diff --git a/.appveyor.yml b/.appveyor.yml index c2db660b52..fd85abb361 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,19 +1,17 @@ init: - - git config --global core.autocrlf true +- git config --global core.autocrlf true branches: only: - - master - - release - - dev - - /^(.*\/)?ci-.*$/ - - /^rel\/.*/ + - dev + - /^release\/.*$/ + - /^(.*\/)?ci-.*$/ build_script: - - ps: .\run.ps1 default-build +- ps: .\run.ps1 default-build clone_depth: 1 environment: global: DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true DOTNET_CLI_TELEMETRY_OPTOUT: 1 -test: off -deploy: off +test: 'off' +deploy: 'off' os: Visual Studio 2017 Preview diff --git a/.gitignore b/.gitignore index 15217d4a09..a0265568eb 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,5 @@ global.json BenchmarkDotNet.Artifacts/ Microsoft.VisualStudio.RazorExtension.nuget.props Microsoft.VisualStudio.RazorExtension.nuget.targets +msbuild.binlog +msbuild.log diff --git a/.travis.yml b/.travis.yml index ceaae0b3b7..28507b93b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,25 +3,25 @@ sudo: required dist: trusty env: global: - - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - - DOTNET_CLI_TELEMETRY_OPTOUT: 1 + - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + - DOTNET_CLI_TELEMETRY_OPTOUT: 1 addons: apt: packages: - - libunwind8 + - libunwind8 mono: none os: - - linux - - osx +- linux +- osx osx_image: xcode8.2 branches: only: - - master - - release - - dev - - /^(.*\/)?ci-.*$/ - - /^rel\/.*/ + - dev + - /^release\/.*$/ + - /^(.*\/)?ci-.*$/ before_install: - - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/; fi +- if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s + /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib + /usr/local/lib/; fi script: - - ./build.sh +- ./build.sh diff --git a/Directory.Build.props b/Directory.Build.props index 0e070d36a3..8260b6f326 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,4 +1,8 @@  + + @@ -13,9 +17,6 @@ true true Microsoft - - - full diff --git a/Razor.Slim.sln b/Razor.Slim.sln deleted file mode 100644 index da9145a9d5..0000000000 --- a/Razor.Slim.sln +++ /dev/null @@ -1,224 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26820.0 -MinimumVisualStudioVersion = 15.0.26730.03 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{3C0D6505-79B3-49D0-B4C3-176F0F1836ED}" - ProjectSection(SolutionItems) = preProject - src\Directory.Build.props = src\Directory.Build.props - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{92463391-81BE-462B-AC3C-78C6C760741F}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor", "src\Microsoft.AspNetCore.Razor\Microsoft.AspNetCore.Razor.csproj", "{EDA30434-C567-44DC-B8B6-2566A7F77163}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Runtime", "src\Microsoft.AspNetCore.Razor.Runtime\Microsoft.AspNetCore.Razor.Runtime.csproj", "{D0196096-1B01-4133-AACE-1A10A0F7247C}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F8C12DD6-659D-405A-AA27-FB22AD92A010}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - Directory.Build.props = Directory.Build.props - Directory.Build.targets = Directory.Build.targets - NuGet.config = NuGet.config - EndProjectSection -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RazorPageGenerator", "src\RazorPageGenerator\RazorPageGenerator.csproj", "{7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Language", "src\Microsoft.AspNetCore.Razor.Language\Microsoft.AspNetCore.Razor.Language.csproj", "{932F3C9C-A6C0-40D3-BA50-9309886242FC}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Language.Test", "test\Microsoft.AspNetCore.Razor.Language.Test\Microsoft.AspNetCore.Razor.Language.Test.csproj", "{969357A4-CCF1-46D9-B002-9AA072AFC75C}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Runtime.Test", "test\Microsoft.AspNetCore.Razor.Runtime.Test\Microsoft.AspNetCore.Razor.Runtime.Test.csproj", "{277AB67E-9C8D-4799-A18C-C628E70A8664}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Razor.Workspaces", "src\Microsoft.CodeAnalysis.Razor.Workspaces\Microsoft.CodeAnalysis.Razor.Workspaces.csproj", "{0F265874-C592-448B-BC4F-3430AB03E0DC}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Remote.Razor", "src\Microsoft.CodeAnalysis.Remote.Razor\Microsoft.CodeAnalysis.Remote.Razor.csproj", "{4EAD959D-73B2-4FB2-B46F-16CEB1EF49D4}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Razor", "src\Microsoft.CodeAnalysis.Razor\Microsoft.CodeAnalysis.Razor.csproj", "{42403DAF-F0BC-4F3A-B7F2-46D7013345D8}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Razor.Test", "test\Microsoft.CodeAnalysis.Razor.Test\Microsoft.CodeAnalysis.Razor.Test.csproj", "{7A8A1664-37CE-4376-81CA-1862CF5F91D9}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RazorPageGenerator.Test", "test\RazorPageGenerator.Test\RazorPageGenerator.Test.csproj", "{96EB1BD4-B8E0-4F52-A068-BBCACA7E3F63}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Razor.Extensions", "src\Microsoft.AspNetCore.Mvc.Razor.Extensions\Microsoft.AspNetCore.Mvc.Razor.Extensions.csproj", "{995F2FEB-65FA-4399-B1C0-16E0B3FBDB15}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Razor.Extensions.Test", "test\Microsoft.AspNetCore.Mvc.Razor.Extensions.Test\Microsoft.AspNetCore.Mvc.Razor.Extensions.Test.csproj", "{7CFD5646-A757-4498-9E01-9C8528ED60AE}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Test.Common", "test\Microsoft.AspNetCore.Razor.Test.Common\Microsoft.AspNetCore.Razor.Test.Common.csproj", "{078AEF36-F319-4CE2-BAA2-5B58A6536B46}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Performance", "test\Microsoft.AspNetCore.Razor.Performance\Microsoft.AspNetCore.Razor.Performance.csproj", "{82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Test.MvcShim", "test\Microsoft.AspNetCore.Razor.Test.MvcShim\Microsoft.AspNetCore.Razor.Test.MvcShim.csproj", "{8F165A3F-A18C-4649-AA08-C0E1BA5F5C90}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Razor.Workspaces.Test", "test\Microsoft.CodeAnalysis.Razor.Workspaces.Test\Microsoft.CodeAnalysis.Razor.Workspaces.Test.csproj", "{C61AAE12-5007-4205-A220-68F354A7F235}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - DebugNoVSIX|Any CPU = DebugNoVSIX|Any CPU - Release|Any CPU = Release|Any CPU - ReleaseNoVSIX|Any CPU = ReleaseNoVSIX|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {EDA30434-C567-44DC-B8B6-2566A7F77163}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EDA30434-C567-44DC-B8B6-2566A7F77163}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EDA30434-C567-44DC-B8B6-2566A7F77163}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {EDA30434-C567-44DC-B8B6-2566A7F77163}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {EDA30434-C567-44DC-B8B6-2566A7F77163}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EDA30434-C567-44DC-B8B6-2566A7F77163}.Release|Any CPU.Build.0 = Release|Any CPU - {EDA30434-C567-44DC-B8B6-2566A7F77163}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {EDA30434-C567-44DC-B8B6-2566A7F77163}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {D0196096-1B01-4133-AACE-1A10A0F7247C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D0196096-1B01-4133-AACE-1A10A0F7247C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D0196096-1B01-4133-AACE-1A10A0F7247C}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {D0196096-1B01-4133-AACE-1A10A0F7247C}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {D0196096-1B01-4133-AACE-1A10A0F7247C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D0196096-1B01-4133-AACE-1A10A0F7247C}.Release|Any CPU.Build.0 = Release|Any CPU - {D0196096-1B01-4133-AACE-1A10A0F7247C}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {D0196096-1B01-4133-AACE-1A10A0F7247C}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.Release|Any CPU.Build.0 = Release|Any CPU - {7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {932F3C9C-A6C0-40D3-BA50-9309886242FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {932F3C9C-A6C0-40D3-BA50-9309886242FC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {932F3C9C-A6C0-40D3-BA50-9309886242FC}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {932F3C9C-A6C0-40D3-BA50-9309886242FC}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {932F3C9C-A6C0-40D3-BA50-9309886242FC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {932F3C9C-A6C0-40D3-BA50-9309886242FC}.Release|Any CPU.Build.0 = Release|Any CPU - {932F3C9C-A6C0-40D3-BA50-9309886242FC}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {932F3C9C-A6C0-40D3-BA50-9309886242FC}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {969357A4-CCF1-46D9-B002-9AA072AFC75C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {969357A4-CCF1-46D9-B002-9AA072AFC75C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {969357A4-CCF1-46D9-B002-9AA072AFC75C}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {969357A4-CCF1-46D9-B002-9AA072AFC75C}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {969357A4-CCF1-46D9-B002-9AA072AFC75C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {969357A4-CCF1-46D9-B002-9AA072AFC75C}.Release|Any CPU.Build.0 = Release|Any CPU - {969357A4-CCF1-46D9-B002-9AA072AFC75C}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {969357A4-CCF1-46D9-B002-9AA072AFC75C}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {277AB67E-9C8D-4799-A18C-C628E70A8664}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {277AB67E-9C8D-4799-A18C-C628E70A8664}.Debug|Any CPU.Build.0 = Debug|Any CPU - {277AB67E-9C8D-4799-A18C-C628E70A8664}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {277AB67E-9C8D-4799-A18C-C628E70A8664}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {277AB67E-9C8D-4799-A18C-C628E70A8664}.Release|Any CPU.ActiveCfg = Release|Any CPU - {277AB67E-9C8D-4799-A18C-C628E70A8664}.Release|Any CPU.Build.0 = Release|Any CPU - {277AB67E-9C8D-4799-A18C-C628E70A8664}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {277AB67E-9C8D-4799-A18C-C628E70A8664}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {0F265874-C592-448B-BC4F-3430AB03E0DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0F265874-C592-448B-BC4F-3430AB03E0DC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0F265874-C592-448B-BC4F-3430AB03E0DC}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {0F265874-C592-448B-BC4F-3430AB03E0DC}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {0F265874-C592-448B-BC4F-3430AB03E0DC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0F265874-C592-448B-BC4F-3430AB03E0DC}.Release|Any CPU.Build.0 = Release|Any CPU - {0F265874-C592-448B-BC4F-3430AB03E0DC}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {0F265874-C592-448B-BC4F-3430AB03E0DC}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {4EAD959D-73B2-4FB2-B46F-16CEB1EF49D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4EAD959D-73B2-4FB2-B46F-16CEB1EF49D4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4EAD959D-73B2-4FB2-B46F-16CEB1EF49D4}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {4EAD959D-73B2-4FB2-B46F-16CEB1EF49D4}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {4EAD959D-73B2-4FB2-B46F-16CEB1EF49D4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4EAD959D-73B2-4FB2-B46F-16CEB1EF49D4}.Release|Any CPU.Build.0 = Release|Any CPU - {4EAD959D-73B2-4FB2-B46F-16CEB1EF49D4}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {4EAD959D-73B2-4FB2-B46F-16CEB1EF49D4}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {42403DAF-F0BC-4F3A-B7F2-46D7013345D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {42403DAF-F0BC-4F3A-B7F2-46D7013345D8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {42403DAF-F0BC-4F3A-B7F2-46D7013345D8}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {42403DAF-F0BC-4F3A-B7F2-46D7013345D8}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {42403DAF-F0BC-4F3A-B7F2-46D7013345D8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {42403DAF-F0BC-4F3A-B7F2-46D7013345D8}.Release|Any CPU.Build.0 = Release|Any CPU - {42403DAF-F0BC-4F3A-B7F2-46D7013345D8}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {42403DAF-F0BC-4F3A-B7F2-46D7013345D8}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {7A8A1664-37CE-4376-81CA-1862CF5F91D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7A8A1664-37CE-4376-81CA-1862CF5F91D9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7A8A1664-37CE-4376-81CA-1862CF5F91D9}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {7A8A1664-37CE-4376-81CA-1862CF5F91D9}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {7A8A1664-37CE-4376-81CA-1862CF5F91D9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7A8A1664-37CE-4376-81CA-1862CF5F91D9}.Release|Any CPU.Build.0 = Release|Any CPU - {7A8A1664-37CE-4376-81CA-1862CF5F91D9}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {7A8A1664-37CE-4376-81CA-1862CF5F91D9}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {96EB1BD4-B8E0-4F52-A068-BBCACA7E3F63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {96EB1BD4-B8E0-4F52-A068-BBCACA7E3F63}.Debug|Any CPU.Build.0 = Debug|Any CPU - {96EB1BD4-B8E0-4F52-A068-BBCACA7E3F63}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {96EB1BD4-B8E0-4F52-A068-BBCACA7E3F63}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {96EB1BD4-B8E0-4F52-A068-BBCACA7E3F63}.Release|Any CPU.ActiveCfg = Release|Any CPU - {96EB1BD4-B8E0-4F52-A068-BBCACA7E3F63}.Release|Any CPU.Build.0 = Release|Any CPU - {96EB1BD4-B8E0-4F52-A068-BBCACA7E3F63}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {96EB1BD4-B8E0-4F52-A068-BBCACA7E3F63}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {995F2FEB-65FA-4399-B1C0-16E0B3FBDB15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {995F2FEB-65FA-4399-B1C0-16E0B3FBDB15}.Debug|Any CPU.Build.0 = Debug|Any CPU - {995F2FEB-65FA-4399-B1C0-16E0B3FBDB15}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {995F2FEB-65FA-4399-B1C0-16E0B3FBDB15}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {995F2FEB-65FA-4399-B1C0-16E0B3FBDB15}.Release|Any CPU.ActiveCfg = Release|Any CPU - {995F2FEB-65FA-4399-B1C0-16E0B3FBDB15}.Release|Any CPU.Build.0 = Release|Any CPU - {995F2FEB-65FA-4399-B1C0-16E0B3FBDB15}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {995F2FEB-65FA-4399-B1C0-16E0B3FBDB15}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {7CFD5646-A757-4498-9E01-9C8528ED60AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7CFD5646-A757-4498-9E01-9C8528ED60AE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7CFD5646-A757-4498-9E01-9C8528ED60AE}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {7CFD5646-A757-4498-9E01-9C8528ED60AE}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {7CFD5646-A757-4498-9E01-9C8528ED60AE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7CFD5646-A757-4498-9E01-9C8528ED60AE}.Release|Any CPU.Build.0 = Release|Any CPU - {7CFD5646-A757-4498-9E01-9C8528ED60AE}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {7CFD5646-A757-4498-9E01-9C8528ED60AE}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {078AEF36-F319-4CE2-BAA2-5B58A6536B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {078AEF36-F319-4CE2-BAA2-5B58A6536B46}.Debug|Any CPU.Build.0 = Debug|Any CPU - {078AEF36-F319-4CE2-BAA2-5B58A6536B46}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {078AEF36-F319-4CE2-BAA2-5B58A6536B46}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {078AEF36-F319-4CE2-BAA2-5B58A6536B46}.Release|Any CPU.ActiveCfg = Release|Any CPU - {078AEF36-F319-4CE2-BAA2-5B58A6536B46}.Release|Any CPU.Build.0 = Release|Any CPU - {078AEF36-F319-4CE2-BAA2-5B58A6536B46}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {078AEF36-F319-4CE2-BAA2-5B58A6536B46}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.Debug|Any CPU.Build.0 = Debug|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.Release|Any CPU.ActiveCfg = Release|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.Release|Any CPU.Build.0 = Release|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {8F165A3F-A18C-4649-AA08-C0E1BA5F5C90}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8F165A3F-A18C-4649-AA08-C0E1BA5F5C90}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8F165A3F-A18C-4649-AA08-C0E1BA5F5C90}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {8F165A3F-A18C-4649-AA08-C0E1BA5F5C90}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {8F165A3F-A18C-4649-AA08-C0E1BA5F5C90}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8F165A3F-A18C-4649-AA08-C0E1BA5F5C90}.Release|Any CPU.Build.0 = Release|Any CPU - {8F165A3F-A18C-4649-AA08-C0E1BA5F5C90}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {8F165A3F-A18C-4649-AA08-C0E1BA5F5C90}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {C61AAE12-5007-4205-A220-68F354A7F235}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C61AAE12-5007-4205-A220-68F354A7F235}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C61AAE12-5007-4205-A220-68F354A7F235}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {C61AAE12-5007-4205-A220-68F354A7F235}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {C61AAE12-5007-4205-A220-68F354A7F235}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C61AAE12-5007-4205-A220-68F354A7F235}.Release|Any CPU.Build.0 = Release|Any CPU - {C61AAE12-5007-4205-A220-68F354A7F235}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {C61AAE12-5007-4205-A220-68F354A7F235}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {EDA30434-C567-44DC-B8B6-2566A7F77163} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} - {D0196096-1B01-4133-AACE-1A10A0F7247C} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} - {7BE58880-36AD-4CD5-9E16-2A5AFEA790EF} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} - {932F3C9C-A6C0-40D3-BA50-9309886242FC} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} - {969357A4-CCF1-46D9-B002-9AA072AFC75C} = {92463391-81BE-462B-AC3C-78C6C760741F} - {277AB67E-9C8D-4799-A18C-C628E70A8664} = {92463391-81BE-462B-AC3C-78C6C760741F} - {0F265874-C592-448B-BC4F-3430AB03E0DC} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} - {4EAD959D-73B2-4FB2-B46F-16CEB1EF49D4} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} - {42403DAF-F0BC-4F3A-B7F2-46D7013345D8} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} - {7A8A1664-37CE-4376-81CA-1862CF5F91D9} = {92463391-81BE-462B-AC3C-78C6C760741F} - {96EB1BD4-B8E0-4F52-A068-BBCACA7E3F63} = {92463391-81BE-462B-AC3C-78C6C760741F} - {995F2FEB-65FA-4399-B1C0-16E0B3FBDB15} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} - {7CFD5646-A757-4498-9E01-9C8528ED60AE} = {92463391-81BE-462B-AC3C-78C6C760741F} - {078AEF36-F319-4CE2-BAA2-5B58A6536B46} = {92463391-81BE-462B-AC3C-78C6C760741F} - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58} = {92463391-81BE-462B-AC3C-78C6C760741F} - {8F165A3F-A18C-4649-AA08-C0E1BA5F5C90} = {92463391-81BE-462B-AC3C-78C6C760741F} - {C61AAE12-5007-4205-A220-68F354A7F235} = {92463391-81BE-462B-AC3C-78C6C760741F} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {057E86AD-8BD3-4E03-978C-42B8A5A3C024} - EndGlobalSection -EndGlobal diff --git a/Razor.sln b/Razor.sln index 9f65845f9c..0d8570750e 100644 --- a/Razor.sln +++ b/Razor.sln @@ -53,8 +53,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Ra EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Test.Common", "test\Microsoft.AspNetCore.Razor.Test.Common\Microsoft.AspNetCore.Razor.Test.Common.csproj", "{078AEF36-F319-4CE2-BAA2-5B58A6536B46}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Performance", "test\Microsoft.AspNetCore.Razor.Performance\Microsoft.AspNetCore.Razor.Performance.csproj", "{82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Test.MvcShim", "test\Microsoft.AspNetCore.Razor.Test.MvcShim\Microsoft.AspNetCore.Razor.Test.MvcShim.csproj", "{8F165A3F-A18C-4649-AA08-C0E1BA5F5C90}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Razor.Workspaces.Test", "test\Microsoft.CodeAnalysis.Razor.Workspaces.Test\Microsoft.CodeAnalysis.Razor.Workspaces.Test.csproj", "{C61AAE12-5007-4205-A220-68F354A7F235}" @@ -75,6 +73,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.Mac. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.Mac.LanguageServices.Razor", "src\Microsoft.VisualStudio.Mac.LanguageServices.Razor\Microsoft.VisualStudio.Mac.LanguageServices.Razor.csproj", "{95B18DEE-8B45-4CF0-B9F8-CCBAF3B5251A}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmarks", "benchmarks", "{4595A6F1-81C5-4A0A-A3DC-81F108523AEC}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Performance", "benchmarks\Microsoft.AspNetCore.Razor.Performance\Microsoft.AspNetCore.Razor.Performance.csproj", "{BE1CE01F-5342-4075-BD46-DB4D857BC1FE}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common", "test\Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common\Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common.csproj", "{E41C50E7-79D0-442C-832A-E6B1A2EF4B67}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Test", "test\Microsoft.AspNetCore.Razor.Test\Microsoft.AspNetCore.Razor.Test.csproj", "{93F116E1-9421-4D55-BF3E-F8DDF8F2172C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -217,14 +223,6 @@ Global {078AEF36-F319-4CE2-BAA2-5B58A6536B46}.Release|Any CPU.Build.0 = Release|Any CPU {078AEF36-F319-4CE2-BAA2-5B58A6536B46}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU {078AEF36-F319-4CE2-BAA2-5B58A6536B46}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.Debug|Any CPU.Build.0 = Debug|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.Release|Any CPU.ActiveCfg = Release|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.Release|Any CPU.Build.0 = Release|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU {8F165A3F-A18C-4649-AA08-C0E1BA5F5C90}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8F165A3F-A18C-4649-AA08-C0E1BA5F5C90}.Debug|Any CPU.Build.0 = Debug|Any CPU {8F165A3F-A18C-4649-AA08-C0E1BA5F5C90}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU @@ -305,6 +303,30 @@ Global {95B18DEE-8B45-4CF0-B9F8-CCBAF3B5251A}.Release|Any CPU.Build.0 = Release|Any CPU {95B18DEE-8B45-4CF0-B9F8-CCBAF3B5251A}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU {95B18DEE-8B45-4CF0-B9F8-CCBAF3B5251A}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU + {BE1CE01F-5342-4075-BD46-DB4D857BC1FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BE1CE01F-5342-4075-BD46-DB4D857BC1FE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BE1CE01F-5342-4075-BD46-DB4D857BC1FE}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU + {BE1CE01F-5342-4075-BD46-DB4D857BC1FE}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU + {BE1CE01F-5342-4075-BD46-DB4D857BC1FE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BE1CE01F-5342-4075-BD46-DB4D857BC1FE}.Release|Any CPU.Build.0 = Release|Any CPU + {BE1CE01F-5342-4075-BD46-DB4D857BC1FE}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU + {BE1CE01F-5342-4075-BD46-DB4D857BC1FE}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU + {E41C50E7-79D0-442C-832A-E6B1A2EF4B67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E41C50E7-79D0-442C-832A-E6B1A2EF4B67}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E41C50E7-79D0-442C-832A-E6B1A2EF4B67}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU + {E41C50E7-79D0-442C-832A-E6B1A2EF4B67}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU + {E41C50E7-79D0-442C-832A-E6B1A2EF4B67}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E41C50E7-79D0-442C-832A-E6B1A2EF4B67}.Release|Any CPU.Build.0 = Release|Any CPU + {E41C50E7-79D0-442C-832A-E6B1A2EF4B67}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU + {E41C50E7-79D0-442C-832A-E6B1A2EF4B67}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU + {93F116E1-9421-4D55-BF3E-F8DDF8F2172C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {93F116E1-9421-4D55-BF3E-F8DDF8F2172C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {93F116E1-9421-4D55-BF3E-F8DDF8F2172C}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU + {93F116E1-9421-4D55-BF3E-F8DDF8F2172C}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU + {93F116E1-9421-4D55-BF3E-F8DDF8F2172C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {93F116E1-9421-4D55-BF3E-F8DDF8F2172C}.Release|Any CPU.Build.0 = Release|Any CPU + {93F116E1-9421-4D55-BF3E-F8DDF8F2172C}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU + {93F116E1-9421-4D55-BF3E-F8DDF8F2172C}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -327,7 +349,6 @@ Global {995F2FEB-65FA-4399-B1C0-16E0B3FBDB15} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} {7CFD5646-A757-4498-9E01-9C8528ED60AE} = {92463391-81BE-462B-AC3C-78C6C760741F} {078AEF36-F319-4CE2-BAA2-5B58A6536B46} = {92463391-81BE-462B-AC3C-78C6C760741F} - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58} = {92463391-81BE-462B-AC3C-78C6C760741F} {8F165A3F-A18C-4649-AA08-C0E1BA5F5C90} = {92463391-81BE-462B-AC3C-78C6C760741F} {C61AAE12-5007-4205-A220-68F354A7F235} = {92463391-81BE-462B-AC3C-78C6C760741F} {F1538809-7347-45D2-A7AC-C1D89CF0BBD4} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} @@ -338,6 +359,9 @@ Global {FC684D4F-D23C-407C-9C68-E10EF3B38560} = {92463391-81BE-462B-AC3C-78C6C760741F} {FAF9986F-E086-4513-9D52-F7BF5FFCF31D} = {C0CC1E1F-1559-44DE-93A8-63259CEA2AAB} {95B18DEE-8B45-4CF0-B9F8-CCBAF3B5251A} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} + {BE1CE01F-5342-4075-BD46-DB4D857BC1FE} = {4595A6F1-81C5-4A0A-A3DC-81F108523AEC} + {E41C50E7-79D0-442C-832A-E6B1A2EF4B67} = {92463391-81BE-462B-AC3C-78C6C760741F} + {93F116E1-9421-4D55-BF3E-F8DDF8F2172C} = {92463391-81BE-462B-AC3C-78C6C760741F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {0035341D-175A-4D05-95E6-F1C2785A1E26} diff --git a/benchmarks/Microsoft.AspNetCore.Razor.Performance/AssemblyInfo.cs b/benchmarks/Microsoft.AspNetCore.Razor.Performance/AssemblyInfo.cs new file mode 100644 index 0000000000..32248e0d1b --- /dev/null +++ b/benchmarks/Microsoft.AspNetCore.Razor.Performance/AssemblyInfo.cs @@ -0,0 +1 @@ +[assembly: BenchmarkDotNet.Attributes.AspNetCoreBenchmark] diff --git a/test/Microsoft.AspNetCore.Razor.Performance/CodeGenerationBenchmark.cs b/benchmarks/Microsoft.AspNetCore.Razor.Performance/CodeGenerationBenchmark.cs similarity index 54% rename from test/Microsoft.AspNetCore.Razor.Performance/CodeGenerationBenchmark.cs rename to benchmarks/Microsoft.AspNetCore.Razor.Performance/CodeGenerationBenchmark.cs index e9e0349f43..c35e1db42f 100644 --- a/test/Microsoft.AspNetCore.Razor.Performance/CodeGenerationBenchmark.cs +++ b/benchmarks/Microsoft.AspNetCore.Razor.Performance/CodeGenerationBenchmark.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using System.IO; using BenchmarkDotNet.Attributes; using Microsoft.AspNetCore.Mvc.Razor.Extensions; @@ -10,7 +9,6 @@ using Microsoft.AspNetCore.Razor.Language; namespace Microsoft.AspNetCore.Razor.Performance { - [Config(typeof(CoreConfig))] public class CodeGenerationBenchmark { public CodeGenerationBenchmark() @@ -22,33 +20,22 @@ namespace Microsoft.AspNetCore.Razor.Performance } var root = current; + var fileSystem = RazorProjectFileSystem.Create(root.FullName); + + ProjectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, fileSystem, b => RazorExtensions.Register(b)); ; - var engine = RazorEngine.Create(b => { RazorExtensions.Register(b); }); - - var project = RazorProject.Create(root.FullName); - - DesignTimeTemplateEngine = new MvcRazorTemplateEngine(RazorEngine.CreateDesignTime(b => { RazorExtensions.Register(b); }), project); - RuntimeTemplateEngine = new MvcRazorTemplateEngine(RazorEngine.Create(b => { RazorExtensions.Register(b); }), project); - - var codeDocument = RuntimeTemplateEngine.CreateCodeDocument(Path.Combine(root.FullName, "MSN.cshtml")); - - Imports = codeDocument.Imports; - MSN = codeDocument.Source; + MSN = fileSystem.GetItem(Path.Combine(root.FullName, "MSN.cshtml")); } - public RazorTemplateEngine DesignTimeTemplateEngine { get; } + public RazorProjectEngine ProjectEngine { get; } - public RazorTemplateEngine RuntimeTemplateEngine { get; } - - public IReadOnlyList Imports { get; } - - public RazorSourceDocument MSN { get; } + public RazorProjectItem MSN { get; } [Benchmark(Description = "Razor Design Time Code Generation of MSN.com")] public void CodeGeneration_DesignTime_LargeStaticFile() { - var codeDocument = RazorCodeDocument.Create(MSN, Imports); - var generated = DesignTimeTemplateEngine.GenerateCode(codeDocument); + var codeDocument = ProjectEngine.ProcessDesignTime(MSN); + var generated = codeDocument.GetCSharpDocument(); if (generated.Diagnostics.Count != 0) { @@ -59,8 +46,8 @@ namespace Microsoft.AspNetCore.Razor.Performance [Benchmark(Description = "Razor Runtime Code Generation of MSN.com")] public void CodeGeneration_Runtime_LargeStaticFile() { - var codeDocument = RazorCodeDocument.Create(MSN, Imports); - var generated = RuntimeTemplateEngine.GenerateCode(codeDocument); + var codeDocument = ProjectEngine.Process(MSN); + var generated = codeDocument.GetCSharpDocument(); if (generated.Diagnostics.Count != 0) { diff --git a/test/Microsoft.AspNetCore.Razor.Performance/MSN.cshtml b/benchmarks/Microsoft.AspNetCore.Razor.Performance/MSN.cshtml similarity index 100% rename from test/Microsoft.AspNetCore.Razor.Performance/MSN.cshtml rename to benchmarks/Microsoft.AspNetCore.Razor.Performance/MSN.cshtml diff --git a/benchmarks/Microsoft.AspNetCore.Razor.Performance/Microsoft.AspNetCore.Razor.Performance.csproj b/benchmarks/Microsoft.AspNetCore.Razor.Performance/Microsoft.AspNetCore.Razor.Performance.csproj new file mode 100644 index 0000000000..e63049a74f --- /dev/null +++ b/benchmarks/Microsoft.AspNetCore.Razor.Performance/Microsoft.AspNetCore.Razor.Performance.csproj @@ -0,0 +1,30 @@ + + + + netcoreapp2.0 + Exe + true + true + false + + + + + + + + + Shared\RazorDiagnosticJsonConverter.cs + + + Shared\TagHelperDescriptorJsonConverter.cs + + + + + + + + + + diff --git a/benchmarks/Microsoft.AspNetCore.Razor.Performance/TagHelperSerializationBenchmark.cs b/benchmarks/Microsoft.AspNetCore.Razor.Performance/TagHelperSerializationBenchmark.cs new file mode 100644 index 0000000000..bfee04164f --- /dev/null +++ b/benchmarks/Microsoft.AspNetCore.Razor.Performance/TagHelperSerializationBenchmark.cs @@ -0,0 +1,54 @@ +// 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.Collections.Generic; +using System.IO; +using System.Text; +using BenchmarkDotNet.Attributes; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.VisualStudio.LanguageServices.Razor; +using Newtonsoft.Json; + +namespace Microsoft.AspNetCore.Razor.Performance +{ + public class TagHelperSerializationBenchmark + { + private readonly byte[] _tagHelperBuffer; + + public TagHelperSerializationBenchmark() + { + var current = new DirectoryInfo(AppContext.BaseDirectory); + while (current != null && !File.Exists(Path.Combine(current.FullName, "taghelpers.json"))) + { + current = current.Parent; + } + + var tagHelperFilePath = Path.Combine(current.FullName, "taghelpers.json"); + _tagHelperBuffer = File.ReadAllBytes(tagHelperFilePath); + } + + [Benchmark(Description = "Razor TagHelper Serialization")] + public void TagHelper_Serialization_RoundTrip() + { + var serializer = new JsonSerializer(); + serializer.Converters.Add(new RazorDiagnosticJsonConverter()); + serializer.Converters.Add(new TagHelperDescriptorJsonConverter()); + + // Deserialize from json file. + IReadOnlyList tagHelpers; + using (var stream = new MemoryStream(_tagHelperBuffer)) + using (var reader = new JsonTextReader(new StreamReader(stream))) + { + tagHelpers = serializer.Deserialize>(reader); + } + + // Serialize back to json. + using (var stream = new MemoryStream()) + using (var writer = new StreamWriter(stream, Encoding.UTF8, bufferSize: 4096)) + { + serializer.Serialize(writer, tagHelpers); + } + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Performance/readme.md b/benchmarks/Microsoft.AspNetCore.Razor.Performance/readme.md similarity index 100% rename from test/Microsoft.AspNetCore.Razor.Performance/readme.md rename to benchmarks/Microsoft.AspNetCore.Razor.Performance/readme.md diff --git a/benchmarks/Microsoft.AspNetCore.Razor.Performance/taghelpers.json b/benchmarks/Microsoft.AspNetCore.Razor.Performance/taghelpers.json new file mode 100644 index 0000000000..27dcb16038 --- /dev/null +++ b/benchmarks/Microsoft.AspNetCore.Razor.Performance/taghelpers.json @@ -0,0 +1 @@ +[{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.SpaServices.Prerendering.PrerenderTagHelper","TagMatchingRules":[{"TagName":"*","Attributes":[{"Name":"asp-prerender-module","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-prerender-module","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.SpaServices","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-prerender-module","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.SpaServices.Prerendering.PrerenderTagHelper.ModuleName","Diagnostics":[],"Metadata":{"Common.PropertyName":"ModuleName"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-prerender-export","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.SpaServices.Prerendering.PrerenderTagHelper.ExportName","Diagnostics":[],"Metadata":{"Common.PropertyName":"ExportName"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"asp-prerender-data","IndexerNamePrefix":null,"TypeName":"System.Object","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"object Microsoft.AspNetCore.SpaServices.Prerendering.PrerenderTagHelper.CustomDataParameter","Diagnostics":[],"Metadata":{"Common.PropertyName":"CustomDataParameter"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"asp-prerender-timeout","IndexerNamePrefix":null,"TypeName":"System.Int32","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"int Microsoft.AspNetCore.SpaServices.Prerendering.PrerenderTagHelper.TimeoutMillisecondsParameter","Diagnostics":[],"Metadata":{"Common.PropertyName":"TimeoutMillisecondsParameter"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.SpaServices.Prerendering.PrerenderTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.SpaServices.Prerendering.PrerenderTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper","TagMatchingRules":[{"TagName":"a","Attributes":[{"Name":"asp-action","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-action","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"a","Attributes":[{"Name":"asp-controller","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-controller","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"a","Attributes":[{"Name":"asp-area","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-area","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"a","Attributes":[{"Name":"asp-page","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-page","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"a","Attributes":[{"Name":"asp-page-handler","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-page-handler","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"a","Attributes":[{"Name":"asp-fragment","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-fragment","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"a","Attributes":[{"Name":"asp-host","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-host","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"a","Attributes":[{"Name":"asp-protocol","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-protocol","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"a","Attributes":[{"Name":"asp-route","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-route","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"a","Attributes":[{"Name":"asp-all-route-data","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-all-route-data","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"a","Attributes":[{"Name":"asp-route-","NameComparison":1,"Value":null,"ValueComparison":0,"DisplayName":"asp-route-...","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-action","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper.Action","Diagnostics":[],"Metadata":{"Common.PropertyName":"Action"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-controller","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper.Controller","Diagnostics":[],"Metadata":{"Common.PropertyName":"Controller"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-area","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper.Area","Diagnostics":[],"Metadata":{"Common.PropertyName":"Area"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-page","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper.Page","Diagnostics":[],"Metadata":{"Common.PropertyName":"Page"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-page-handler","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper.PageHandler","Diagnostics":[],"Metadata":{"Common.PropertyName":"PageHandler"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-protocol","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper.Protocol","Diagnostics":[],"Metadata":{"Common.PropertyName":"Protocol"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-host","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper.Host","Diagnostics":[],"Metadata":{"Common.PropertyName":"Host"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-fragment","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper.Fragment","Diagnostics":[],"Metadata":{"Common.PropertyName":"Fragment"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-route","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper.Route","Diagnostics":[],"Metadata":{"Common.PropertyName":"Route"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":true,"IsEnum":false,"IsStringProperty":false,"Name":"asp-all-route-data","IndexerNamePrefix":"asp-route-","TypeName":"System.Collections.Generic.IDictionary","IndexerTypeName":"System.String","HasIndexer":true,"Documentation":null,"DisplayName":"System.Collections.Generic.IDictionary Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper.RouteValues","Diagnostics":[],"Metadata":{"Common.PropertyName":"RouteValues"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.CacheTagHelper","TagMatchingRules":[{"TagName":"cache","Attributes":[],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"priority","IndexerNamePrefix":null,"TypeName":"Microsoft.Extensions.Caching.Memory.CacheItemPriority?","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"Microsoft.Extensions.Caching.Memory.CacheItemPriority? Microsoft.AspNetCore.Mvc.TagHelpers.CacheTagHelper.Priority","Diagnostics":[],"Metadata":{"Common.PropertyName":"Priority"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"vary-by","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.CacheTagHelper.VaryBy","Diagnostics":[],"Metadata":{"Common.PropertyName":"VaryBy"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"vary-by-header","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.CacheTagHelper.VaryByHeader","Diagnostics":[],"Metadata":{"Common.PropertyName":"VaryByHeader"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"vary-by-query","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.CacheTagHelper.VaryByQuery","Diagnostics":[],"Metadata":{"Common.PropertyName":"VaryByQuery"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"vary-by-route","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.CacheTagHelper.VaryByRoute","Diagnostics":[],"Metadata":{"Common.PropertyName":"VaryByRoute"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"vary-by-cookie","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.CacheTagHelper.VaryByCookie","Diagnostics":[],"Metadata":{"Common.PropertyName":"VaryByCookie"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"vary-by-user","IndexerNamePrefix":null,"TypeName":"System.Boolean","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"bool Microsoft.AspNetCore.Mvc.TagHelpers.CacheTagHelper.VaryByUser","Diagnostics":[],"Metadata":{"Common.PropertyName":"VaryByUser"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"expires-on","IndexerNamePrefix":null,"TypeName":"System.DateTimeOffset?","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"System.DateTimeOffset? Microsoft.AspNetCore.Mvc.TagHelpers.CacheTagHelper.ExpiresOn","Diagnostics":[],"Metadata":{"Common.PropertyName":"ExpiresOn"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"expires-after","IndexerNamePrefix":null,"TypeName":"System.TimeSpan?","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"System.TimeSpan? Microsoft.AspNetCore.Mvc.TagHelpers.CacheTagHelper.ExpiresAfter","Diagnostics":[],"Metadata":{"Common.PropertyName":"ExpiresAfter"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"expires-sliding","IndexerNamePrefix":null,"TypeName":"System.TimeSpan?","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"System.TimeSpan? Microsoft.AspNetCore.Mvc.TagHelpers.CacheTagHelper.ExpiresSliding","Diagnostics":[],"Metadata":{"Common.PropertyName":"ExpiresSliding"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"enabled","IndexerNamePrefix":null,"TypeName":"System.Boolean","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"bool Microsoft.AspNetCore.Mvc.TagHelpers.CacheTagHelper.Enabled","Diagnostics":[],"Metadata":{"Common.PropertyName":"Enabled"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.CacheTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.CacheTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.DistributedCacheTagHelper","TagMatchingRules":[{"TagName":"distributed-cache","Attributes":[{"Name":"name","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"name","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"name","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.DistributedCacheTagHelper.Name","Diagnostics":[],"Metadata":{"Common.PropertyName":"Name"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"vary-by","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.DistributedCacheTagHelper.VaryBy","Diagnostics":[],"Metadata":{"Common.PropertyName":"VaryBy"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"vary-by-header","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.DistributedCacheTagHelper.VaryByHeader","Diagnostics":[],"Metadata":{"Common.PropertyName":"VaryByHeader"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"vary-by-query","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.DistributedCacheTagHelper.VaryByQuery","Diagnostics":[],"Metadata":{"Common.PropertyName":"VaryByQuery"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"vary-by-route","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.DistributedCacheTagHelper.VaryByRoute","Diagnostics":[],"Metadata":{"Common.PropertyName":"VaryByRoute"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"vary-by-cookie","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.DistributedCacheTagHelper.VaryByCookie","Diagnostics":[],"Metadata":{"Common.PropertyName":"VaryByCookie"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"vary-by-user","IndexerNamePrefix":null,"TypeName":"System.Boolean","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"bool Microsoft.AspNetCore.Mvc.TagHelpers.DistributedCacheTagHelper.VaryByUser","Diagnostics":[],"Metadata":{"Common.PropertyName":"VaryByUser"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"expires-on","IndexerNamePrefix":null,"TypeName":"System.DateTimeOffset?","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"System.DateTimeOffset? Microsoft.AspNetCore.Mvc.TagHelpers.DistributedCacheTagHelper.ExpiresOn","Diagnostics":[],"Metadata":{"Common.PropertyName":"ExpiresOn"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"expires-after","IndexerNamePrefix":null,"TypeName":"System.TimeSpan?","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"System.TimeSpan? Microsoft.AspNetCore.Mvc.TagHelpers.DistributedCacheTagHelper.ExpiresAfter","Diagnostics":[],"Metadata":{"Common.PropertyName":"ExpiresAfter"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"expires-sliding","IndexerNamePrefix":null,"TypeName":"System.TimeSpan?","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"System.TimeSpan? Microsoft.AspNetCore.Mvc.TagHelpers.DistributedCacheTagHelper.ExpiresSliding","Diagnostics":[],"Metadata":{"Common.PropertyName":"ExpiresSliding"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"enabled","IndexerNamePrefix":null,"TypeName":"System.Boolean","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"bool Microsoft.AspNetCore.Mvc.TagHelpers.DistributedCacheTagHelper.Enabled","Diagnostics":[],"Metadata":{"Common.PropertyName":"Enabled"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.DistributedCacheTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.DistributedCacheTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.EnvironmentTagHelper","TagMatchingRules":[{"TagName":"environment","Attributes":[],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"names","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.EnvironmentTagHelper.Names","Diagnostics":[],"Metadata":{"Common.PropertyName":"Names"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"include","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.EnvironmentTagHelper.Include","Diagnostics":[],"Metadata":{"Common.PropertyName":"Include"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"exclude","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.EnvironmentTagHelper.Exclude","Diagnostics":[],"Metadata":{"Common.PropertyName":"Exclude"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.EnvironmentTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.EnvironmentTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.FormActionTagHelper","TagMatchingRules":[{"TagName":"button","Attributes":[{"Name":"asp-action","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-action","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"button","Attributes":[{"Name":"asp-controller","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-controller","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"button","Attributes":[{"Name":"asp-area","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-area","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"button","Attributes":[{"Name":"asp-page","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-page","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"button","Attributes":[{"Name":"asp-page-handler","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-page-handler","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"button","Attributes":[{"Name":"asp-fragment","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-fragment","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"button","Attributes":[{"Name":"asp-route","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-route","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"button","Attributes":[{"Name":"asp-all-route-data","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-all-route-data","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"button","Attributes":[{"Name":"asp-route-","NameComparison":1,"Value":null,"ValueComparison":0,"DisplayName":"asp-route-...","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"image","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-action","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-action","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"image","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-controller","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-controller","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"image","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-area","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-area","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"image","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-page","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-page","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"image","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-page-handler","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-page-handler","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"image","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-fragment","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-fragment","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"image","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-route","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-route","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"image","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-all-route-data","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-all-route-data","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"image","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-route-","NameComparison":1,"Value":null,"ValueComparison":0,"DisplayName":"asp-route-...","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"submit","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-action","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-action","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"submit","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-controller","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-controller","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"submit","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-area","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-area","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"submit","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-page","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-page","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"submit","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-page-handler","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-page-handler","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"submit","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-fragment","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-fragment","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"submit","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-route","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-route","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"submit","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-all-route-data","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-all-route-data","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"submit","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-route-","NameComparison":1,"Value":null,"ValueComparison":0,"DisplayName":"asp-route-...","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-action","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.FormActionTagHelper.Action","Diagnostics":[],"Metadata":{"Common.PropertyName":"Action"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-controller","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.FormActionTagHelper.Controller","Diagnostics":[],"Metadata":{"Common.PropertyName":"Controller"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-area","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.FormActionTagHelper.Area","Diagnostics":[],"Metadata":{"Common.PropertyName":"Area"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-page","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.FormActionTagHelper.Page","Diagnostics":[],"Metadata":{"Common.PropertyName":"Page"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-page-handler","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.FormActionTagHelper.PageHandler","Diagnostics":[],"Metadata":{"Common.PropertyName":"PageHandler"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-fragment","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.FormActionTagHelper.Fragment","Diagnostics":[],"Metadata":{"Common.PropertyName":"Fragment"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-route","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.FormActionTagHelper.Route","Diagnostics":[],"Metadata":{"Common.PropertyName":"Route"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":true,"IsEnum":false,"IsStringProperty":false,"Name":"asp-all-route-data","IndexerNamePrefix":"asp-route-","TypeName":"System.Collections.Generic.IDictionary","IndexerTypeName":"System.String","HasIndexer":true,"Documentation":null,"DisplayName":"System.Collections.Generic.IDictionary Microsoft.AspNetCore.Mvc.TagHelpers.FormActionTagHelper.RouteValues","Diagnostics":[],"Metadata":{"Common.PropertyName":"RouteValues"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.FormActionTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.FormActionTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper","TagMatchingRules":[{"TagName":"form","Attributes":[],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-action","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper.Action","Diagnostics":[],"Metadata":{"Common.PropertyName":"Action"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-controller","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper.Controller","Diagnostics":[],"Metadata":{"Common.PropertyName":"Controller"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-area","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper.Area","Diagnostics":[],"Metadata":{"Common.PropertyName":"Area"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-page","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper.Page","Diagnostics":[],"Metadata":{"Common.PropertyName":"Page"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-page-handler","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper.PageHandler","Diagnostics":[],"Metadata":{"Common.PropertyName":"PageHandler"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"asp-antiforgery","IndexerNamePrefix":null,"TypeName":"System.Boolean?","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"System.Boolean? Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper.Antiforgery","Diagnostics":[],"Metadata":{"Common.PropertyName":"Antiforgery"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-fragment","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper.Fragment","Diagnostics":[],"Metadata":{"Common.PropertyName":"Fragment"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-route","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper.Route","Diagnostics":[],"Metadata":{"Common.PropertyName":"Route"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"method","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper.Method","Diagnostics":[],"Metadata":{"Common.PropertyName":"Method"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":true,"IsEnum":false,"IsStringProperty":false,"Name":"asp-all-route-data","IndexerNamePrefix":"asp-route-","TypeName":"System.Collections.Generic.IDictionary","IndexerTypeName":"System.String","HasIndexer":true,"Documentation":null,"DisplayName":"System.Collections.Generic.IDictionary Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper.RouteValues","Diagnostics":[],"Metadata":{"Common.PropertyName":"RouteValues"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.ImageTagHelper","TagMatchingRules":[{"TagName":"img","Attributes":[{"Name":"asp-append-version","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-append-version","Diagnostics":[],"HasErrors":false},{"Name":"src","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"src","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"src","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.ImageTagHelper.Src","Diagnostics":[],"Metadata":{"Common.PropertyName":"Src"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"asp-append-version","IndexerNamePrefix":null,"TypeName":"System.Boolean","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"bool Microsoft.AspNetCore.Mvc.TagHelpers.ImageTagHelper.AppendVersion","Diagnostics":[],"Metadata":{"Common.PropertyName":"AppendVersion"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.ImageTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.ImageTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.InputTagHelper","TagMatchingRules":[{"TagName":"input","Attributes":[{"Name":"asp-for","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-for","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"asp-for","IndexerNamePrefix":null,"TypeName":"Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression Microsoft.AspNetCore.Mvc.TagHelpers.InputTagHelper.For","Diagnostics":[],"Metadata":{"Common.PropertyName":"For"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-format","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.InputTagHelper.Format","Diagnostics":[],"Metadata":{"Common.PropertyName":"Format"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"type","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.InputTagHelper.InputTypeName","Diagnostics":[],"Metadata":{"Common.PropertyName":"InputTypeName"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"value","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.InputTagHelper.Value","Diagnostics":[],"Metadata":{"Common.PropertyName":"Value"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.InputTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.InputTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.LabelTagHelper","TagMatchingRules":[{"TagName":"label","Attributes":[{"Name":"asp-for","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-for","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"asp-for","IndexerNamePrefix":null,"TypeName":"Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression Microsoft.AspNetCore.Mvc.TagHelpers.LabelTagHelper.For","Diagnostics":[],"Metadata":{"Common.PropertyName":"For"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.LabelTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.LabelTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.LinkTagHelper","TagMatchingRules":[{"TagName":"link","Attributes":[{"Name":"asp-href-include","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-href-include","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"link","Attributes":[{"Name":"asp-href-exclude","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-href-exclude","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"link","Attributes":[{"Name":"asp-fallback-href","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-fallback-href","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"link","Attributes":[{"Name":"asp-fallback-href-include","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-fallback-href-include","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"link","Attributes":[{"Name":"asp-fallback-href-exclude","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-fallback-href-exclude","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"link","Attributes":[{"Name":"asp-fallback-test-class","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-fallback-test-class","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"link","Attributes":[{"Name":"asp-fallback-test-property","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-fallback-test-property","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"link","Attributes":[{"Name":"asp-fallback-test-value","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-fallback-test-value","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"link","Attributes":[{"Name":"asp-append-version","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-append-version","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"href","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.LinkTagHelper.Href","Diagnostics":[],"Metadata":{"Common.PropertyName":"Href"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-href-include","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.LinkTagHelper.HrefInclude","Diagnostics":[],"Metadata":{"Common.PropertyName":"HrefInclude"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-href-exclude","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.LinkTagHelper.HrefExclude","Diagnostics":[],"Metadata":{"Common.PropertyName":"HrefExclude"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-fallback-href","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.LinkTagHelper.FallbackHref","Diagnostics":[],"Metadata":{"Common.PropertyName":"FallbackHref"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"asp-append-version","IndexerNamePrefix":null,"TypeName":"System.Boolean?","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"System.Boolean? Microsoft.AspNetCore.Mvc.TagHelpers.LinkTagHelper.AppendVersion","Diagnostics":[],"Metadata":{"Common.PropertyName":"AppendVersion"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-fallback-href-include","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.LinkTagHelper.FallbackHrefInclude","Diagnostics":[],"Metadata":{"Common.PropertyName":"FallbackHrefInclude"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-fallback-href-exclude","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.LinkTagHelper.FallbackHrefExclude","Diagnostics":[],"Metadata":{"Common.PropertyName":"FallbackHrefExclude"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-fallback-test-class","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.LinkTagHelper.FallbackTestClass","Diagnostics":[],"Metadata":{"Common.PropertyName":"FallbackTestClass"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-fallback-test-property","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.LinkTagHelper.FallbackTestProperty","Diagnostics":[],"Metadata":{"Common.PropertyName":"FallbackTestProperty"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-fallback-test-value","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.LinkTagHelper.FallbackTestValue","Diagnostics":[],"Metadata":{"Common.PropertyName":"FallbackTestValue"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.LinkTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.LinkTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.OptionTagHelper","TagMatchingRules":[{"TagName":"option","Attributes":[],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"value","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.OptionTagHelper.Value","Diagnostics":[],"Metadata":{"Common.PropertyName":"Value"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.OptionTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.OptionTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.RenderAtEndOfFormTagHelper","TagMatchingRules":[{"TagName":"form","Attributes":[],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.RenderAtEndOfFormTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.RenderAtEndOfFormTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.ScriptTagHelper","TagMatchingRules":[{"TagName":"script","Attributes":[{"Name":"asp-src-include","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-src-include","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"script","Attributes":[{"Name":"asp-src-exclude","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-src-exclude","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"script","Attributes":[{"Name":"asp-fallback-src","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-fallback-src","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"script","Attributes":[{"Name":"asp-fallback-src-include","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-fallback-src-include","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"script","Attributes":[{"Name":"asp-fallback-src-exclude","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-fallback-src-exclude","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"script","Attributes":[{"Name":"asp-fallback-test","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-fallback-test","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"script","Attributes":[{"Name":"asp-append-version","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-append-version","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"src","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.ScriptTagHelper.Src","Diagnostics":[],"Metadata":{"Common.PropertyName":"Src"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-src-include","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.ScriptTagHelper.SrcInclude","Diagnostics":[],"Metadata":{"Common.PropertyName":"SrcInclude"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-src-exclude","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.ScriptTagHelper.SrcExclude","Diagnostics":[],"Metadata":{"Common.PropertyName":"SrcExclude"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-fallback-src","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.ScriptTagHelper.FallbackSrc","Diagnostics":[],"Metadata":{"Common.PropertyName":"FallbackSrc"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"asp-append-version","IndexerNamePrefix":null,"TypeName":"System.Boolean?","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"System.Boolean? Microsoft.AspNetCore.Mvc.TagHelpers.ScriptTagHelper.AppendVersion","Diagnostics":[],"Metadata":{"Common.PropertyName":"AppendVersion"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-fallback-src-include","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.ScriptTagHelper.FallbackSrcInclude","Diagnostics":[],"Metadata":{"Common.PropertyName":"FallbackSrcInclude"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-fallback-src-exclude","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.ScriptTagHelper.FallbackSrcExclude","Diagnostics":[],"Metadata":{"Common.PropertyName":"FallbackSrcExclude"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-fallback-test","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.ScriptTagHelper.FallbackTestExpression","Diagnostics":[],"Metadata":{"Common.PropertyName":"FallbackTestExpression"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.ScriptTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.ScriptTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.SelectTagHelper","TagMatchingRules":[{"TagName":"select","Attributes":[{"Name":"asp-for","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-for","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"select","Attributes":[{"Name":"asp-items","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-items","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"asp-for","IndexerNamePrefix":null,"TypeName":"Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression Microsoft.AspNetCore.Mvc.TagHelpers.SelectTagHelper.For","Diagnostics":[],"Metadata":{"Common.PropertyName":"For"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"asp-items","IndexerNamePrefix":null,"TypeName":"System.Collections.Generic.IEnumerable","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"System.Collections.Generic.IEnumerable Microsoft.AspNetCore.Mvc.TagHelpers.SelectTagHelper.Items","Diagnostics":[],"Metadata":{"Common.PropertyName":"Items"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.SelectTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.SelectTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.TextAreaTagHelper","TagMatchingRules":[{"TagName":"textarea","Attributes":[{"Name":"asp-for","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-for","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"asp-for","IndexerNamePrefix":null,"TypeName":"Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression Microsoft.AspNetCore.Mvc.TagHelpers.TextAreaTagHelper.For","Diagnostics":[],"Metadata":{"Common.PropertyName":"For"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.TextAreaTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.TextAreaTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.ValidationMessageTagHelper","TagMatchingRules":[{"TagName":"span","Attributes":[{"Name":"asp-validation-for","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-validation-for","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"asp-validation-for","IndexerNamePrefix":null,"TypeName":"Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression Microsoft.AspNetCore.Mvc.TagHelpers.ValidationMessageTagHelper.For","Diagnostics":[],"Metadata":{"Common.PropertyName":"For"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.ValidationMessageTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.ValidationMessageTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.ValidationSummaryTagHelper","TagMatchingRules":[{"TagName":"div","Attributes":[{"Name":"asp-validation-summary","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-validation-summary","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":true,"IsStringProperty":false,"Name":"asp-validation-summary","IndexerNamePrefix":null,"TypeName":"Microsoft.AspNetCore.Mvc.Rendering.ValidationSummary","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.Rendering.ValidationSummary Microsoft.AspNetCore.Mvc.TagHelpers.ValidationSummaryTagHelper.ValidationSummary","Diagnostics":[],"Metadata":{"Common.PropertyName":"ValidationSummary"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.ValidationSummaryTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.ValidationSummaryTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper","TagMatchingRules":[{"TagName":"body","Attributes":[],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.Razor","BoundAttributes":[],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper","TagMatchingRules":[{"TagName":"head","Attributes":[],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.Razor","BoundAttributes":[],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper","TagMatchingRules":[{"TagName":"*","Attributes":[{"Name":"itemid","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"itemid","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"a","Attributes":[{"Name":"href","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"href","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"applet","Attributes":[{"Name":"archive","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"archive","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"area","Attributes":[{"Name":"href","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"href","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"audio","Attributes":[{"Name":"src","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"src","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"base","Attributes":[{"Name":"href","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"href","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"blockquote","Attributes":[{"Name":"cite","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"cite","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"button","Attributes":[{"Name":"formaction","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"formaction","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"del","Attributes":[{"Name":"cite","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"cite","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"embed","Attributes":[{"Name":"src","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"src","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"form","Attributes":[{"Name":"action","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"action","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"html","Attributes":[{"Name":"manifest","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"manifest","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"iframe","Attributes":[{"Name":"src","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"src","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"img","Attributes":[{"Name":"src","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"src","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"img","Attributes":[{"Name":"srcset","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"srcset","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"src","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"src","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"formaction","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"formaction","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"ins","Attributes":[{"Name":"cite","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"cite","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"link","Attributes":[{"Name":"href","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"href","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"menuitem","Attributes":[{"Name":"icon","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"icon","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"object","Attributes":[{"Name":"archive","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"archive","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"object","Attributes":[{"Name":"data","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"data","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"q","Attributes":[{"Name":"cite","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"cite","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"script","Attributes":[{"Name":"src","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"src","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"source","Attributes":[{"Name":"src","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"src","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"source","Attributes":[{"Name":"srcset","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"srcset","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"track","Attributes":[{"Name":"src","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"src","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"video","Attributes":[{"Name":"src","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"src","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"video","Attributes":[{"Name":"poster","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"poster","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.Razor","BoundAttributes":[],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper"},"HasErrors":false}] \ No newline at end of file diff --git a/build/VSIX.targets b/build/VSIX.targets index 7cd27381f2..e5114e4b03 100644 --- a/build/VSIX.targets +++ b/build/VSIX.targets @@ -8,6 +8,7 @@ $(BuildDir)$(VSIXName).vsix $(BuildDir)$(VSIXName).json $(RepositoryRoot)tooling\$(VSIXName)\$(VSIXName).csproj + $(BuildDir)$(VSIXName).pdb shipoob @@ -27,6 +28,13 @@ $(VSIXName) + + SymbolsFile + $(VSIXArtifactCategory) + $(VSIXName).vsix + full + + VsixPackageManifestFile $(VSIXArtifactCategory) @@ -36,6 +44,7 @@ + @@ -93,6 +102,7 @@ /flp:LogFile=$(VSIXLogFilePath); /p:DeployExtension=false; /p:TargetVSIXContainer=$(VSIXOutputPath); + /p:SymbolsPublishDir=$(BuildDir); /p:Configuration=$(Configuration);" /> diff --git a/build/dependencies.props b/build/dependencies.props index 1fd2f19bc2..bd52ff645b 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,16 +1,17 @@ - + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 0.10.11 - 2.1.0-preview1-15651 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.3.1 - 2.3.1 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 + 2.1.0-preview2-15704 + 2.1.0-preview2-30077 + 2.1.0-preview2-30106 + 2.1.0-preview2-30106 + 2.4.0 + 2.4.0 + 2.1.0-preview2-30106 + 2.1.0-preview2-30106 2.1.0-preview2-25711-01 2.1.0-preview1-27965 2.1.0-preview1-27965 @@ -33,7 +34,7 @@ 7.10.6071 1.3.7 4.7.49 - 2.0.0 + 2.0.1 10.0.1 1.1.92 4.5.0-preview1-26016-05 @@ -52,5 +53,6 @@ 2.3.1 2.3.1 + diff --git a/build/repo.props b/build/repo.props index a3a5fbdbc0..091758faa3 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,12 +1,16 @@  + + true + + + - diff --git a/korebuild-lock.txt b/korebuild-lock.txt index d7ea9c33bf..02dc92cb26 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,7 +1,2 @@ -<<<<<<< HEAD -version:2.1.0-preview2-15696 -commithash:85ae1301d1a2ff19aab6837cc657699ccca719b5 -======= version:2.1.0-preview2-15704 commithash:21fdd9f5254226f407a2b4b3ef963693c2fd7998 ->>>>>>> Update KoreBuild diff --git a/shared/Microsoft.AspNetCore.Razor.TagHelpers.Testing.Sources/CaseSensitiveBoundAttributeComparer.cs b/shared/Microsoft.AspNetCore.Razor.TagHelpers.Testing.Sources/CaseSensitiveBoundAttributeComparer.cs index a385327fc8..4f7acca92b 100644 --- a/shared/Microsoft.AspNetCore.Razor.TagHelpers.Testing.Sources/CaseSensitiveBoundAttributeComparer.cs +++ b/shared/Microsoft.AspNetCore.Razor.TagHelpers.Testing.Sources/CaseSensitiveBoundAttributeComparer.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.IO; using Microsoft.AspNetCore.Html; -using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Razor.TagHelpers.Testing { @@ -35,11 +34,7 @@ namespace Microsoft.AspNetCore.Razor.TagHelpers.Testing public int GetHashCode(TagHelperAttribute attribute) { - var hashCodeCombiner = HashCodeCombiner.Start(); - hashCodeCombiner.Add(attribute.GetHashCode()); - hashCodeCombiner.Add(attribute.Name, StringComparer.Ordinal); - - return hashCodeCombiner.CombinedHash; + return attribute.GetHashCode(); } private string GetString(object value) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 25771e8046..83534ef969 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -8,7 +8,7 @@ - + diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/CSharpIdentifier.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/CSharpIdentifier.cs index dc3183ba1d..4e34345903 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/CSharpIdentifier.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/CSharpIdentifier.cs @@ -1,6 +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. +using System; using System.Globalization; using System.Text; @@ -8,6 +9,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X { internal static class CSharpIdentifier { + private const string CshtmlExtension = ".cshtml"; + public static string GetClassNameFromPath(string path) { if (string.IsNullOrEmpty(path)) @@ -15,6 +18,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X return path; } + if (path.EndsWith(CshtmlExtension, StringComparison.OrdinalIgnoreCase)) + { + path = path.Substring(0, path.Length - CshtmlExtension.Length); + } + return SanitizeClassName(path); } diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/InjectDirective.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/InjectDirective.cs index c5e84d3ede..c1c348f8a9 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/InjectDirective.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/InjectDirective.cs @@ -24,8 +24,13 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X builder.Description = Resources.InjectDirective_Description; }); - public static IRazorEngineBuilder Register(IRazorEngineBuilder builder) + public static RazorProjectEngineBuilder Register(RazorProjectEngineBuilder builder) { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + builder.AddDirective(Directive); builder.Features.Add(new Pass()); builder.AddTargetExtension(new InjectTargetExtension()); @@ -99,5 +104,20 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X } } } + + #region Obsolete + public static IRazorEngineBuilder Register(IRazorEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.AddDirective(Directive); + builder.Features.Add(new Pass()); + builder.AddTargetExtension(new InjectTargetExtension()); + return builder; + } + #endregion } } diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.csproj b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.csproj index 2935e1b9ca..c6b3d3e212 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.csproj +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.csproj @@ -13,10 +13,6 @@ - - - - diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/ModelDirective.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/ModelDirective.cs index 572d1b9ccb..0c5859ce22 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/ModelDirective.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/ModelDirective.cs @@ -21,10 +21,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X builder.Description = Resources.ModelDirective_Description; }); - public static IRazorEngineBuilder Register(IRazorEngineBuilder builder) + public static RazorProjectEngineBuilder Register(RazorProjectEngineBuilder builder) { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + builder.AddDirective(Directive); - builder.Features.Add(new Pass(builder.DesignTime)); + builder.Features.Add(new Pass()); return builder; } @@ -59,13 +64,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X internal class Pass : IntermediateNodePassBase, IRazorDirectiveClassifierPass { - private readonly bool _designTime; - - public Pass(bool designTime) - { - _designTime = designTime; - } - // Runs after the @inherits directive public override int Order => 5; @@ -74,7 +72,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X var visitor = new Visitor(); var modelType = GetModelType(documentNode, visitor); - if (_designTime) + if (documentNode.Options.DesignTime) { // Alias the TModel token to a known type. // This allows design time compilation to succeed for Razor files where the token isn't replaced. @@ -128,5 +126,19 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X } } } + + #region Obsolete + public static IRazorEngineBuilder Register(IRazorEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.AddDirective(Directive); + builder.Features.Add(new Pass()); + return builder; + } + #endregion } } diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/MvcImportProjectFeature.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/MvcImportProjectFeature.cs new file mode 100644 index 0000000000..254c57c1c4 --- /dev/null +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/MvcImportProjectFeature.cs @@ -0,0 +1,89 @@ +// 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.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using Microsoft.AspNetCore.Razor.Language; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X +{ + internal class MvcImportProjectFeature : RazorProjectEngineFeatureBase, IImportProjectFeature + { + private const string ImportsFileName = "_ViewImports.cshtml"; + + public IReadOnlyList GetImports(RazorProjectItem projectItem) + { + if (projectItem == null) + { + throw new ArgumentNullException(nameof(projectItem)); + } + + var imports = new List(); + AddDefaultDirectivesImport(imports); + + // We add hierarchical imports second so any default directive imports can be overridden. + AddHierarchicalImports(projectItem, imports); + + return imports; + } + + // Internal for testing + internal static void AddDefaultDirectivesImport(List imports) + { + imports.Add(DefaultDirectivesProjectItem.Instance); + } + + // Internal for testing + internal void AddHierarchicalImports(RazorProjectItem projectItem, List imports) + { + // We want items in descending order. FindHierarchicalItems returns items in ascending order. + var importProjectItems = ProjectEngine.FileSystem.FindHierarchicalItems(projectItem.FilePath, ImportsFileName).Reverse(); + imports.AddRange(importProjectItems); + } + + private class DefaultDirectivesProjectItem : RazorProjectItem + { + private readonly byte[] _defaultImportBytes; + + private DefaultDirectivesProjectItem() + { + var preamble = Encoding.UTF8.GetPreamble(); + var content = @" +@using System +@using System.Collections.Generic +@using System.Linq +@using System.Threading.Tasks +@using Microsoft.AspNetCore.Mvc +@using Microsoft.AspNetCore.Mvc.Rendering +@using Microsoft.AspNetCore.Mvc.ViewFeatures +@inject global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html +@inject global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json +@inject global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component +@inject global::Microsoft.AspNetCore.Mvc.IUrlHelper Url +@inject global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider +@addTagHelper Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor +"; + var contentBytes = Encoding.UTF8.GetBytes(content); + + _defaultImportBytes = new byte[preamble.Length + contentBytes.Length]; + preamble.CopyTo(_defaultImportBytes, 0); + contentBytes.CopyTo(_defaultImportBytes, preamble.Length); + } + + public override string BasePath => null; + + public override string FilePath => null; + + public override string PhysicalPath => null; + + public override bool Exists => true; + + public static DefaultDirectivesProjectItem Instance { get; } = new DefaultDirectivesProjectItem(); + + public override Stream Read() => new MemoryStream(_defaultImportBytes); + } + } +} diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/MvcRazorTemplateEngine.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/MvcRazorTemplateEngine.cs index 442eddddbc..497d173e4e 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/MvcRazorTemplateEngine.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/MvcRazorTemplateEngine.cs @@ -26,13 +26,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X Options.DefaultImports = GetDefaultImports(); } - /// public override RazorCodeDocument CreateCodeDocument(RazorProjectItem projectItem) { - var codeDocument = base.CreateCodeDocument(projectItem); - codeDocument.SetRelativePath(projectItem.FilePath); - - return codeDocument; + return base.CreateCodeDocument(projectItem); } // Internal for testing. diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/MvcViewDocumentClassifierPass.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/MvcViewDocumentClassifierPass.cs index 6fb18e2641..45cc3c1cb9 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/MvcViewDocumentClassifierPass.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/MvcViewDocumentClassifierPass.cs @@ -20,12 +20,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X ClassDeclarationIntermediateNode @class, MethodDeclarationIntermediateNode method) { - var filePath = codeDocument.GetRelativePath() ?? codeDocument.Source.FilePath; - base.OnDocumentStructureCreated(codeDocument, @namespace, @class, method); @namespace.Content = "AspNetCore"; + var filePath = codeDocument.Source.RelativePath ?? codeDocument.Source.FilePath; @class.ClassName = CSharpIdentifier.GetClassNameFromPath(filePath); @class.BaseType = "global::Microsoft.AspNetCore.Mvc.Razor.RazorPage"; @class.Modifiers.Clear(); diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/RazorCodeDocumentExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/RazorCodeDocumentExtensions.cs deleted file mode 100644 index 487ad3d2dc..0000000000 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/RazorCodeDocumentExtensions.cs +++ /dev/null @@ -1,34 +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; -using Microsoft.AspNetCore.Razor.Language; - -namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X -{ - internal static class RazorCodeDocumentExtensions - { - private const string RelativePathKey = "relative-path"; - - public static string GetRelativePath(this RazorCodeDocument document) - { - if (document == null) - { - throw new ArgumentNullException(nameof(document)); - } - - return document.Items[RelativePathKey] as string; - } - - - public static void SetRelativePath(this RazorCodeDocument document, string relativePath) - { - if (document == null) - { - throw new ArgumentNullException(nameof(document)); - } - - document.Items[RelativePathKey] = relativePath; - } - } -} diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/RazorExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/RazorExtensions.cs index 341bb5d47a..e8b4f0018c 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/RazorExtensions.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/RazorExtensions.cs @@ -9,8 +9,54 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X { public static class RazorExtensions { + public static void Register(RazorProjectEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + InjectDirective.Register(builder); + ModelDirective.Register(builder); + + FunctionsDirective.Register(builder); + InheritsDirective.Register(builder); + + // Register section directive with the 1.x compatible target extension. + builder.AddDirective(SectionDirective.Directive); + builder.Features.Add(new SectionDirectivePass()); + builder.AddTargetExtension(new LegacySectionTargetExtension()); + + builder.AddTargetExtension(new TemplateTargetExtension() + { + TemplateTypeName = "global::Microsoft.AspNetCore.Mvc.Razor.HelperResult", + }); + + builder.Features.Add(new ModelExpressionPass()); + builder.Features.Add(new MvcViewDocumentClassifierPass()); + + builder.SetImportFeature(new MvcImportProjectFeature()); + } + + public static void RegisterViewComponentTagHelpers(RazorProjectEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.Features.Add(new ViewComponentTagHelperPass()); + builder.AddTargetExtension(new ViewComponentTagHelperTargetExtension()); + } + + #region Obsolete public static void Register(IRazorEngineBuilder builder) { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + EnsureDesignTime(builder); InjectDirective.Register(builder); @@ -35,6 +81,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X public static void RegisterViewComponentTagHelpers(IRazorEngineBuilder builder) { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + EnsureDesignTime(builder); builder.Features.Add(new ViewComponentTagHelperPass()); @@ -50,5 +101,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X throw new NotSupportedException(Resources.RuntimeCodeGenerationNotSupported); } + #endregion } } diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/RazorExtensionsDiagnosticFactory.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/RazorExtensionsDiagnosticFactory.cs index 578de74478..af883af3d4 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/RazorExtensionsDiagnosticFactory.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/RazorExtensionsDiagnosticFactory.cs @@ -11,7 +11,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X { private const string DiagnosticPrefix = "RZ"; - public static readonly RazorDiagnosticDescriptor ViewComponent_CannotFindMethod = + internal static readonly RazorDiagnosticDescriptor ViewComponent_CannotFindMethod = new RazorDiagnosticDescriptor( $"{DiagnosticPrefix}3900", () => ViewComponentResources.ViewComponent_CannotFindMethod, @@ -29,7 +29,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X return diagnostic; } - public static readonly RazorDiagnosticDescriptor ViewComponent_AmbiguousMethods = + internal static readonly RazorDiagnosticDescriptor ViewComponent_AmbiguousMethods = new RazorDiagnosticDescriptor( $"{DiagnosticPrefix}3901", () => ViewComponentResources.ViewComponent_AmbiguousMethods, @@ -47,7 +47,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X return diagnostic; } - public static readonly RazorDiagnosticDescriptor ViewComponent_AsyncMethod_ShouldReturnTask = + internal static readonly RazorDiagnosticDescriptor ViewComponent_AsyncMethod_ShouldReturnTask = new RazorDiagnosticDescriptor( $"{DiagnosticPrefix}3902", () => ViewComponentResources.ViewComponent_AsyncMethod_ShouldReturnTask, @@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X return diagnostic; } - public static readonly RazorDiagnosticDescriptor ViewComponent_SyncMethod_ShouldReturnValue = + internal static readonly RazorDiagnosticDescriptor ViewComponent_SyncMethod_ShouldReturnValue = new RazorDiagnosticDescriptor( $"{DiagnosticPrefix}3903", () => ViewComponentResources.ViewComponent_SyncMethod_ShouldReturnValue, @@ -82,7 +82,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X return diagnostic; } - public static readonly RazorDiagnosticDescriptor ViewComponent_SyncMethod_CannotReturnTask = + internal static readonly RazorDiagnosticDescriptor ViewComponent_SyncMethod_CannotReturnTask = new RazorDiagnosticDescriptor( $"{DiagnosticPrefix}3904", () => ViewComponentResources.ViewComponent_SyncMethod_CannotReturnTask, diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/AssemblyAttributeInjectionPass.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/AssemblyAttributeInjectionPass.cs index ef02120f02..cf5549d0f5 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/AssemblyAttributeInjectionPass.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/AssemblyAttributeInjectionPass.cs @@ -14,6 +14,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) { + if (documentNode.Options.DesignTime) + { + return; + } + var @namespace = documentNode.FindPrimaryNamespace(); if (@namespace == null || string.IsNullOrEmpty(@namespace.Content)) { @@ -29,8 +34,13 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions } var generatedTypeName = $"{@namespace.Content}.{@class.ClassName}"; - var path = codeDocument.GetRelativePath(); - var escapedPath = EscapeAsVerbatimLiteral(path); + + // The MVC attributes require a relative path to be specified so that we can make a view engine path. + // We can't use a rooted path because we don't know what the project root is. + // + // If we can't sanitize the path, we'll just set it to null and let is blow up at runtime - we don't + // want to create noise if this code has to run in some unanticipated scenario. + var escapedPath = MakeVerbatimStringLiteral(ConvertToViewEnginePath(codeDocument.Source.RelativePath)); string attribute; if (documentNode.DocumentKind == MvcViewDocumentClassifierPass.MvcViewDocumentKind) @@ -40,7 +50,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions else if (documentNode.DocumentKind == RazorPageDocumentClassifierPass.RazorPageDocumentKind && PageDirective.TryGetPageDirective(documentNode, out var pageDirective)) { - var escapedRoutePrefix = EscapeAsVerbatimLiteral(pageDirective.RouteTemplate); + var escapedRoutePrefix = MakeVerbatimStringLiteral(pageDirective.RouteTemplate); attribute = $"[assembly:{RazorPageAttribute}({escapedPath}, typeof({generatedTypeName}), {escapedRoutePrefix})]"; } else @@ -61,7 +71,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions documentNode.Children.Insert(index, pageAttribute); } - private static string EscapeAsVerbatimLiteral(string value) + private static string MakeVerbatimStringLiteral(string value) { if (value == null) { @@ -71,5 +81,22 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions value = value.Replace("\"", "\"\""); return $"@\"{value}\""; } + + private static string ConvertToViewEnginePath(string relativePath) + { + if (string.IsNullOrEmpty(relativePath)) + { + return null; + } + + // Checking for both / and \ because a \ will become a /. + if (!relativePath.StartsWith("/") && !relativePath.StartsWith("\\")) + { + relativePath = "/" + relativePath; + } + + relativePath = relativePath.Replace('\\', '/'); + return relativePath; + } } } diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/CSharpIdentifier.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/CSharpIdentifier.cs index cd2661a70c..e1ca2e343e 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/CSharpIdentifier.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/CSharpIdentifier.cs @@ -1,6 +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. +using System; using System.Globalization; using System.Text; @@ -8,6 +9,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions { internal static class CSharpIdentifier { + private const string CshtmlExtension = ".cshtml"; + public static string GetClassNameFromPath(string path) { if (string.IsNullOrEmpty(path)) @@ -15,6 +18,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions return path; } + if (path.EndsWith(CshtmlExtension, StringComparison.OrdinalIgnoreCase)) + { + path = path.Substring(0, path.Length - CshtmlExtension.Length); + } + return SanitizeClassName(path); } diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ExtensionInitializer.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ExtensionInitializer.cs new file mode 100644 index 0000000000..eeb3246f74 --- /dev/null +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ExtensionInitializer.cs @@ -0,0 +1,15 @@ +// 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; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions +{ + internal class ExtensionInitializer : RazorExtensionInitializer + { + public override void Initialize(RazorProjectEngineBuilder builder) + { + RazorExtensions.Register(builder); + } + } +} diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InjectDirective.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InjectDirective.cs index 81f1d5b834..41bb56b57d 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InjectDirective.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InjectDirective.cs @@ -24,8 +24,13 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions builder.Description = Resources.InjectDirective_Description; }); - public static IRazorEngineBuilder Register(IRazorEngineBuilder builder) + public static RazorProjectEngineBuilder Register(RazorProjectEngineBuilder builder) { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + builder.AddDirective(Directive); builder.Features.Add(new Pass()); builder.AddTargetExtension(new InjectTargetExtension()); @@ -99,5 +104,20 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions } } } + + #region Obsolete + public static IRazorEngineBuilder Register(IRazorEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.AddDirective(Directive); + builder.Features.Add(new Pass()); + builder.AddTargetExtension(new InjectTargetExtension()); + return builder; + } + #endregion } } diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InstrumentationPass.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InstrumentationPass.cs index 9f271faf82..1ae0a72210 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InstrumentationPass.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InstrumentationPass.cs @@ -15,6 +15,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) { + if (documentNode.Options.DesignTime) + { + return; + } + var walker = new Visitor(); walker.VisitDocument(documentNode); diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/Microsoft.AspNetCore.Mvc.Razor.Extensions.csproj b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/Microsoft.AspNetCore.Mvc.Razor.Extensions.csproj index 497df54e0f..401d07c030 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/Microsoft.AspNetCore.Mvc.Razor.Extensions.csproj +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/Microsoft.AspNetCore.Mvc.Razor.Extensions.csproj @@ -13,7 +13,8 @@ - + + diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ModelDirective.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ModelDirective.cs index 17d98d72b4..b6e2955f22 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ModelDirective.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ModelDirective.cs @@ -21,10 +21,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions builder.Description = Resources.ModelDirective_Description; }); - public static IRazorEngineBuilder Register(IRazorEngineBuilder builder) + public static RazorProjectEngineBuilder Register(RazorProjectEngineBuilder builder) { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + builder.AddDirective(Directive); - builder.Features.Add(new Pass(builder.DesignTime)); + builder.Features.Add(new Pass()); return builder; } @@ -66,13 +71,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions internal class Pass : IntermediateNodePassBase, IRazorDirectiveClassifierPass { - private readonly bool _designTime; - - public Pass(bool designTime) - { - _designTime = designTime; - } - // Runs after the @inherits directive public override int Order => 5; @@ -81,7 +79,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions var visitor = new Visitor(); var modelType = GetModelType(documentNode, visitor); - if (_designTime) + if (documentNode.Options.DesignTime) { // Alias the TModel token to a known type. // This allows design time compilation to succeed for Razor files where the token isn't replaced. @@ -135,5 +133,19 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions } } } + + #region Obsolete + public static IRazorEngineBuilder Register(IRazorEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.AddDirective(Directive); + builder.Features.Add(new Pass()); + return builder; + } + #endregion } } diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcImportProjectFeature.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcImportProjectFeature.cs new file mode 100644 index 0000000000..5c6ee7361d --- /dev/null +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcImportProjectFeature.cs @@ -0,0 +1,91 @@ +// 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.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using Microsoft.AspNetCore.Razor.Language; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions +{ + internal class MvcImportProjectFeature : RazorProjectEngineFeatureBase, IImportProjectFeature + { + private const string ImportsFileName = "_ViewImports.cshtml"; + + public IReadOnlyList GetImports(RazorProjectItem projectItem) + { + if (projectItem == null) + { + throw new ArgumentNullException(nameof(projectItem)); + } + + var imports = new List(); + AddDefaultDirectivesImport(imports); + + // We add hierarchical imports second so any default directive imports can be overridden. + AddHierarchicalImports(projectItem, imports); + + return imports; + } + + // Internal for testing + internal static void AddDefaultDirectivesImport(List imports) + { + imports.Add(DefaultDirectivesProjectItem.Instance); + } + + // Internal for testing + internal void AddHierarchicalImports(RazorProjectItem projectItem, List imports) + { + // We want items in descending order. FindHierarchicalItems returns items in ascending order. + var importProjectItems = ProjectEngine.FileSystem.FindHierarchicalItems(projectItem.FilePath, ImportsFileName).Reverse(); + imports.AddRange(importProjectItems); + } + + private class DefaultDirectivesProjectItem : RazorProjectItem + { + private readonly byte[] _defaultImportBytes; + + private DefaultDirectivesProjectItem() + { + var preamble = Encoding.UTF8.GetPreamble(); + var content = @" +@using System +@using System.Collections.Generic +@using System.Linq +@using System.Threading.Tasks +@using Microsoft.AspNetCore.Mvc +@using Microsoft.AspNetCore.Mvc.Rendering +@using Microsoft.AspNetCore.Mvc.ViewFeatures +@inject global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html +@inject global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json +@inject global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component +@inject global::Microsoft.AspNetCore.Mvc.IUrlHelper Url +@inject global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider +@addTagHelper Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor +@addTagHelper Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor +@addTagHelper Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor +"; + var contentBytes = Encoding.UTF8.GetBytes(content); + + _defaultImportBytes = new byte[preamble.Length + contentBytes.Length]; + preamble.CopyTo(_defaultImportBytes, 0); + contentBytes.CopyTo(_defaultImportBytes, preamble.Length); + } + + public override string BasePath => null; + + public override string FilePath => null; + + public override string PhysicalPath => null; + + public override bool Exists => true; + + public static DefaultDirectivesProjectItem Instance { get; } = new DefaultDirectivesProjectItem(); + + public override Stream Read() => new MemoryStream(_defaultImportBytes); + } + } +} diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcRazorTemplateEngine.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcRazorTemplateEngine.cs index c30ad4a037..f278b20a45 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcRazorTemplateEngine.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcRazorTemplateEngine.cs @@ -26,13 +26,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions Options.DefaultImports = GetDefaultImports(); } - /// public override RazorCodeDocument CreateCodeDocument(RazorProjectItem projectItem) { - var codeDocument = base.CreateCodeDocument(projectItem); - codeDocument.SetRelativePath(projectItem.FilePath); - - return codeDocument; + return base.CreateCodeDocument(projectItem); } // Internal for testing. diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcViewDocumentClassifierPass.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcViewDocumentClassifierPass.cs index ac524144d1..2378f23591 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcViewDocumentClassifierPass.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcViewDocumentClassifierPass.cs @@ -20,12 +20,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions ClassDeclarationIntermediateNode @class, MethodDeclarationIntermediateNode method) { - var filePath = codeDocument.GetRelativePath() ?? codeDocument.Source.FilePath; - base.OnDocumentStructureCreated(codeDocument, @namespace, @class, method); @namespace.Content = "AspNetCore"; + var filePath = codeDocument.Source.RelativePath ?? codeDocument.Source.FilePath; @class.ClassName = CSharpIdentifier.GetClassNameFromPath(filePath); @class.BaseType = "global::Microsoft.AspNetCore.Mvc.Razor.RazorPage"; @class.Modifiers.Clear(); diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/NamespaceDirective.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/NamespaceDirective.cs index b235f2eabb..b0c197f42b 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/NamespaceDirective.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/NamespaceDirective.cs @@ -26,7 +26,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions builder.Description = Resources.NamespaceDirective_Description; }); - public static void Register(IRazorEngineBuilder builder) + public static void Register(RazorProjectEngineBuilder builder) { if (builder == null) { @@ -66,22 +66,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions return; } - if (TryComputeNamespace(codeDocument.Source.FilePath, directive, out var computedNamespace)) - { - // Beautify the class name since we're using a hierarchy for namespaces. - var @class = visitor.FirstClass; - var prefix = CSharpIdentifier.SanitizeClassName(Path.GetFileNameWithoutExtension(codeDocument.Source.FilePath)); - if (@class != null && documentNode.DocumentKind == RazorPageDocumentClassifierPass.RazorPageDocumentKind) - { - @class.ClassName = prefix + "_Page"; - } - else if (@class != null && documentNode.DocumentKind == MvcViewDocumentClassifierPass.MvcViewDocumentKind) - { - @class.ClassName = prefix + "_View"; - } - } - - @namespace.Content = computedNamespace; + @namespace.Content = GetNamespace(codeDocument.Source.FilePath, directive); } } @@ -92,7 +77,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions // // In the event that these two source either don't have FileNames set or don't follow a coherent hierarchy, // we will just use the namespace verbatim. - internal static bool TryComputeNamespace(string source, DirectiveIntermediateNode directive, out string @namespace) + internal static string GetNamespace(string source, DirectiveIntermediateNode directive) { var directiveSource = NormalizeDirectory(directive.Source?.FilePath); @@ -100,15 +85,13 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions if (string.IsNullOrEmpty(baseNamespace)) { // The namespace directive was incomplete. - @namespace = string.Empty; - return false; + return string.Empty; } if (string.IsNullOrEmpty(source) || directiveSource == null) { // No sources, can't compute a suffix. - @namespace = baseNamespace; - return false; + return baseNamespace; } // We're specifically using OrdinalIgnoreCase here because Razor treats all paths as case-insensitive. @@ -116,8 +99,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions source.Length <= directiveSource.Length) { // The imports are not from the directory hierarchy, can't compute a suffix. - @namespace = baseNamespace; - return false; + return baseNamespace; } // OK so that this point we know that the 'imports' file containing this directive is in the directory @@ -136,8 +118,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions builder.Append(CSharpIdentifier.SanitizeClassName(segments[i])); } - @namespace = builder.ToString(); - return true; + return builder.ToString(); } // We want to normalize the path of the file containing the '@namespace' directive to just the containing @@ -205,5 +186,18 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions base.VisitDirective(node); } } + + #region Obsolete + public static void Register(IRazorEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(); + } + + builder.AddDirective(Directive); + builder.Features.Add(new Pass()); + } + #endregion } } diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/PageDirective.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/PageDirective.cs index 5f617a1ebd..cd3624f435 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/PageDirective.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/PageDirective.cs @@ -32,8 +32,13 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public IntermediateNode DirectiveNode { get; } - public static IRazorEngineBuilder Register(IRazorEngineBuilder builder) + public static RazorProjectEngineBuilder Register(RazorProjectEngineBuilder builder) { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + builder.AddDirective(Directive); return builder; } @@ -98,5 +103,18 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions } } } + + #region Obsolete + public static IRazorEngineBuilder Register(IRazorEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.AddDirective(Directive); + return builder; + } + #endregion } } diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/Properties/AssemblyInfo.cs index 6a4431ff38..b5caca17dd 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/Properties/AssemblyInfo.cs @@ -2,5 +2,11 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Runtime.CompilerServices; +using Microsoft.AspNetCore.Mvc.Razor.Extensions; +using Microsoft.AspNetCore.Razor.Language; + +[assembly: ProvideRazorExtensionInitializer("MVC-2.0", typeof(ExtensionInitializer))] +[assembly: ProvideRazorExtensionInitializer("MVC-2.1", typeof(ExtensionInitializer))] [assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.Razor.Extensions.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Editor.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorCodeDocumentExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorCodeDocumentExtensions.cs deleted file mode 100644 index 2e6c220bcc..0000000000 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorCodeDocumentExtensions.cs +++ /dev/null @@ -1,34 +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; -using Microsoft.AspNetCore.Razor.Language; - -namespace Microsoft.AspNetCore.Mvc.Razor.Extensions -{ - internal static class RazorCodeDocumentExtensions - { - private const string RelativePathKey = "relative-path"; - - public static string GetRelativePath(this RazorCodeDocument document) - { - if (document == null) - { - throw new ArgumentNullException(nameof(document)); - } - - return document.Items[RelativePathKey] as string; - } - - - public static void SetRelativePath(this RazorCodeDocument document, string relativePath) - { - if (document == null) - { - throw new ArgumentNullException(nameof(document)); - } - - document.Items[RelativePathKey] = relativePath; - } - } -} diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorExtensions.cs index fc1ad0c162..abf1b447f0 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorExtensions.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorExtensions.cs @@ -1,6 +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. +using System; using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Extensions; @@ -8,8 +9,49 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions { public static class RazorExtensions { + public static void Register(RazorProjectEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + InjectDirective.Register(builder); + ModelDirective.Register(builder); + NamespaceDirective.Register(builder); + PageDirective.Register(builder); + + FunctionsDirective.Register(builder); + InheritsDirective.Register(builder); + SectionDirective.Register(builder); + + builder.Features.Add(new ViewComponentTagHelperDescriptorProvider()); + + builder.AddTargetExtension(new ViewComponentTagHelperTargetExtension()); + builder.AddTargetExtension(new TemplateTargetExtension() + { + TemplateTypeName = "global::Microsoft.AspNetCore.Mvc.Razor.HelperResult", + }); + + builder.Features.Add(new ModelExpressionPass()); + builder.Features.Add(new PagesPropertyInjectionPass()); + builder.Features.Add(new ViewComponentTagHelperPass()); + builder.Features.Add(new RazorPageDocumentClassifierPass()); + builder.Features.Add(new MvcViewDocumentClassifierPass()); + builder.Features.Add(new AssemblyAttributeInjectionPass()); + builder.Features.Add(new InstrumentationPass()); + + builder.SetImportFeature(new MvcImportProjectFeature()); + } + + #region Obsolete public static void Register(IRazorEngineBuilder builder) { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + InjectDirective.Register(builder); ModelDirective.Register(builder); NamespaceDirective.Register(builder); @@ -37,5 +79,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions builder.Features.Add(new InstrumentationPass()); } } + #endregion } } diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorExtensionsDiagnosticFactory.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorExtensionsDiagnosticFactory.cs index 565d4caa0b..1e2f6a1f7e 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorExtensionsDiagnosticFactory.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorExtensionsDiagnosticFactory.cs @@ -11,7 +11,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions { private const string DiagnosticPrefix = "RZ"; - public static readonly RazorDiagnosticDescriptor ViewComponent_CannotFindMethod = + internal static readonly RazorDiagnosticDescriptor ViewComponent_CannotFindMethod = new RazorDiagnosticDescriptor( $"{DiagnosticPrefix}3900", () => ViewComponentResources.ViewComponent_CannotFindMethod, @@ -29,7 +29,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions return diagnostic; } - public static readonly RazorDiagnosticDescriptor ViewComponent_AmbiguousMethods = + internal static readonly RazorDiagnosticDescriptor ViewComponent_AmbiguousMethods = new RazorDiagnosticDescriptor( $"{DiagnosticPrefix}3901", () => ViewComponentResources.ViewComponent_AmbiguousMethods, @@ -47,7 +47,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions return diagnostic; } - public static readonly RazorDiagnosticDescriptor ViewComponent_AsyncMethod_ShouldReturnTask = + internal static readonly RazorDiagnosticDescriptor ViewComponent_AsyncMethod_ShouldReturnTask = new RazorDiagnosticDescriptor( $"{DiagnosticPrefix}3902", () => ViewComponentResources.ViewComponent_AsyncMethod_ShouldReturnTask, @@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions return diagnostic; } - public static readonly RazorDiagnosticDescriptor ViewComponent_SyncMethod_ShouldReturnValue = + internal static readonly RazorDiagnosticDescriptor ViewComponent_SyncMethod_ShouldReturnValue = new RazorDiagnosticDescriptor( $"{DiagnosticPrefix}3903", () => ViewComponentResources.ViewComponent_SyncMethod_ShouldReturnValue, @@ -82,7 +82,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions return diagnostic; } - public static readonly RazorDiagnosticDescriptor ViewComponent_SyncMethod_CannotReturnTask = + internal static readonly RazorDiagnosticDescriptor ViewComponent_SyncMethod_CannotReturnTask = new RazorDiagnosticDescriptor( $"{DiagnosticPrefix}3904", () => ViewComponentResources.ViewComponent_SyncMethod_CannotReturnTask, @@ -100,7 +100,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions return diagnostic; } - public static readonly RazorDiagnosticDescriptor PageDirective_CannotBeImported = + internal static readonly RazorDiagnosticDescriptor PageDirective_CannotBeImported = new RazorDiagnosticDescriptor( $"{DiagnosticPrefix}3905", () => Resources.PageDirectiveCannotBeImported, diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorPageDocumentClassifierPass.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorPageDocumentClassifierPass.cs index c69cd9ac16..a4959dded2 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorPageDocumentClassifierPass.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorPageDocumentClassifierPass.cs @@ -24,13 +24,13 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions ClassDeclarationIntermediateNode @class, MethodDeclarationIntermediateNode method) { - var filePath = codeDocument.GetRelativePath() ?? codeDocument.Source.FilePath; - base.OnDocumentStructureCreated(codeDocument, @namespace, @class, method); @namespace.Content = "AspNetCore"; @class.BaseType = "global::Microsoft.AspNetCore.Mvc.RazorPages.Page"; + + var filePath = codeDocument.Source.RelativePath ?? codeDocument.Source.FilePath; @class.ClassName = CSharpIdentifier.GetClassNameFromPath(filePath); @class.Modifiers.Clear(); diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.props b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.props new file mode 100644 index 0000000000..ef8766cdf2 --- /dev/null +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.props @@ -0,0 +1,35 @@ + + + + + MVC-2.1 + + + <_MvcExtensionAssemblyPath Condition="'$(_MvcExtensionAssemblyPath)'==''">$(MSBuildThisFileDirectory)..\..\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.Extensions.dll + + + + + + MVC-2.1;$(CustomRazorExtension) + + + + + + Microsoft.AspNetCore.Mvc.Razor.Extensions + $(_MvcExtensionAssemblyPath) + + + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.targets b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.targets new file mode 100644 index 0000000000..61a0e7a8dc --- /dev/null +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.targets @@ -0,0 +1,9 @@ + + + + + true + + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Language/AllowedChildTagDescriptor.cs b/src/Microsoft.AspNetCore.Razor.Language/AllowedChildTagDescriptor.cs index 14ea34c493..84a83b3e8c 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/AllowedChildTagDescriptor.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/AllowedChildTagDescriptor.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; namespace Microsoft.AspNetCore.Razor.Language diff --git a/src/Microsoft.AspNetCore.Razor.Language/AssemblyExtension.cs b/src/Microsoft.AspNetCore.Razor.Language/AssemblyExtension.cs new file mode 100644 index 0000000000..b93323e018 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/AssemblyExtension.cs @@ -0,0 +1,31 @@ +// 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.Reflection; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal class AssemblyExtension : RazorExtension + { + public AssemblyExtension(string extensionName, Assembly assembly) + { + if (extensionName == null) + { + throw new ArgumentNullException(nameof(extensionName)); + } + + if (assembly == null) + { + throw new ArgumentNullException(nameof(assembly)); + } + + ExtensionName = extensionName; + Assembly = assembly; + } + + public override string ExtensionName { get; } + + public Assembly Assembly { get; } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/Checksum.cs b/src/Microsoft.AspNetCore.Razor.Language/Checksum.cs new file mode 100644 index 0000000000..57834739e6 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/Checksum.cs @@ -0,0 +1,28 @@ +// 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.Text; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal static class Checksum + { + public static string BytesToString(byte[] bytes) + { + if (bytes == null) + { + throw new ArgumentNullException(nameof(bytes)); + } + + var result = new StringBuilder(bytes.Length); + for (var i = 0; i < bytes.Length; i++) + { + // The x2 format means lowercase hex, where each byte is a 2-character string. + result.Append(bytes[i].ToString("x2")); + } + + return result.ToString(); + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DefaultDocumentWriter.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DefaultDocumentWriter.cs index 1469ec377c..772c5a0fab 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DefaultDocumentWriter.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DefaultDocumentWriter.cs @@ -3,6 +3,7 @@ using System; using System.Linq; +using System.Security.Cryptography; using System.Text; using Microsoft.AspNetCore.Razor.Language.Intermediate; @@ -67,28 +68,52 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration if (!Context.Options.SuppressChecksum) { // See http://msdn.microsoft.com/en-us/library/system.codedom.codechecksumpragma.checksumalgorithmid.aspx - const string Sha1AlgorithmId = "{ff1816ec-aa5e-4d10-87f7-6f4963833460}"; + // And https://github.com/dotnet/roslyn/blob/614299ff83da9959fa07131c6d0ffbc58873b6ae/src/Compilers/Core/Portable/PEWriter/DebugSourceDocument.cs#L67 + // + // We only support algorithms that the debugger understands, which is currently SHA1 and SHA256. + + string algorithmId; + var algorithm = Context.SourceDocument.GetChecksumAlgorithm(); + if (string.Equals(algorithm, HashAlgorithmName.SHA256.Name, StringComparison.Ordinal)) + { + algorithmId = "{8829d00f-11b8-4213-878b-770e8597ac16}"; + } + else if (string.Equals(algorithm, HashAlgorithmName.SHA1.Name, StringComparison.Ordinal) || + + // In 2.0, we didn't actually expose the name of the algorithm, so it's possible we could get null here. + // If that's the case, we just assume SHA1 since that's the only thing we supported in 2.0. + algorithm == null) + { + algorithmId = "{ff1816ec-aa5e-4d10-87f7-6f4963833460}"; + } + else + { + var supportedAlgorithms = string.Join(" ", new string[] + { + HashAlgorithmName.SHA1.Name, + HashAlgorithmName.SHA256.Name + }); + + var message = Resources.FormatUnsupportedChecksumAlgorithm( + algorithm, + supportedAlgorithms, + nameof(RazorCodeGenerationOptions) + "." + nameof(RazorCodeGenerationOptions.SuppressChecksum), + bool.TrueString); + throw new InvalidOperationException(message); + } var sourceDocument = Context.SourceDocument; - var checksum = sourceDocument.GetChecksum(); - var fileHashBuilder = new StringBuilder(checksum.Length * 2); - foreach (var value in checksum) - { - fileHashBuilder.Append(value.ToString("x2")); - } - - var bytes = fileHashBuilder.ToString(); - - if (!string.IsNullOrEmpty(bytes)) + var checksum = Checksum.BytesToString(sourceDocument.GetChecksum()); + if (!string.IsNullOrEmpty(checksum)) { Context.CodeWriter .Write("#pragma checksum \"") .Write(sourceDocument.FilePath) .Write("\" \"") - .Write(Sha1AlgorithmId) + .Write(algorithmId) .Write("\" \"") - .Write(bytes) + .Write(checksum) .WriteLine("\""); } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultDirectiveSyntaxTreePass.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultDirectiveSyntaxTreePass.cs index d41b998ca9..54c733e0f1 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultDirectiveSyntaxTreePass.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultDirectiveSyntaxTreePass.cs @@ -45,11 +45,7 @@ namespace Microsoft.AspNetCore.Razor.Language { var directiveStart = block.Children.First(child => !child.IsBlock && ((Span)child).Kind == SpanKindInternal.Transition).Start; var errorLength = /* @ */ 1 + SectionDirective.Directive.Directive.Length; - var error = RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Sections_Cannot_Be_Nested(LegacyResources.SectionExample_CS), - directiveStart, - errorLength)); + var error = RazorDiagnosticFactory.CreateParsing_SectionsCannotBeNested(new SourceSpan(directiveStart, errorLength)); chunkGenerator.Diagnostics.Add(error); } diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultImportProjectFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultImportProjectFeature.cs new file mode 100644 index 0000000000..92778322d7 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultImportProjectFeature.cs @@ -0,0 +1,13 @@ +// 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.Collections.Generic; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal class DefaultImportProjectFeature : RazorProjectEngineFeatureBase, IImportProjectFeature + { + public IReadOnlyList GetImports(RazorProjectItem projectItem) => Array.Empty(); + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptions.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptions.cs index c7a9fcf673..e521141628 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptions.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptions.cs @@ -5,12 +5,18 @@ namespace Microsoft.AspNetCore.Razor.Language { internal class DefaultRazorCodeGenerationOptions : RazorCodeGenerationOptions { - public DefaultRazorCodeGenerationOptions(bool indentWithTabs, int indentSize, bool designTime, bool suppressChecksum) + public DefaultRazorCodeGenerationOptions( + bool indentWithTabs, + int indentSize, + bool designTime, + bool suppressChecksum, + bool supressMetadataAttributes) { IndentWithTabs = indentWithTabs; IndentSize = indentSize; DesignTime = designTime; SuppressChecksum = suppressChecksum; + SuppressMetadataAttributes = supressMetadataAttributes; } public override bool DesignTime { get; } diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsBuilder.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsBuilder.cs index 79acdf8d44..8dd095a04e 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsBuilder.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsBuilder.cs @@ -1,26 +1,45 @@ // 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; + namespace Microsoft.AspNetCore.Razor.Language { internal class DefaultRazorCodeGenerationOptionsBuilder : RazorCodeGenerationOptionsBuilder { - public DefaultRazorCodeGenerationOptionsBuilder(bool designTime) + private bool _designTime; + + public DefaultRazorCodeGenerationOptionsBuilder(RazorConfiguration configuration) { - DesignTime = designTime; + if (configuration == null) + { + throw new ArgumentNullException(nameof(configuration)); + } } - public override bool DesignTime { get; } + public DefaultRazorCodeGenerationOptionsBuilder(bool designTime) + { + _designTime = designTime; + } + + public override RazorConfiguration Configuration { get; } + + public override bool DesignTime => _designTime; public override int IndentSize { get; set; } = 4; public override bool IndentWithTabs { get; set; } public override bool SuppressChecksum { get; set; } - + public override RazorCodeGenerationOptions Build() { - return new DefaultRazorCodeGenerationOptions(IndentWithTabs, IndentSize, DesignTime, SuppressChecksum); + return new DefaultRazorCodeGenerationOptions(IndentWithTabs, IndentSize, DesignTime, SuppressChecksum, SuppressMetadataAttributes); + } + + public override void SetDesignTime(bool designTime) + { + _designTime = designTime; } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsFactoryProjectFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsFactoryProjectFeature.cs new file mode 100644 index 0000000000..db2a25b81f --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsFactoryProjectFeature.cs @@ -0,0 +1,32 @@ +// 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.Linq; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal class DefaultRazorCodeGenerationOptionsFactoryProjectFeature : RazorProjectEngineFeatureBase, IRazorCodeGenerationOptionsFactoryProjectFeature + { + private IConfigureRazorCodeGenerationOptionsFeature[] _configureOptions; + + protected override void OnInitialized() + { + _configureOptions = ProjectEngine.EngineFeatures.OfType().ToArray(); + } + + public RazorCodeGenerationOptions Create(Action configure) + { + var builder = new DefaultRazorCodeGenerationOptionsBuilder(ProjectEngine.Configuration); + configure?.Invoke(builder); + + for (var i = 0; i < _configureOptions.Length; i++) + { + _configureOptions[i].Configure(builder); + } + + var options = builder.Build(); + return options; + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsFeature.cs index 70ca502788..1c915364d7 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsFeature.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsFeature.cs @@ -5,7 +5,9 @@ using System.Linq; namespace Microsoft.AspNetCore.Razor.Language { +#pragma warning disable CS0618 // Type or member is obsolete internal class DefaultRazorCodeGenerationOptionsFeature : RazorEngineFeatureBase, IRazorCodeGenerationOptionsFeature +#pragma warning restore CS0618 // Type or member is obsolete { private readonly bool _designTime; private IConfigureRazorCodeGenerationOptionsFeature[] _configureOptions; @@ -22,15 +24,15 @@ namespace Microsoft.AspNetCore.Razor.Language public RazorCodeGenerationOptions GetOptions() { - var builder = new DefaultRazorCodeGenerationOptionsBuilder(_designTime); + return _designTime ? RazorCodeGenerationOptions.CreateDesignTime(ConfigureOptions) : RazorCodeGenerationOptions.Create(ConfigureOptions); + } + + private void ConfigureOptions(RazorCodeGenerationOptionsBuilder builder) + { for (var i = 0; i < _configureOptions.Length; i++) { _configureOptions[i].Configure(builder); } - - var options = builder.Build(); - - return options; } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorDiagnostic.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorDiagnostic.cs index a8bc704e7a..40f558df26 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorDiagnostic.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorDiagnostic.cs @@ -8,26 +8,29 @@ namespace Microsoft.AspNetCore.Razor.Language { internal class DefaultRazorDiagnostic : RazorDiagnostic { - private readonly RazorDiagnosticDescriptor _descriptor; - private readonly object[] _args; - internal DefaultRazorDiagnostic(RazorDiagnosticDescriptor descriptor, SourceSpan span, object[] args) { - _descriptor = descriptor; + Descriptor = descriptor; Span = span; - _args = args; + Args = args; } - public override string Id => _descriptor.Id; + public override string Id => Descriptor.Id; - public override RazorDiagnosticSeverity Severity => _descriptor.Severity; + public override RazorDiagnosticSeverity Severity => Descriptor.Severity; public override SourceSpan Span { get; } + // Internal for testing + internal RazorDiagnosticDescriptor Descriptor { get; } + + // Internal for testing + internal object[] Args { get; } + public override string GetMessage(IFormatProvider formatProvider) { - var format = _descriptor.GetMessageFormat(); - return string.Format(formatProvider, format, _args); + var format = Descriptor.GetMessageFormat(); + return string.Format(formatProvider, format, Args); } public override bool Equals(RazorDiagnostic obj) @@ -38,7 +41,7 @@ namespace Microsoft.AspNetCore.Razor.Language return false; } - if (!_descriptor.Equals(other._descriptor)) + if (!Descriptor.Equals(other.Descriptor)) { return false; } @@ -48,14 +51,14 @@ namespace Microsoft.AspNetCore.Razor.Language return false; } - if (_args.Length != other._args.Length) + if (Args.Length != other.Args.Length) { return false; } - for (var i = 0; i < _args.Length; i++) + for (var i = 0; i < Args.Length; i++) { - if (!_args[i].Equals(other._args[i])) + if (!Args[i].Equals(other.Args[i])) { return false; } @@ -67,12 +70,12 @@ namespace Microsoft.AspNetCore.Razor.Language public override int GetHashCode() { var hash = new HashCodeCombiner(); - hash.Add(_descriptor.GetHashCode()); + hash.Add(Descriptor.GetHashCode()); hash.Add(Span.GetHashCode()); - for (var i = 0; i < _args.Length; i++) + for (var i = 0; i < Args.Length; i++) { - hash.Add(_args[i]); + hash.Add(Args[i]); } return hash; diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorIntermediateNodeLoweringPhase.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorIntermediateNodeLoweringPhase.cs index b7047bca1b..5e3ae8a258 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorIntermediateNodeLoweringPhase.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorIntermediateNodeLoweringPhase.cs @@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Razor.Language.Legacy; namespace Microsoft.AspNetCore.Razor.Language { +#pragma warning disable CS0618 // Type or member is obsolete internal class DefaultRazorIntermediateNodeLoweringPhase : RazorEnginePhaseBase, IRazorIntermediateNodeLoweringPhase { private IRazorCodeGenerationOptionsFeature _optionsFeature; @@ -31,7 +32,7 @@ namespace Microsoft.AspNetCore.Razor.Language var document = new DocumentIntermediateNode(); var builder = IntermediateNodeBuilder.Create(document); - document.Options = _optionsFeature.GetOptions(); + document.Options = codeDocument.GetCodeGenerationOptions() ?? _optionsFeature.GetOptions(); var namespaces = new Dictionary(StringComparer.Ordinal); @@ -785,4 +786,5 @@ namespace Microsoft.AspNetCore.Razor.Language private static bool IsMalformed(List diagnostics) => diagnostics.Count > 0 && diagnostics.Any(diagnostic => diagnostic.Severity == RazorDiagnosticSeverity.Error); } +#pragma warning restore CS0618 // Type or member is obsolete } diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsBuilder.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsBuilder.cs index eadc773439..2e4d3273d2 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsBuilder.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsBuilder.cs @@ -9,23 +9,43 @@ namespace Microsoft.AspNetCore.Razor.Language { internal class DefaultRazorParserOptionsBuilder : RazorParserOptionsBuilder { - public DefaultRazorParserOptionsBuilder(bool designTime, RazorLanguageVersion version) + private bool _designTime; + + public DefaultRazorParserOptionsBuilder(RazorConfiguration configuration) { - DesignTime = designTime; - Version = version; + if (configuration == null) + { + throw new ArgumentNullException(nameof(configuration)); + } + + Configuration = configuration; + LanguageVersion = configuration.LanguageVersion; } - public override bool DesignTime { get; } + public DefaultRazorParserOptionsBuilder(bool designTime, RazorLanguageVersion version) + { + _designTime = designTime; + LanguageVersion = version; + } + + public override RazorConfiguration Configuration { get; } + + public override bool DesignTime => _designTime; public override ICollection Directives { get; } = new List(); public override bool ParseLeadingDirectives { get; set; } - public override RazorLanguageVersion Version { get; } + public override RazorLanguageVersion LanguageVersion { get; } public override RazorParserOptions Build() { - return new DefaultRazorParserOptions(Directives.ToArray(), DesignTime, ParseLeadingDirectives, Version); + return new DefaultRazorParserOptions(Directives.ToArray(), DesignTime, ParseLeadingDirectives, LanguageVersion); + } + + public override void SetDesignTime(bool designTime) + { + _designTime = designTime; } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsFactoryProjectFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsFactoryProjectFeature.cs new file mode 100644 index 0000000000..32fb04af7f --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsFactoryProjectFeature.cs @@ -0,0 +1,32 @@ +// 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.Linq; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal class DefaultRazorParserOptionsFactoryProjectFeature : RazorProjectEngineFeatureBase, IRazorParserOptionsFactoryProjectFeature + { + private IConfigureRazorParserOptionsFeature[] _configureOptions; + + protected override void OnInitialized() + { + _configureOptions = ProjectEngine.EngineFeatures.OfType().ToArray(); + } + + public RazorParserOptions Create(Action configure) + { + var builder = new DefaultRazorParserOptionsBuilder(ProjectEngine.Configuration); + configure?.Invoke(builder); + + for (var i = 0; i < _configureOptions.Length; i++) + { + _configureOptions[i].Configure(builder); + } + + var options = builder.Build(); + return options; + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsFeature.cs index 867e289ee7..eecb9bd9cc 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsFeature.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsFeature.cs @@ -5,7 +5,9 @@ using System.Linq; namespace Microsoft.AspNetCore.Razor.Language { +#pragma warning disable CS0618 // Type or member is obsolete internal class DefaultRazorParserOptionsFeature : RazorEngineFeatureBase, IRazorParserOptionsFeature +#pragma warning restore CS0618 // Type or member is obsolete { private readonly bool _designTime; private readonly RazorLanguageVersion _version; diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParsingPhase.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParsingPhase.cs index 5a13e68760..8264201271 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParsingPhase.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParsingPhase.cs @@ -3,6 +3,7 @@ namespace Microsoft.AspNetCore.Razor.Language { +#pragma warning disable CS0618 // Type or member is obsolete internal class DefaultRazorParsingPhase : RazorEnginePhaseBase, IRazorParsingPhase { private IRazorParserOptionsFeature _optionsFeature; @@ -14,7 +15,7 @@ namespace Microsoft.AspNetCore.Razor.Language protected override void ExecuteCore(RazorCodeDocument codeDocument) { - var options = _optionsFeature.GetOptions(); + var options = codeDocument.GetParserOptions() ??_optionsFeature.GetOptions(); var syntaxTree = RazorSyntaxTree.Parse(codeDocument.Source, options); codeDocument.SetSyntaxTree(syntaxTree); @@ -26,4 +27,5 @@ namespace Microsoft.AspNetCore.Razor.Language codeDocument.SetImportSyntaxTrees(importSyntaxTrees); } } +#pragma warning restore CS0618 // Type or member is obsolete } diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngine.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngine.cs new file mode 100644 index 0000000000..e7eaafec22 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngine.cs @@ -0,0 +1,154 @@ +// 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.Collections.Generic; +using System.Linq; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal class DefaultRazorProjectEngine : RazorProjectEngine + { + public DefaultRazorProjectEngine( + RazorConfiguration configuration, + RazorEngine engine, + RazorProjectFileSystem fileSystem, + IReadOnlyList projectFeatures) + { + if (configuration == null) + { + throw new ArgumentNullException(nameof(configuration)); + } + + if (engine == null) + { + throw new ArgumentNullException(nameof(engine)); + } + + if (fileSystem == null) + { + throw new ArgumentNullException(nameof(fileSystem)); + } + + if (projectFeatures == null) + { + throw new ArgumentNullException(nameof(projectFeatures)); + } + + Configuration = configuration; + Engine = engine; + FileSystem = fileSystem; + ProjectFeatures = projectFeatures; + + for (var i = 0; i < projectFeatures.Count; i++) + { + projectFeatures[i].ProjectEngine = this; + } + } + + public override RazorConfiguration Configuration { get; } + + public override RazorProjectFileSystem FileSystem { get; } + + public override RazorEngine Engine { get; } + + public override IReadOnlyList ProjectFeatures { get; } + + protected override RazorCodeDocument CreateCodeDocumentCore(RazorProjectItem projectItem) + { + if (projectItem == null) + { + throw new ArgumentNullException(nameof(projectItem)); + } + + var sourceDocument = RazorSourceDocument.ReadFrom(projectItem); + + var importFeature = GetRequiredFeature(); + var importItems = importFeature.GetImports(projectItem); + var importSourceDocuments = importItems.Select(ConvertToSourceDocument); + + var parserOptions = GetRequiredFeature().Create(ConfigureParserOptions); + var codeGenerationOptions = GetRequiredFeature().Create(ConfigureCodeGenerationOptions); + + return RazorCodeDocument.Create(sourceDocument, importSourceDocuments, parserOptions, codeGenerationOptions); + } + + protected override RazorCodeDocument CreateCodeDocumentDesignTimeCore(RazorProjectItem projectItem) + { + if (projectItem == null) + { + throw new ArgumentNullException(nameof(projectItem)); + } + + var sourceDocument = RazorSourceDocument.ReadFrom(projectItem); + + var importFeature = GetRequiredFeature(); + var importItems = importFeature.GetImports(projectItem); + var importSourceDocuments = importItems.Select(ConvertToSourceDocument); + + var parserOptions = GetRequiredFeature().Create(ConfigureDesignTimeParserOptions); + var codeGenerationOptions = GetRequiredFeature().Create(ConfigureDesignTimeCodeGenerationOptions); + + + return RazorCodeDocument.Create(sourceDocument, importSourceDocuments, parserOptions, codeGenerationOptions); + } + + protected override void ProcessCore(RazorCodeDocument codeDocument) + { + if (codeDocument == null) + { + throw new ArgumentNullException(nameof(codeDocument)); + } + + Engine.Process(codeDocument); + } + + private TFeature GetRequiredFeature() where TFeature : IRazorProjectEngineFeature + { + var feature = ProjectFeatures.OfType().FirstOrDefault(); + if (feature == null) + { + throw new InvalidOperationException( + Resources.FormatRazorProjectEngineMissingFeatureDependency( + typeof(RazorProjectEngine).FullName, + typeof(TFeature).FullName)); + } + + return feature; + } + + private void ConfigureParserOptions(RazorParserOptionsBuilder builder) + { + } + + private void ConfigureDesignTimeParserOptions(RazorParserOptionsBuilder builder) + { + builder.SetDesignTime(true); + } + + private void ConfigureCodeGenerationOptions(RazorCodeGenerationOptionsBuilder builder) + { + } + + private void ConfigureDesignTimeCodeGenerationOptions(RazorCodeGenerationOptionsBuilder builder) + { + builder.SetDesignTime(true); + builder.SuppressChecksum = true; + builder.SuppressMetadataAttributes = true; + } + + // Internal for testing + internal static RazorSourceDocument ConvertToSourceDocument(RazorProjectItem importItem) + { + if (importItem.Exists) + { + // Normal import, has file paths, content etc. + return RazorSourceDocument.ReadFrom(importItem); + } + + // Marker import, doesn't exist, used as an identifier for "there could be something here". + var sourceDocumentProperties = new RazorSourceDocumentProperties(importItem.FilePath, importItem.RelativePhysicalPath); + return RazorSourceDocument.Create(string.Empty, sourceDocumentProperties); + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngineBuilder.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngineBuilder.cs new file mode 100644 index 0000000000..a07f4581ff --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngineBuilder.cs @@ -0,0 +1,56 @@ +// 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.Collections.Generic; +using System.Linq; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal class DefaultRazorProjectEngineBuilder : RazorProjectEngineBuilder + { + public DefaultRazorProjectEngineBuilder(RazorConfiguration configuration, RazorProjectFileSystem fileSystem) + { + if (fileSystem == null) + { + throw new ArgumentNullException(nameof(fileSystem)); + } + + Configuration = configuration; + FileSystem = fileSystem; + Features = new List(); + Phases = new List(); + } + + public override RazorConfiguration Configuration { get; } + + public override RazorProjectFileSystem FileSystem { get; } + + public override ICollection Features { get; } + + public override IList Phases { get; } + + public override RazorProjectEngine Build() + { + var engine = RazorEngine.CreateEmpty(ConfigureRazorEngine); + var projectFeatures = Features.OfType().ToArray(); + var projectEngine = new DefaultRazorProjectEngine(Configuration, engine, FileSystem, projectFeatures); + + return projectEngine; + } + + private void ConfigureRazorEngine(IRazorEngineBuilder engineBuilder) + { + var engineFeatures = Features.OfType(); + foreach (var engineFeature in engineFeatures) + { + engineBuilder.Features.Add(engineFeature); + } + + for (var i = 0; i < Phases.Count; i++) + { + engineBuilder.Phases.Add(Phases[i]); + } + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/FileSystemRazorProject.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectFileSystem.cs similarity index 68% rename from src/Microsoft.AspNetCore.Razor.Language/FileSystemRazorProject.cs rename to src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectFileSystem.cs index 52ddafebe3..2600ce5efe 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/FileSystemRazorProject.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectFileSystem.cs @@ -8,15 +8,15 @@ using System.Linq; namespace Microsoft.AspNetCore.Razor.Language { - internal class FileSystemRazorProject : RazorProject + internal class DefaultRazorProjectFileSystem : RazorProjectFileSystem { - public FileSystemRazorProject(string root) + public DefaultRazorProjectFileSystem(string root) { if (string.IsNullOrEmpty(root)) { throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(root)); } - + Root = root.Replace('\\', '/').TrimEnd('/'); } @@ -36,16 +36,24 @@ namespace Microsoft.AspNetCore.Razor.Language .EnumerateFiles("*.cshtml", SearchOption.AllDirectories) .Select(file => { - var relativePath = file.FullName.Substring(absoluteBasePath.Length).Replace(Path.DirectorySeparatorChar, '/'); - return new FileSystemRazorProjectItem(basePath, relativePath, file); + var relativePhysicalPath = file.FullName.Substring(absoluteBasePath.Length + 1); // Include leading separator + var filePath = "/" + relativePhysicalPath.Replace(Path.DirectorySeparatorChar, '/'); + + return new DefaultRazorProjectItem(basePath, filePath, relativePhysicalPath, file); }); } public override RazorProjectItem GetItem(string path) { + var absoluteBasePath = NormalizeAndEnsureValidPath("/"); var absolutePath = NormalizeAndEnsureValidPath(path); - return new FileSystemRazorProjectItem("/", path, new FileInfo(absolutePath)); + var file = new FileInfo(absolutePath); + + var relativePhysicalPath = file.FullName.Substring(absoluteBasePath.Length + 1); // Include leading separator + var filePath = "/" + relativePhysicalPath.Replace(Path.DirectorySeparatorChar, '/'); + + return new DefaultRazorProjectItem("/", filePath, relativePhysicalPath, new FileInfo(absolutePath)); } protected override string NormalizeAndEnsureValidPath(string path) diff --git a/src/Microsoft.AspNetCore.Razor.Language/FileSystemRazorProjectItem.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectItem.cs similarity index 51% rename from src/Microsoft.AspNetCore.Razor.Language/FileSystemRazorProjectItem.cs rename to src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectItem.cs index 4138fbc3d8..5a3590a121 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/FileSystemRazorProjectItem.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectItem.cs @@ -5,18 +5,20 @@ using System.IO; namespace Microsoft.AspNetCore.Razor.Language { - internal class FileSystemRazorProjectItem : RazorProjectItem + internal class DefaultRazorProjectItem : RazorProjectItem { /// - /// Initializes a new instance of . + /// Initializes a new instance of . /// /// The base path. - /// The path. + /// The physical path of the base path. + /// The path. /// The . - public FileSystemRazorProjectItem(string basePath, string path, FileInfo file) + public DefaultRazorProjectItem(string basePath, string filePath, string relativePhysicalPath, FileInfo file) { BasePath = basePath; - FilePath = path; + FilePath = filePath; + RelativePhysicalPath = relativePhysicalPath; File = file; } @@ -30,6 +32,8 @@ namespace Microsoft.AspNetCore.Razor.Language public override string PhysicalPath => File.FullName; - public override Stream Read() => File.OpenRead(); + public override string RelativePhysicalPath { get; } + + public override Stream Read() => new FileStream(PhysicalPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete); } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorSourceLineCollection.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorSourceLineCollection.cs index 87749a73e6..37b5e156f1 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorSourceLineCollection.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorSourceLineCollection.cs @@ -49,7 +49,7 @@ namespace Microsoft.AspNetCore.Razor.Language // We have an exact match for the start of a line. Debug.Assert(_lineStarts[index] == position); - return new SourceLocation(_document.FilePath, position, index, characterIndex: 0); + return new SourceLocation(_document.GetFilePathForDisplay(), position, index, characterIndex: 0); } @@ -59,12 +59,12 @@ namespace Microsoft.AspNetCore.Razor.Language if (index == -1) { // There's no preceding line, so it's based on the start of the string - return new SourceLocation(_document.FilePath, position, 0, position); + return new SourceLocation(_document.GetFilePathForDisplay(), position, 0, position); } else { var characterIndex = position - _lineStarts[index]; - return new SourceLocation(_document.FilePath, position, index, characterIndex); + return new SourceLocation(_document.GetFilePathForDisplay(), position, index, characterIndex); } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorTagHelperBinderPhase.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorTagHelperBinderPhase.cs index b75ab9335c..7d9dfb7c6e 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorTagHelperBinderPhase.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorTagHelperBinderPhase.cs @@ -58,9 +58,8 @@ namespace Microsoft.AspNetCore.Razor.Language var root = syntaxTree.Root; root = rewriter.Rewrite(root, errorSink); - // Temporary code while we're still using legacy diagnostics in the SyntaxTree. var errorList = new List(); - errorList.AddRange(errorSink.Errors.Select(error => RazorDiagnostic.Create(error))); + errorList.AddRange(errorSink.Errors); errorList.AddRange(descriptors.SelectMany(d => d.GetAllDiagnostics())); diff --git a/src/Microsoft.AspNetCore.Razor.Language/EmptyProjectFileSystem.cs b/src/Microsoft.AspNetCore.Razor.Language/EmptyProjectFileSystem.cs new file mode 100644 index 0000000000..61ced1271b --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/EmptyProjectFileSystem.cs @@ -0,0 +1,23 @@ +// 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.Linq; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal class EmptyProjectFileSystem : RazorProjectFileSystem + { + public override IEnumerable EnumerateItems(string basePath) + { + NormalizeAndEnsureValidPath(basePath); + return Enumerable.Empty(); + } + + public override RazorProjectItem GetItem(string path) + { + NormalizeAndEnsureValidPath(path); + return new NotFoundProjectItem(string.Empty, path); + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultMetadataIdentifierFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultMetadataIdentifierFeature.cs new file mode 100644 index 0000000000..89dc56c469 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultMetadataIdentifierFeature.cs @@ -0,0 +1,41 @@ +// 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; + +namespace Microsoft.AspNetCore.Razor.Language.Extensions +{ + // The default scheme for identifiers matches MVC's view engine paths: + // 1. Normalize backslash to forward-slash + // 2. Always include leading slash + // 3. Always include file name and extensions + internal class DefaultMetadataIdentifierFeature : RazorEngineFeatureBase, IMetadataIdentifierFeature + { + public string GetIdentifier(RazorCodeDocument codeDocument, RazorSourceDocument sourceDocument) + { + if (codeDocument == null) + { + throw new ArgumentNullException(nameof(codeDocument)); + } + + if (sourceDocument == null) + { + throw new ArgumentNullException(nameof(sourceDocument)); + } + + if (string.IsNullOrEmpty(sourceDocument.RelativePath)) + { + return null; + } + + var identifier = sourceDocument.RelativePath; + identifier = identifier.Replace("\\", "/"); + if (!identifier.StartsWith("/")) + { + identifier = "/" + identifier; + } + + return identifier; + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultTagHelperTargetExtension.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultTagHelperTargetExtension.cs index 3a6247a47e..ad85ebf807 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultTagHelperTargetExtension.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultTagHelperTargetExtension.cs @@ -16,8 +16,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions { private static readonly string[] PrivateModifiers = new string[] { "private" }; - public bool DesignTime { get; set; } - public string RunnerVariableName { get; set; } = "__tagHelperRunner"; public string StringValueBufferVariableName { get; set; } = "__tagHelperStringValueBuffer"; @@ -82,7 +80,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions throw new InvalidOperationException(message); } - if (DesignTime) + if (context.Options.DesignTime) { context.RenderChildren(node); } @@ -136,7 +134,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions .Write(CreateTagHelperMethodName) .WriteLine("();"); - if (!DesignTime) + if (!context.Options.DesignTime) { context.CodeWriter.WriteInstanceMethodInvocation( ExecutionContextVariableName, @@ -153,7 +151,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions throw new InvalidOperationException(message); } - if (!DesignTime) + if (!context.Options.DesignTime) { context.CodeWriter .Write("await ") @@ -200,7 +198,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions throw new InvalidOperationException(message); } - if (DesignTime) + if (context.Options.DesignTime) { context.RenderChildren(node); } @@ -284,7 +282,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions throw new InvalidOperationException(message); } - if (!DesignTime) + if (!context.Options.DesignTime) { // Ensure that the property we're trying to set has initialized its dictionary bound properties. if (node.IsIndexerNameMatch && @@ -338,7 +336,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions // If we get there, this is the first time seeing this property so we need to evaluate the expression. if (node.BoundAttribute.ExpectsStringValue(node.AttributeName)) { - if (DesignTime) + if (context.Options.DesignTime) { context.RenderChildren(node); @@ -370,7 +368,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions } else { - if (DesignTime) + if (context.Options.DesignTime) { var firstMappedChild = node.Children.FirstOrDefault(child => child.Source != null) as IntermediateNode; var valueStart = firstMappedChild?.Source; @@ -456,7 +454,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions } } - if (!DesignTime) + if (!context.Options.DesignTime) { // We need to inform the context of the attribute value. context.CodeWriter @@ -474,7 +472,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions public void WriteTagHelperRuntime(CodeRenderingContext context, DefaultTagHelperRuntimeIntermediateNode node) { - if (!DesignTime) + if (!context.Options.DesignTime) { context.CodeWriter.WriteLine("#line hidden"); @@ -550,7 +548,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions } } - private void RenderTagHelperAttributeInline( + // Internal for testing + internal void RenderTagHelperAttributeInline( CodeRenderingContext context, DefaultTagHelperPropertyIntermediateNode property, IntermediateNode node, @@ -565,7 +564,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions } else if (node is IntermediateToken token) { - if (DesignTime && node.Source != null) + if (context.Options.DesignTime && node.Source != null) { context.AddSourceMappingFor(node); } @@ -574,20 +573,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions } else if (node is CSharpCodeIntermediateNode) { - var error = new RazorError( - LegacyResources.TagHelpers_CodeBlocks_NotSupported_InAttributes, - SourceLocation.FromSpan(span), - span == null ? -1 : span.Value.Length); - context.Diagnostics.Add(RazorDiagnostic.Create(error)); + var diagnostic = RazorDiagnosticFactory.CreateTagHelper_CodeBlocksNotSupportedInAttributes(span ?? SourceSpan.Undefined); + context.Diagnostics.Add(diagnostic); } else if (node is TemplateIntermediateNode) { var expectedTypeName = property.IsIndexerNameMatch ? property.BoundAttribute.IndexerTypeName : property.BoundAttribute.TypeName; - var error = new RazorError( - LegacyResources.FormatTagHelpers_InlineMarkupBlocks_NotSupported_InAttributes(expectedTypeName), - SourceLocation.FromSpan(span), - span == null ? -1 : span.Value.Length); - context.Diagnostics.Add(RazorDiagnostic.Create(error)); + var diagnostic = RazorDiagnosticFactory.CreateTagHelper_InlineMarkupBlocksNotSupportedInAttributes(span ?? SourceSpan.Undefined, expectedTypeName); + context.Diagnostics.Add(diagnostic); } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/DesignTimeDirectivePass.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/DesignTimeDirectivePass.cs index 31e9cbf361..6d6d7e261d 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Extensions/DesignTimeDirectivePass.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/DesignTimeDirectivePass.cs @@ -15,6 +15,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) { + // Only supports design time. This pass rewrites directives so they will have the right design time + // behavior and would break things if it ran for runtime. + if (!documentNode.Options.DesignTime) + { + return; + } + var walker = new DesignTimeHelperWalker(); walker.VisitDocument(documentNode); } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/FunctionsDirective.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/FunctionsDirective.cs index f9033b8a83..0adb20aefb 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Extensions/FunctionsDirective.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/FunctionsDirective.cs @@ -1,6 +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. +using System; using Microsoft.AspNetCore.Razor.Language.Legacy; namespace Microsoft.AspNetCore.Razor.Language.Extensions @@ -15,10 +16,28 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions builder.Description = Resources.FunctionsDirective_Description; }); - public static void Register(IRazorEngineBuilder builder) + public static void Register(RazorProjectEngineBuilder builder) { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + builder.AddDirective(Directive); builder.Features.Add(new FunctionsDirectivePass()); } + + #region Obsolete + public static void Register(IRazorEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.AddDirective(Directive); + builder.Features.Add(new FunctionsDirectivePass()); + } + #endregion } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/IMetadataAttributeTargetExtension.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/IMetadataAttributeTargetExtension.cs new file mode 100644 index 0000000000..646dcdd46f --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/IMetadataAttributeTargetExtension.cs @@ -0,0 +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.CodeGeneration; + +namespace Microsoft.AspNetCore.Razor.Language.Extensions +{ + internal interface IMetadataAttributeTargetExtension : ICodeTargetExtension + { + void WriteRazorCompiledItemAttribute(CodeRenderingContext context, RazorCompiledItemAttributeIntermediateNode node); + + void WriteRazorSourceChecksumAttribute(CodeRenderingContext context, RazorSourceChecksumAttributeIntermediateNode node); + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/IMetadataIdentifierFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/IMetadataIdentifierFeature.cs new file mode 100644 index 0000000000..6948c33a67 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/IMetadataIdentifierFeature.cs @@ -0,0 +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. + +namespace Microsoft.AspNetCore.Razor.Language.Extensions +{ + internal interface IMetadataIdentifierFeature : IRazorEngineFeature + { + string GetIdentifier(RazorCodeDocument codeDocument, RazorSourceDocument sourceDocument); + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/InheritsDirective.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/InheritsDirective.cs index 289b5d853c..6cef321c73 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Extensions/InheritsDirective.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/InheritsDirective.cs @@ -1,6 +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. +using System; using Microsoft.AspNetCore.Razor.Language.Legacy; namespace Microsoft.AspNetCore.Razor.Language.Extensions @@ -17,10 +18,28 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions builder.Description = Resources.InheritsDirective_Description; }); - public static void Register(IRazorEngineBuilder builder) + public static void Register(RazorProjectEngineBuilder builder) { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + builder.AddDirective(Directive); builder.Features.Add(new InheritsDirectivePass()); } + + #region Obsolete + public static void Register(IRazorEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.AddDirective(Directive); + builder.Features.Add(new InheritsDirectivePass()); + } + #endregion } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/MetadataAttributePass.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/MetadataAttributePass.cs new file mode 100644 index 0000000000..843b1fa48b --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/MetadataAttributePass.cs @@ -0,0 +1,128 @@ +// 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.Linq; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.Extensions +{ + // Optimization pass is the best choice for this class. It's not an optimization, but it also doesn't add semantically + // meaningful information. + internal class MetadataAttributePass : IntermediateNodePassBase, IRazorOptimizationPass + { + private IMetadataIdentifierFeature _identifierFeature; + + protected override void OnInitialized() + { + _identifierFeature = Engine.Features.OfType().FirstOrDefault(); + } + + protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) + { + if (documentNode.Options == null || documentNode.Options.SuppressMetadataAttributes) + { + // Metadata attributes are turned off (or options not populated), nothing to do. + return; + } + + // We need to be able to compute the data we need for the [RazorCompiledItem] attribute - that includes + // a full type name, and a document kind, and optionally an identifier. + // + // If we can't use [RazorCompiledItem] then we don't care about the rest of the attributes. + var @namespace = documentNode.FindPrimaryNamespace(); + if (@namespace == null || string.IsNullOrEmpty(@namespace.Content)) + { + // No namespace node or it's incomplete. Skip. + return; + } + + var @class = documentNode.FindPrimaryClass(); + if (@class == null || string.IsNullOrEmpty(@class.ClassName)) + { + // No class node or it's incomplete. Skip. + return; + } + + if (documentNode.DocumentKind == null) + { + // No document kind. Skip. + return; + } + + var identifier = _identifierFeature?.GetIdentifier(codeDocument, codeDocument.Source); + if (identifier == null) + { + // No identifier. Skip + return; + } + + // [RazorCompiledItem] is an [assembly: ... ] attribute, so it needs to be applied at the global scope. + documentNode.Children.Insert(0, new RazorCompiledItemAttributeIntermediateNode() + { + TypeName = @namespace.Content + "." + @class.ClassName, + Kind = documentNode.DocumentKind, + Identifier = identifier, + }); + + // Now we need to add a [RazorSourceChecksum] for the source and for each import + // these are class attributes, so we need to find the insertion point to put them + // right before the class. + var insert = (int?)null; + for (var j = 0; j < @namespace.Children.Count; j++) + { + if (object.ReferenceEquals(@namespace.Children[j], @class)) + { + insert = j; + break; + } + } + + if (insert == null) + { + // Can't find a place to put the attributes, just bail. + return; + } + + // Checksum of the main source + var checksum = codeDocument.Source.GetChecksum(); + var checksumAlgorithm = codeDocument.Source.GetChecksumAlgorithm(); + if (checksum == null || checksum.Length == 0 || checksumAlgorithm == null || identifier == null) + { + // Don't generate anything unless we have all of the required information. + return; + } + + @namespace.Children.Insert((int)insert++, new RazorSourceChecksumAttributeIntermediateNode() + { + Checksum = checksum, + ChecksumAlgorithm = checksumAlgorithm, + Identifier = identifier, + }); + + // Now process the checksums of the imports + Debug.Assert(_identifierFeature != null); + for (var i = 0; i < codeDocument.Imports.Count; i++) + { + var import = codeDocument.Imports[i]; + + checksum = import.GetChecksum(); + checksumAlgorithm = import.GetChecksumAlgorithm(); + identifier = _identifierFeature.GetIdentifier(codeDocument, import); + + if (checksum == null || checksum.Length == 0 || checksumAlgorithm == null || identifier == null) + { + // It's ok to skip an import if we don't have all of the required information. + continue; + } + + @namespace.Children.Insert((int)insert++, new RazorSourceChecksumAttributeIntermediateNode() + { + Checksum = checksum, + ChecksumAlgorithm = checksumAlgorithm, + Identifier = identifier, + }); + } + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/MetadataAttributeTargetExtension.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/MetadataAttributeTargetExtension.cs new file mode 100644 index 0000000000..c9723efc5b --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/MetadataAttributeTargetExtension.cs @@ -0,0 +1,63 @@ +// 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 Microsoft.AspNetCore.Razor.Language.CodeGeneration; + +namespace Microsoft.AspNetCore.Razor.Language.Extensions +{ + internal class MetadataAttributeTargetExtension : IMetadataAttributeTargetExtension + { + public string CompiledItemAttributeName { get; set; } = "global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute"; + + public string SourceChecksumAttributeName { get; set; } = "global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute"; + + public void WriteRazorCompiledItemAttribute(CodeRenderingContext context, RazorCompiledItemAttributeIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + // [assembly: global::...RazorCompiledItem(typeof({node.TypeName}), @"{node.Kind}", @"{node.Identifier}")] + context.CodeWriter.Write("[assembly: "); + context.CodeWriter.Write(CompiledItemAttributeName); + context.CodeWriter.Write("(typeof("); + context.CodeWriter.Write(node.TypeName); + context.CodeWriter.Write("), @\""); + context.CodeWriter.Write(node.Kind); + context.CodeWriter.Write("\", @\""); + context.CodeWriter.Write(node.Identifier); + context.CodeWriter.WriteLine("\")]"); + } + + public void WriteRazorSourceChecksumAttribute(CodeRenderingContext context, RazorSourceChecksumAttributeIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + // [global::...RazorSourceChecksum(@"{node.ChecksumAlgorithm}", @"{node.Checksum}", @"{node.Identifier}")] + context.CodeWriter.Write("["); + context.CodeWriter.Write(SourceChecksumAttributeName); + context.CodeWriter.Write("(@\""); + context.CodeWriter.Write(node.ChecksumAlgorithm); + context.CodeWriter.Write("\", @\""); + context.CodeWriter.Write(Checksum.BytesToString(node.Checksum)); + context.CodeWriter.Write("\", @\""); + context.CodeWriter.Write(node.Identifier); + context.CodeWriter.WriteLine("\")]"); + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperAttributeOptimizationPass.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperAttributeOptimizationPass.cs index ed9488da20..f6d0f40a3b 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperAttributeOptimizationPass.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperAttributeOptimizationPass.cs @@ -15,6 +15,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) { + // There's no value in executing this pass at design time, it just prevents some allocations. + if (documentNode.Options.DesignTime) + { + return; + } + var walker = new PreallocatedTagHelperWalker(); walker.VisitDocument(documentNode); } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/RazorCompiledItemAttributeIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/RazorCompiledItemAttributeIntermediateNode.cs new file mode 100644 index 0000000000..792fb4ecc1 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/RazorCompiledItemAttributeIntermediateNode.cs @@ -0,0 +1,52 @@ +// 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 Microsoft.AspNetCore.Razor.Language.CodeGeneration; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.Extensions +{ + internal sealed class RazorCompiledItemAttributeIntermediateNode : ExtensionIntermediateNode + { + public override IntermediateNodeCollection Children => IntermediateNodeCollection.ReadOnly; + + public string TypeName { get; set; } + + public string Kind { get; set; } + + public string Identifier { get; set; } + + public override void Accept(IntermediateNodeVisitor visitor) + { + if (visitor == null) + { + throw new ArgumentNullException(nameof(visitor)); + } + + AcceptExtensionNode(this, visitor); + } + + public override void WriteNode(CodeTarget target, CodeRenderingContext context) + { + if (target == null) + { + throw new ArgumentNullException(nameof(target)); + } + + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + var extension = target.GetExtension(); + if (extension == null) + { + ReportMissingCodeTargetExtension(context); + return; + } + + extension.WriteRazorCompiledItemAttribute(context, this); + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/RazorSourceChecksumAttributeIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/RazorSourceChecksumAttributeIntermediateNode.cs new file mode 100644 index 0000000000..4aa8d3f978 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/RazorSourceChecksumAttributeIntermediateNode.cs @@ -0,0 +1,52 @@ +// 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 Microsoft.AspNetCore.Razor.Language.CodeGeneration; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.Extensions +{ + internal sealed class RazorSourceChecksumAttributeIntermediateNode : ExtensionIntermediateNode + { + public override IntermediateNodeCollection Children => IntermediateNodeCollection.ReadOnly; + + public byte[] Checksum { get; set; } + + public string ChecksumAlgorithm { get; set; } + + public string Identifier { get; set; } + + public override void Accept(IntermediateNodeVisitor visitor) + { + if (visitor == null) + { + throw new ArgumentNullException(nameof(visitor)); + } + + AcceptExtensionNode(this, visitor); + } + + public override void WriteNode(CodeTarget target, CodeRenderingContext context) + { + if (target == null) + { + throw new ArgumentNullException(nameof(target)); + } + + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + var extension = target.GetExtension(); + if (extension == null) + { + ReportMissingCodeTargetExtension(context); + return; + } + + extension.WriteRazorSourceChecksumAttribute(context, this); + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/SectionDirective.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/SectionDirective.cs index 1542525a70..14c461d08f 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Extensions/SectionDirective.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/SectionDirective.cs @@ -1,6 +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. +using System; using Microsoft.AspNetCore.Razor.Language.Legacy; namespace Microsoft.AspNetCore.Razor.Language.Extensions @@ -16,11 +17,30 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions builder.Description = Resources.SectionDirective_Description; }); - public static void Register(IRazorEngineBuilder builder) + public static void Register(RazorProjectEngineBuilder builder) { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + builder.AddDirective(Directive); builder.Features.Add(new SectionDirectivePass()); builder.AddTargetExtension(new SectionTargetExtension()); } + + #region Obsolete + public static void Register(IRazorEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.AddDirective(Directive); + builder.Features.Add(new SectionDirectivePass()); + builder.AddTargetExtension(new SectionTargetExtension()); + } + #endregion } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/IImportProjectFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/IImportProjectFeature.cs new file mode 100644 index 0000000000..98d8ffe558 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/IImportProjectFeature.cs @@ -0,0 +1,12 @@ +// 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 Microsoft.AspNetCore.Razor.Language +{ + public interface IImportProjectFeature : IRazorProjectEngineFeature + { + IReadOnlyList GetImports(RazorProjectItem projectItem); + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/IRazorCodeGenerationOptionsFactoryProjectFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/IRazorCodeGenerationOptionsFactoryProjectFeature.cs new file mode 100644 index 0000000000..6d3ed5156c --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/IRazorCodeGenerationOptionsFactoryProjectFeature.cs @@ -0,0 +1,12 @@ +// 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; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal interface IRazorCodeGenerationOptionsFactoryProjectFeature : IRazorProjectEngineFeature + { + RazorCodeGenerationOptions Create(Action configure); + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/IRazorCodeGenerationOptionsFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/IRazorCodeGenerationOptionsFeature.cs index dc97b6326c..b74bcc3d8d 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/IRazorCodeGenerationOptionsFeature.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/IRazorCodeGenerationOptionsFeature.cs @@ -1,8 +1,11 @@ // 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; + namespace Microsoft.AspNetCore.Razor.Language { + [Obsolete("In Razor 2.1 and newer, use RazorCodeDocument.GetCodeGenerationOptions().")] public interface IRazorCodeGenerationOptionsFeature : IRazorEngineFeature { RazorCodeGenerationOptions GetOptions(); diff --git a/src/Microsoft.AspNetCore.Razor.Language/IRazorEngineFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/IRazorEngineFeature.cs index dcf3efdf8a..e06f3a65ce 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/IRazorEngineFeature.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/IRazorEngineFeature.cs @@ -3,7 +3,7 @@ namespace Microsoft.AspNetCore.Razor.Language { - public interface IRazorEngineFeature + public interface IRazorEngineFeature : IRazorFeature { RazorEngine Engine { get; set; } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/IRazorFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/IRazorFeature.cs new file mode 100644 index 0000000000..4b8d602601 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/IRazorFeature.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. + +namespace Microsoft.AspNetCore.Razor.Language +{ + public interface IRazorFeature + { + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/IRazorParserOptionsFactoryProjectFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/IRazorParserOptionsFactoryProjectFeature.cs new file mode 100644 index 0000000000..e73bf8babc --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/IRazorParserOptionsFactoryProjectFeature.cs @@ -0,0 +1,12 @@ +// 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; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal interface IRazorParserOptionsFactoryProjectFeature : IRazorProjectEngineFeature + { + RazorParserOptions Create(Action configure); + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/IRazorParserOptionsFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/IRazorParserOptionsFeature.cs index ec4b3f1ab1..b2c1e9ec3e 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/IRazorParserOptionsFeature.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/IRazorParserOptionsFeature.cs @@ -1,8 +1,11 @@ // 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; + namespace Microsoft.AspNetCore.Razor.Language { + [Obsolete("In Razor 2.1 and newer, use RazorCodeDocument.GetParserOptions().")] public interface IRazorParserOptionsFeature : IRazorEngineFeature { RazorParserOptions GetOptions(); diff --git a/src/Microsoft.AspNetCore.Razor.Language/IRazorProjectEngineFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/IRazorProjectEngineFeature.cs new file mode 100644 index 0000000000..3b97dbefd2 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/IRazorProjectEngineFeature.cs @@ -0,0 +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. + +namespace Microsoft.AspNetCore.Razor.Language +{ + public interface IRazorProjectEngineFeature : IRazorFeature + { + RazorProjectEngine ProjectEngine { get; set; } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/LargeTextSourceDocument.cs b/src/Microsoft.AspNetCore.Razor.Language/LargeTextSourceDocument.cs index 20498f66b4..34e72ad984 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/LargeTextSourceDocument.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/LargeTextSourceDocument.cs @@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Razor.Language private readonly int _length; private byte[] _checksum; - public LargeTextSourceDocument(StreamReader reader, int chunkMaxLength, Encoding encoding, string fileName) + public LargeTextSourceDocument(StreamReader reader, int chunkMaxLength, Encoding encoding, RazorSourceDocumentProperties properties) { if (reader == null) { @@ -32,9 +32,15 @@ namespace Microsoft.AspNetCore.Razor.Language throw new ArgumentNullException(nameof(encoding)); } + if (properties == null) + { + throw new ArgumentNullException(nameof(properties)); + } + _chunkMaxLength = chunkMaxLength; Encoding = encoding; - FilePath = fileName; + FilePath = properties.FilePath; + RelativePath = properties.RelativePath; ReadChunks(reader, _chunkMaxLength, out _length, out _chunks); _lines = new DefaultRazorSourceLineCollection(this); @@ -59,6 +65,8 @@ namespace Microsoft.AspNetCore.Razor.Language public override RazorSourceLineCollection Lines => _lines; + public override string RelativePath { get; } + public override void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count) { if (destination == null) diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/Block.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/Block.cs index 9084f43a4e..ee7cc135f1 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/Block.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/Block.cs @@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { if (type == null) { - throw new InvalidOperationException(LegacyResources.Block_Type_Not_Specified); + throw new InvalidOperationException(Resources.Block_Type_Not_Specified); } Type = type.Value; @@ -234,6 +234,20 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy visitor.VisitBlock(this); } + public override SyntaxTreeNode Clone() + { + var blockBuilder = new BlockBuilder(this); + + blockBuilder.Children.Clear(); + for (var i = 0; i < Children.Count; i++) + { + var clonedChild = Children[i].Clone(); + blockBuilder.Children.Add(clonedChild); + } + + return blockBuilder.Build(); + } + internal void ChildChanged() { // A node in our graph has changed. We'll need to recompute our length the next time we're asked for it. diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpCodeParser.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpCodeParser.cs index 6390d1ffc4..9cdbb1389e 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpCodeParser.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpCodeParser.cs @@ -196,7 +196,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { if (Context == null) { - throw new InvalidOperationException(LegacyResources.Parser_Context_Not_Set); + throw new InvalidOperationException(Resources.Parser_Context_Not_Set); } Span.Start = CurrentLocation; @@ -296,10 +296,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy StringComparison.Ordinal)) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatParseError_HelperDirectiveNotAvailable( - SyntaxConstants.CSharp.HelperKeyword), - CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_HelperDirectiveNotAvailable( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length))); } Context.Builder.CurrentBlock.Type = BlockKindInternal.Expression; @@ -344,24 +342,21 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (At(CSharpSymbolType.WhiteSpace) || At(CSharpSymbolType.NewLine)) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS, - CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_UnexpectedWhiteSpaceAtStartOfCodeBlock( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length))); } else if (EndOfFile) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock, - length: 1 /* end of file */); + RazorDiagnosticFactory.CreateParsing_UnexpectedEndOfFileAtStartOfCodeBlock( + new SourceSpan(CurrentStart, contentLength: 1 /* end of file */))); } else { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS( - CurrentSymbol.Content), - CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), + CurrentSymbol.Content)); } } finally @@ -375,7 +370,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private void VerbatimBlock() { Assert(CSharpSymbolType.LeftBrace); - var block = new Block(LegacyResources.BlockName_Code, CurrentStart); + var block = new Block(Resources.BlockName_Code, CurrentStart); AcceptAndMoveNext(); // Set up the "{" span and output @@ -614,7 +609,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private void ExplicitExpression() { - var block = new Block(LegacyResources.BlockName_ExplicitExpression, CurrentStart); + var block = new Block(Resources.BlockName_ExplicitExpression, CurrentStart); Assert(CSharpSymbolType.LeftParenthesis); AcceptAndMoveNext(); Span.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.None; @@ -634,9 +629,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { AcceptUntil(CSharpSymbolType.LessThan); Context.ErrorSink.OnError( - block.Start, - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(block.Name, ")", "("), - length: 1 /* ( */); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(block.Start, contentLength: 1 /* ( */), block.Name, ")", "(")); } // If necessary, put an empty-content marker symbol here @@ -664,9 +658,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (Context.Builder.ActiveBlocks.Any(block => block.Type == BlockKindInternal.Template)) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.ParseError_InlineMarkup_Blocks_Cannot_Be_Nested, - length: 1 /* @ */); + RazorDiagnosticFactory.CreateParsing_InlineMarkupBlocksCannotBeNested( + new SourceSpan(CurrentStart, contentLength: 1 /* @ */))); } Output(SpanKindInternal.Code); using (Context.Builder.StartBlock(BlockKindInternal.Template)) @@ -767,9 +760,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy protected virtual void ReservedDirective(bool topLevel) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatParseError_ReservedWord(CurrentSymbol.Content), - CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_ReservedWord( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), CurrentSymbol.Content)); + AcceptAndMoveNext(); Span.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.None; Span.ChunkGenerator = SpanChunkGenerator.Null; @@ -850,9 +843,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (!topLevel) { Context.ErrorSink.OnError( - block.Start, - LegacyResources.ParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock, - block.Name.Length); + RazorDiagnosticFactory.CreateParsing_NamespaceImportAndTypeAliasCannotExistWithinCodeBlock( + new SourceSpan(block.Start, block.Name.Length))); StandardStatement(); } else @@ -1170,11 +1162,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (!At(CSharpSymbolType.LeftBrace)) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatParseError_SingleLine_ControlFlowStatements_Not_Allowed( + RazorDiagnosticFactory.CreateParsing_SingleLineControlFlowStatementsNotAllowed( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), Language.GetSample(CSharpSymbolType.LeftBrace), - CurrentSymbol.Content), - CurrentSymbol.Content.Length); + CurrentSymbol.Content)); } // Parse the statement and then we're done @@ -1333,9 +1324,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (type == CSharpSymbolType.Transition && !isSingleLineMarkup) { Context.ErrorSink.OnError( - loc, - LegacyResources.ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start, - length: 1 /* @ */); + RazorDiagnosticFactory.CreateParsing_AtInCodeMustBeFollowedByColonParenOrIdentifierStart( + new SourceSpan(loc, contentLength: 1 /* @ */))); } // Markup block @@ -1365,7 +1355,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy break; case CSharpSymbolType.LeftBrace: // Verbatim Block - block = block ?? new Block(LegacyResources.BlockName_Code, CurrentStart); + block = block ?? new Block(Resources.BlockName_Code, CurrentStart); AcceptAndMoveNext(); CodeBlock(block); break; @@ -1417,9 +1407,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (At(CSharpSymbolType.LeftBrace)) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.ParseError_Unexpected_Nested_CodeBlock, - length: 1 /* { */); + RazorDiagnosticFactory.CreateParsing_UnexpectedNestedCodeBlock( + new SourceSpan(CurrentStart, contentLength: 1 /* { */))); } // @( or @foo - Nested expression, parse a child block @@ -1513,9 +1502,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (EndOfFile) { Context.ErrorSink.OnError( - block.Start, - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(block.Name, '}', '{'), - length: 1 /* { OR } */); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(block.Start, contentLength: 1 /* { OR } */), block.Name, "}", "{")); } else if (acceptTerminatingBrace) { @@ -1624,9 +1612,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var currentDirective = CurrentSymbol.Content; Context.ErrorSink.OnError( - CurrentStart, - Resources.FormatDirectiveMustAppearAtStartOfLine(currentDirective), - length: currentDirective.Length); + RazorDiagnosticFactory.CreateParsing_DirectiveMustAppearAtStartOfLine( + new SourceSpan(CurrentStart, currentDirective.Length), currentDirective)); break; } } @@ -1662,9 +1649,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy !EndOfFile) { Context.ErrorSink.OnError( - CurrentStart, - Resources.FormatDirectiveTokensMustBeSeparatedByWhitespace(descriptor.Directive), - length: CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_DirectiveTokensMustBeSeparatedByWhitespace( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), descriptor.Directive)); return; } @@ -1700,9 +1686,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy else if (EndOfFile) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatUnexpectedEOFAfterDirective(descriptor.Directive, tokenDescriptor.Kind.ToString().ToLowerInvariant()), - length: 1); + RazorDiagnosticFactory.CreateParsing_UnexpectedEOFAfterDirective( + new SourceSpan(CurrentStart, contentLength: 1), + descriptor.Directive, + tokenDescriptor.Kind.ToString().ToLowerInvariant())); return; } @@ -1712,9 +1699,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (!NamespaceOrTypeName()) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatDirectiveExpectsTypeName(descriptor.Directive), - CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsTypeName( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), descriptor.Directive)); return; } @@ -1724,9 +1710,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (!QualifiedIdentifier(out var identifierLength)) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatDirectiveExpectsNamespace(descriptor.Directive), - identifierLength); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsNamespace( + new SourceSpan(CurrentStart, identifierLength), descriptor.Directive)); return; } @@ -1740,9 +1725,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy else { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatDirectiveExpectsIdentifier(descriptor.Directive), - CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsIdentifier( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), descriptor.Directive)); return; } break; @@ -1755,9 +1739,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy else { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatDirectiveExpectsQuotedStringLiteral(descriptor.Directive), - CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsQuotedStringLiteral( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), descriptor.Directive)); return; } break; @@ -1789,9 +1772,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy else if (!EndOfFile) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatUnexpectedDirectiveLiteral(descriptor.Directive, LegacyResources.ErrorComponent_Newline), - CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_UnexpectedDirectiveLiteral( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), + descriptor.Directive, + Resources.ErrorComponent_Newline)); } Span.ChunkGenerator = SpanChunkGenerator.Null; @@ -1840,8 +1824,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { if (directiveErrorSink.Errors.Count > 0) { - var directiveDiagnostics = directiveErrorSink.Errors.Select(error => RazorDiagnostic.Create(error)); - directiveChunkGenerator.Diagnostics.AddRange(directiveDiagnostics); + directiveChunkGenerator.Diagnostics.AddRange(directiveErrorSink.Errors); } Context.ErrorSink = savedErrorSink; @@ -1855,18 +1838,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { if (Context.SeenDirectives.Contains(descriptor.Directive)) { - UsageError(Resources.FormatDuplicateDirective(descriptor.Directive)); + // There will always be at least 1 child because of the `@` transition. + var directiveStart = Context.Builder.CurrentBlock.Children.First().Start; + var errorLength = /* @ */ 1 + descriptor.Directive.Length; + Context.ErrorSink.OnError( + RazorDiagnosticFactory.CreateParsing_DuplicateDirective( + new SourceSpan(directiveStart, errorLength), descriptor.Directive)); + return; } } - - void UsageError(string message) - { - // There wil always be at least 1 child because of the `@` transition. - var directiveStart = Context.Builder.CurrentBlock.Children.First().Start; - var errorLength = /* @ */ 1 + descriptor.Directive.Length; - Context.ErrorSink.OnError(directiveStart, message, errorLength); - } } private void ParseDirectiveBlock(DirectiveDescriptor descriptor, Action parseChildren) @@ -1874,16 +1855,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (EndOfFile) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatUnexpectedEOFAfterDirective(descriptor.Directive, "{"), - length: 1 /* { */); + RazorDiagnosticFactory.CreateParsing_UnexpectedEOFAfterDirective( + new SourceSpan(CurrentStart, contentLength: 1 /* { */), descriptor.Directive, "{")); } else if (!At(CSharpSymbolType.LeftBrace)) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatUnexpectedDirectiveLiteral(descriptor.Directive, "{"), - CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_UnexpectedDirectiveLiteral( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), descriptor.Directive, "{")); } else { @@ -1901,9 +1880,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { editHandler.AutoCompleteString = "}"; Context.ErrorSink.OnError( - startingBraceLocation, - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(descriptor.Directive, "}", "{"), - length: 1 /* } */); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(startingBraceLocation, contentLength: 1 /* } */), descriptor.Directive, "}", "{")); } else { @@ -1924,8 +1902,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var directiveStart = Context.Builder.CurrentBlock.Children.First().Start; var errorLength = /* @ */ 1 + SyntaxConstants.CSharp.TagHelperPrefixKeyword.Length; duplicateDiagnostic = RazorDiagnosticFactory.CreateParsing_DuplicateDirective( - SyntaxConstants.CSharp.TagHelperPrefixKeyword, - new SourceSpan(directiveStart, errorLength)); + new SourceSpan(directiveStart, errorLength), + SyntaxConstants.CSharp.TagHelperPrefixKeyword); } TagHelperDirective( @@ -1958,11 +1936,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (char.IsWhiteSpace(character) || InvalidNonWhitespaceNameCharacters.Contains(character)) { diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - Resources.FormatInvalidTagHelperPrefixValue(SyntaxConstants.CSharp.TagHelperPrefixKeyword, character, prefix), - directiveLocation, - prefix.Length))); + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperPrefixValue( + new SourceSpan(directiveLocation, prefix.Length), + SyntaxConstants.CSharp.TagHelperPrefixKeyword, + character, + prefix)); return; } @@ -2037,11 +2015,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy text.EndsWith("'")) { errors.Add( - RazorDiagnostic.Create( - new RazorError( - Resources.FormatInvalidTagHelperLookupText(text), - directiveLocation, - Math.Max(text.Length, 1)))); + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(directiveLocation, Math.Max(text.Length, 1)), text)); return directive; } @@ -2100,59 +2075,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Debug.Assert(string.Equals(CurrentSymbol.Content, directive, StringComparison.Ordinal)); } - protected void BaseTypeDirective(string noTypeNameError, Func createChunkGenerator) - { - var keywordStartLocation = Span.Start; - - // Set the block type - Context.Builder.CurrentBlock.Type = BlockKindInternal.Directive; - - var keywordLength = Span.End.AbsoluteIndex - Span.Start.AbsoluteIndex; - - // Accept whitespace - var remainingWhitespace = AcceptSingleWhiteSpaceCharacter(); - - if (Span.Symbols.Count > 1) - { - Span.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.None; - } - - Output(SpanKindInternal.MetaCode); - - if (remainingWhitespace != null) - { - Accept(remainingWhitespace); - } - - AcceptWhile(IsSpacingToken(includeNewLines: false, includeComments: true)); - - if (EndOfFile || At(CSharpSymbolType.WhiteSpace) || At(CSharpSymbolType.NewLine)) - { - Context.ErrorSink.OnError( - keywordStartLocation, - noTypeNameError, - keywordLength); - } - - // Parse to the end of the line - AcceptUntil(CSharpSymbolType.NewLine); - if (!Context.DesignTimeMode) - { - // We want the newline to be treated as code, but it causes issues at design-time. - Optional(CSharpSymbolType.NewLine); - } - - // Pull out the type name - var baseType = string.Concat(Span.Symbols.Select(s => s.Content)); - - // Set up chunk generation - Span.ChunkGenerator = createChunkGenerator(baseType.Trim()); - - // Output the span and finish the block - CompleteBlock(); - Output(SpanKindInternal.Code, AcceptedCharactersInternal.AnyExceptNewline); - } - private void TagHelperDirective(string keyword, Func, ISpanChunkGenerator> chunkGeneratorFactory) { AssertDirective(keyword); @@ -2190,9 +2112,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (EndOfFile || At(CSharpSymbolType.NewLine)) { Context.ErrorSink.OnError( - keywordStartLocation, - LegacyResources.FormatParseError_DirectiveMustHaveValue(keyword), - keywordLength); + RazorDiagnosticFactory.CreateParsing_DirectiveMustHaveValue( + new SourceSpan(keywordStartLocation, keywordLength), keyword)); directiveValue = string.Empty; } @@ -2213,9 +2134,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (startsWithQuote != endsWithQuote) { Context.ErrorSink.OnError( - startLocation, - LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(keyword), - rawValue.Length); + RazorDiagnosticFactory.CreateParsing_IncompleteQuotesAroundDirective( + new SourceSpan(startLocation, rawValue.Length), keyword)); } directiveValue = rawValue; @@ -2223,17 +2143,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } finally { - List directiveErrors; - if (directiveErrorSink.Errors.Count > 0) - { - directiveErrors = directiveErrorSink.Errors.Select(RazorDiagnostic.Create).ToList(); - } - else - { - directiveErrors = new List(); - } - - Span.ChunkGenerator = chunkGeneratorFactory(directiveValue, directiveErrors); + Span.ChunkGenerator = chunkGeneratorFactory(directiveValue, directiveErrorSink.Errors.ToList()); Context.ErrorSink = savedErrorSink; } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpLanguageCharacteristics.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpLanguageCharacteristics.cs index 7a251cc7e9..44ce3a89ce 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpLanguageCharacteristics.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpLanguageCharacteristics.cs @@ -74,7 +74,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return new CSharpTokenizer(source); } - protected override CSharpSymbol CreateSymbol(string content, CSharpSymbolType type, IReadOnlyList errors) + protected override CSharpSymbol CreateSymbol(string content, CSharpSymbolType type, IReadOnlyList errors) { return new CSharpSymbol(content, type, errors); } @@ -87,25 +87,25 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy switch (type) { case CSharpSymbolType.Identifier: - return LegacyResources.CSharpSymbol_Identifier; + return Resources.CSharpSymbol_Identifier; case CSharpSymbolType.Keyword: - return LegacyResources.CSharpSymbol_Keyword; + return Resources.CSharpSymbol_Keyword; case CSharpSymbolType.IntegerLiteral: - return LegacyResources.CSharpSymbol_IntegerLiteral; + return Resources.CSharpSymbol_IntegerLiteral; case CSharpSymbolType.NewLine: - return LegacyResources.CSharpSymbol_Newline; + return Resources.CSharpSymbol_Newline; case CSharpSymbolType.WhiteSpace: - return LegacyResources.CSharpSymbol_Whitespace; + return Resources.CSharpSymbol_Whitespace; case CSharpSymbolType.Comment: - return LegacyResources.CSharpSymbol_Comment; + return Resources.CSharpSymbol_Comment; case CSharpSymbolType.RealLiteral: - return LegacyResources.CSharpSymbol_RealLiteral; + return Resources.CSharpSymbol_RealLiteral; case CSharpSymbolType.CharacterLiteral: - return LegacyResources.CSharpSymbol_CharacterLiteral; + return Resources.CSharpSymbol_CharacterLiteral; case CSharpSymbolType.StringLiteral: - return LegacyResources.CSharpSymbol_StringLiteral; + return Resources.CSharpSymbol_StringLiteral; default: - return LegacyResources.Symbol_Unknown; + return Resources.Symbol_Unknown; } } return sample; diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpSymbol.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpSymbol.cs index cbb8cc9a21..21cd94915d 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpSymbol.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpSymbol.cs @@ -11,7 +11,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public CSharpSymbol( string content, CSharpSymbolType type) - : base(content, type, RazorError.EmptyArray) + : base(content, type, RazorDiagnostic.EmptyArray) { if (content == null) { @@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public CSharpSymbol( string content, CSharpSymbolType type, - IReadOnlyList errors) + IReadOnlyList errors) : base(content, type, errors) { if (content == null) diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpTokenizer.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpTokenizer.cs index eb08ba8e2e..a1943070f3 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpTokenizer.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpTokenizer.cs @@ -343,7 +343,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return base.GetSymbolContent(type); } - protected override CSharpSymbol CreateSymbol(string content, CSharpSymbolType type, IReadOnlyList errors) + protected override CSharpSymbol CreateSymbol(string content, CSharpSymbolType type, IReadOnlyList errors) { return new CSharpSymbol(content, type, errors); } @@ -547,10 +547,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy else if (EndOfFile) { CurrentErrors.Add( - new RazorError( - LegacyResources.ParseError_Unterminated_String_Literal, - CurrentStart, - length: 1 /* end of file */)); + RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( + new SourceSpan(CurrentStart, contentLength: 1 /* end of file */))); } return Transition(CSharpTokenizerState.Data, EndSymbol(CSharpSymbolType.StringLiteral)); } @@ -576,10 +574,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy else if (EndOfFile || ParserHelpers.IsNewLine(CurrentCharacter)) { CurrentErrors.Add( - new RazorError( - LegacyResources.ParseError_Unterminated_String_Literal, - CurrentStart, - length: 1 /* " */)); + RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( + new SourceSpan(CurrentStart, contentLength: 1 /* " */))); } else { @@ -595,10 +591,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (EndOfFile) { CurrentErrors.Add( - new RazorError( - LegacyResources.ParseError_BlockComment_Not_Terminated, - CurrentStart, - length: 1 /* end of file */)); + RazorDiagnosticFactory.CreateParsing_BlockCommentNotTerminated( + new SourceSpan(CurrentStart, contentLength: 1 /* end of file */))); + return Transition(CSharpTokenizerState.Data, EndSymbol(CSharpSymbolType.Comment)); } if (CurrentCharacter == '*') diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/ErrorSink.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/ErrorSink.cs index c8219dda5a..3b4c057cd7 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/ErrorSink.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/ErrorSink.cs @@ -6,41 +6,29 @@ using System.Collections.Generic; namespace Microsoft.AspNetCore.Razor.Language.Legacy { /// - /// Used to manage s encountered during the Razor parsing phase. + /// Used to manage s encountered during the Razor parsing phase. /// internal class ErrorSink { - private readonly List _errors; + private readonly List _errors; /// /// Instantiates a new instance of . /// public ErrorSink() { - _errors = new List(); + _errors = new List(); } /// - /// s collected. + /// s collected. /// - public IReadOnlyList Errors => _errors; + public IReadOnlyList Errors => _errors; /// /// Tracks the given . /// - /// The to track. - public void OnError(RazorError error) =>_errors.Add(error); - - /// - /// Creates and tracks a new . - /// - /// of the error. - /// A message describing the error. - /// The length of the error. - public void OnError(SourceLocation location, string message, int length) - { - var error = new RazorError(message, location, length); - _errors.Add(error); - } + /// The to track. + public void OnError(RazorDiagnostic error) =>_errors.Add(error); } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlLanguageCharacteristics.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlLanguageCharacteristics.cs index 70d7929736..cc44a34368 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlLanguageCharacteristics.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlLanguageCharacteristics.cs @@ -24,11 +24,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy switch (type) { case HtmlSymbolType.Text: - return LegacyResources.HtmlSymbol_Text; + return Resources.HtmlSymbol_Text; case HtmlSymbolType.WhiteSpace: - return LegacyResources.HtmlSymbol_WhiteSpace; + return Resources.HtmlSymbol_WhiteSpace; case HtmlSymbolType.NewLine: - return LegacyResources.HtmlSymbol_NewLine; + return Resources.HtmlSymbol_NewLine; case HtmlSymbolType.OpenAngle: return "<"; case HtmlSymbolType.Bang: @@ -56,13 +56,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy case HtmlSymbolType.Colon: return ":"; case HtmlSymbolType.RazorComment: - return LegacyResources.HtmlSymbol_RazorComment; + return Resources.HtmlSymbol_RazorComment; case HtmlSymbolType.RazorCommentStar: return "*"; case HtmlSymbolType.RazorCommentTransition: return "@"; default: - return LegacyResources.Symbol_Unknown; + return Resources.Symbol_Unknown; } } @@ -119,7 +119,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } } - protected override HtmlSymbol CreateSymbol(string content, HtmlSymbolType type, IReadOnlyList errors) + protected override HtmlSymbol CreateSymbol(string content, HtmlSymbolType type, IReadOnlyList errors) { return new HtmlSymbol(content, type, errors); } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlMarkupParser.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlMarkupParser.cs index 0a7d84efd3..4fdee1322f 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlMarkupParser.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlMarkupParser.cs @@ -267,7 +267,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { if (Context == null) { - throw new InvalidOperationException(LegacyResources.Parser_Context_Not_Set); + throw new InvalidOperationException(Resources.Parser_Context_Not_Set); } using (PushSpanConfig(DefaultMarkupSpan)) @@ -310,9 +310,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy else { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.ParseError_MarkupBlock_Must_Start_With_Tag, - CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_MarkupBlockMustStartWithTag( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length))); } Output(SpanKindInternal.Markup); } @@ -472,9 +471,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (tags.Count == 0) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.ParseError_OuterTagMissingName, - length: 1 /* end of file */); + RazorDiagnosticFactory.CreateParsing_OuterTagMissingName( + new SourceSpan(CurrentStart, contentLength: 1 /* end of file */))); } return false; } @@ -634,9 +632,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (!seenCloseAngle) { Context.ErrorSink.OnError( - textLocation, - LegacyResources.ParseError_TextTagCannotContainAttributes, - length: 4 /* text */); + RazorDiagnosticFactory.CreateParsing_TextTagCannotContainAttributes( + new SourceSpan(textLocation, contentLength: 4 /* text */))); Span.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.Any; RecoverTextTag(); @@ -1089,9 +1086,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Context.Source.Position = bookmark; NextToken(); Context.ErrorSink.OnError( - textLocation, - LegacyResources.ParseError_TextTagCannotContainAttributes, - length: 4 /* text */); + RazorDiagnosticFactory.CreateParsing_TextTagCannotContainAttributes( + new SourceSpan(textLocation, contentLength: 4 /* text */))); RecoverTextTag(); } @@ -1142,9 +1138,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (!seenClose) { Context.ErrorSink.OnError( - SourceLocationTracker.Advance(tag.Item2, "<"), - LegacyResources.FormatParseError_UnfinishedTag(tag.Item1.Content), - Math.Max(tag.Item1.Content.Length, 1)); + RazorDiagnosticFactory.CreateParsing_UnfinishedTag( + new SourceSpan( + SourceLocationTracker.Advance(tag.Item2, "<"), + Math.Max(tag.Item1.Content.Length, 1)), + tag.Item1.Content)); } else { @@ -1277,9 +1275,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (!Optional(HtmlSymbolType.CloseAngle)) { Context.ErrorSink.OnError( - SourceLocationTracker.Advance(tagStart, " { public HtmlSymbol(string content, HtmlSymbolType type) - : base(content, type, RazorError.EmptyArray) + : base(content, type, RazorDiagnostic.EmptyArray) { if (content == null) { @@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public HtmlSymbol( string content, HtmlSymbolType type, - IReadOnlyList errors) + IReadOnlyList errors) : base(content, type, errors) { if (content == null) diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlTokenizer.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlTokenizer.cs index 0b3af2d407..df9671d1b7 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlTokenizer.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlTokenizer.cs @@ -36,7 +36,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy get { return HtmlSymbolType.RazorCommentStar; } } - protected override HtmlSymbol CreateSymbol(string content, HtmlSymbolType type, IReadOnlyList errors) + protected override HtmlSymbol CreateSymbol(string content, HtmlSymbolType type, IReadOnlyList errors) { return new HtmlSymbol(content, type, errors); } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/LanguageCharacteristics.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/LanguageCharacteristics.cs index 02b5864458..23d5f037d0 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/LanguageCharacteristics.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/LanguageCharacteristics.cs @@ -86,7 +86,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public virtual Tuple SplitSymbol(TSymbol symbol, int splitAt, TSymbolType leftType) { - var left = CreateSymbol(symbol.Content.Substring(0, splitAt), leftType, RazorError.EmptyArray); + var left = CreateSymbol(symbol.Content.Substring(0, splitAt), leftType, RazorDiagnostic.EmptyArray); TSymbol right = null; if (splitAt < symbol.Content.Length) @@ -104,6 +104,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return type == KnownSymbolType.Unknown || !Equals(GetKnownSymbolType(type), GetKnownSymbolType(KnownSymbolType.Unknown)); } - protected abstract TSymbol CreateSymbol(string content, TSymbolType type, IReadOnlyList errors); + protected abstract TSymbol CreateSymbol(string content, TSymbolType type, IReadOnlyList errors); } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/RazorError.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/RazorError.cs deleted file mode 100644 index 7c93867a8c..0000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/RazorError.cs +++ /dev/null @@ -1,81 +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; -using System.Globalization; -using Microsoft.Extensions.Internal; - -namespace Microsoft.AspNetCore.Razor.Language.Legacy -{ - internal class RazorError : IEquatable - { - internal static readonly RazorError[] EmptyArray = new RazorError[0]; - - /// - /// Used only for deserialization. - /// - public RazorError() - : this(message: string.Empty, location: SourceLocation.Undefined, length: -1) - { - } - - public RazorError(string message, int absoluteIndex, int lineIndex, int columnIndex, int length) - : this(message, new SourceLocation(absoluteIndex, lineIndex, columnIndex), length) - { - } - - public RazorError(string message, SourceLocation location, int length) - { - Message = message; - Location = location; - Length = length; - } - - /// - /// Gets (or sets) the message describing the error. - /// - /// Set property is only accessible for deserialization purposes. - public string Message { get; set; } - - /// - /// Gets (or sets) the start position of the erroneous text. - /// - /// Set property is only accessible for deserialization purposes. - public SourceLocation Location { get; set; } - - /// - /// Gets or sets the length of the erroneous text. - /// - /// Set property is only accessible for deserialization purposes. - public int Length { get; set; } - - public override string ToString() - { - return string.Format(CultureInfo.CurrentCulture, "Error @ {0}({2}) - [{1}]", Location, Message, Length); - } - - public override bool Equals(object obj) - { - var error = obj as RazorError; - return Equals(error); - } - - public override int GetHashCode() - { - var hashCodeCombiner = HashCodeCombiner.Start(); - hashCodeCombiner.Add(Message, StringComparer.Ordinal); - hashCodeCombiner.Add(Location); - hashCodeCombiner.Add(Length); - - return hashCodeCombiner; - } - - public bool Equals(RazorError other) - { - return other != null && - string.Equals(other.Message, Message, StringComparison.Ordinal) && - Location.Equals(other.Location) && - Length.Equals(other.Length); - } - } -} diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/RazorParser.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/RazorParser.cs index 2823ffd69d..8e79907b8c 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/RazorParser.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/RazorParser.cs @@ -43,8 +43,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var root = context.Builder.Build(); - // Temporary code while we're still using legacy diagnostics in the SyntaxTree. - var diagnostics = context.ErrorSink.Errors.Select(error => RazorDiagnostic.Create(error)); + var diagnostics = context.ErrorSink.Errors; return RazorSyntaxTree.Create(root, source, diagnostics, Options); } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/Span.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/Span.cs index 880e8ee6f6..9b7366fc5e 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/Span.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/Span.cs @@ -179,5 +179,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { visitor.VisitSpan(this); } + + public override SyntaxTreeNode Clone() + { + var spanBuilder = new SpanBuilder(this); + return spanBuilder.Build(); + } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/SymbolBase.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/SymbolBase.cs index b0a772e85d..c1caebb988 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/SymbolBase.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/SymbolBase.cs @@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy protected SymbolBase( string content, TType type, - IReadOnlyList errors) + IReadOnlyList errors) { if (content == null) { @@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public Span Parent { get; set; } - public IReadOnlyList Errors { get; } + public IReadOnlyList Errors { get; } public string Content { get; } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/SyntaxTreeBuilder.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/SyntaxTreeBuilder.cs index 625a33fba4..6a48614ad7 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/SyntaxTreeBuilder.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/SyntaxTreeBuilder.cs @@ -39,7 +39,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { if (_blockStack.Count == 0) { - throw new InvalidOperationException(LegacyResources.ParserContext_NoCurrentBlock); + throw new InvalidOperationException(Resources.ParserContext_NoCurrentBlock); } CurrentBlock.Children.Add(span); LastSpan = span; @@ -63,7 +63,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { if (_blockStack.Count == 0) { - throw new InvalidOperationException(LegacyResources.EndBlock_Called_Without_Matching_StartBlock); + throw new InvalidOperationException(Resources.EndBlock_Called_Without_Matching_StartBlock); } if (_blockStack.Count > 1) @@ -78,11 +78,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { if (_blockStack.Count == 0) { - throw new InvalidOperationException(LegacyResources.ParserContext_CannotCompleteTree_NoRootBlock); + throw new InvalidOperationException(Resources.ParserContext_CannotCompleteTree_NoRootBlock); } if (_blockStack.Count != 1) { - throw new InvalidOperationException(LegacyResources.ParserContext_CannotCompleteTree_OutstandingBlocks); + throw new InvalidOperationException(Resources.ParserContext_CannotCompleteTree_OutstandingBlocks); } var rootBuilder = _blockStack.Pop(); diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/SyntaxTreeNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/SyntaxTreeNode.cs index ed5ef74181..a20c7c318b 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/SyntaxTreeNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/SyntaxTreeNode.cs @@ -43,5 +43,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public abstract int GetEquivalenceHash(); public abstract void Accept(ParserVisitor visitor); + + public abstract SyntaxTreeNode Clone(); } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperBlock.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperBlock.cs index 9d3f7167be..b8863247bd 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperBlock.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperBlock.cs @@ -159,6 +159,41 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return null; } + public override SyntaxTreeNode Clone() + { + var tagHelperBlockBuilder = new TagHelperBlockBuilder(this); + + tagHelperBlockBuilder.Children.Clear(); + for (var i = 0; i < Children.Count; i++) + { + var clonedChild = Children[i].Clone(); + tagHelperBlockBuilder.Children.Add(clonedChild); + } + + tagHelperBlockBuilder.Attributes.Clear(); + for (var i = 0; i < Attributes.Count; i++) + { + var existingAttribute = Attributes[i]; + var clonedValue = existingAttribute.Value != null ? existingAttribute.Value.Clone() : null; + tagHelperBlockBuilder.Attributes.Add( + new TagHelperAttributeNode(existingAttribute.Name, clonedValue, existingAttribute.AttributeStructure)); + } + + if (SourceStartTag != null) + { + var clonedStartTag = (Block)SourceStartTag.Clone(); + tagHelperBlockBuilder.SourceStartTag = clonedStartTag; + } + + if (SourceEndTag != null) + { + var clonedEndTag = (Block)SourceEndTag.Clone(); + tagHelperBlockBuilder.SourceEndTag = clonedEndTag; + } + + return tagHelperBlockBuilder.Build(); + } + /// public override string ToString() { diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperBlockBuilder.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperBlockBuilder.cs index b05edd8941..29e39bb3ae 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperBlockBuilder.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperBlockBuilder.cs @@ -18,9 +18,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public TagHelperBlockBuilder(TagHelperBlock original) : base(original) { - TagName = original.TagName; + SourceStartTag = original.SourceStartTag; + SourceEndTag = original.SourceEndTag; + TagMode = original.TagMode; BindingResult = original.Binding; Attributes = new List(original.Attributes); + TagName = original.TagName; } /// diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperBlockRewriter.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperBlockRewriter.cs index af8b1a9c36..bfb31bce05 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperBlockRewriter.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperBlockRewriter.cs @@ -61,8 +61,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Only want to track the attribute if we succeeded in parsing its corresponding Block/Span. if (result != null) { - SourceLocation? errorLocation = null; - // Check if it's a non-boolean bound attribute that is minimized or if it's a bound // non-string attribute that has null or whitespace content. var isMinimized = result.AttributeValueNode == null; @@ -74,32 +72,19 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy result.IsBoundNonStringAttribute && IsNullOrWhitespaceAttributeValue(result.AttributeValueNode))) { - errorLocation = GetAttributeNameStartLocation(child); - - errorSink.OnError( - errorLocation.Value, - LegacyResources.FormatRewriterError_EmptyTagHelperBoundAttribute( - result.AttributeName, - tagName, - GetPropertyType(result.AttributeName, bindingResult.Descriptors)), - result.AttributeName.Length); + var errorLocation = GetAttributeNameLocation(child, result.AttributeName); + var propertyTypeName = GetPropertyType(result.AttributeName, bindingResult.Descriptors); + var diagnostic = RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(errorLocation, result.AttributeName, tagName, propertyTypeName); + errorSink.OnError(diagnostic); } // Check if the attribute was a prefix match for a tag helper dictionary property but the // dictionary key would be the empty string. if (result.IsMissingDictionaryKey) { - if (!errorLocation.HasValue) - { - errorLocation = GetAttributeNameStartLocation(child); - } - - errorSink.OnError( - errorLocation.Value, - LegacyResources.FormatTagHelperBlockRewriter_IndexerAttributeNameMustIncludeKey( - result.AttributeName, - tagName), - result.AttributeName.Length); + var errorLocation = GetAttributeNameLocation(child, result.AttributeName); + var diagnostic = RazorDiagnosticFactory.CreateParsing_TagHelperIndexerAttributeNameMustIncludeKey(errorLocation, result.AttributeName, tagName); + errorSink.OnError(diagnostic); } var attributeNode = new TagHelperAttributeNode( @@ -299,10 +284,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // ex: () .First(sym => sym.Type != HtmlSymbolType.WhiteSpace && sym.Type != HtmlSymbolType.NewLine); - return firstNonWhitespaceSymbol.Start; + var location = new SourceSpan(firstNonWhitespaceSymbol.Start, attributeName.Length); + return location; } private static Span CreateMarkupAttribute(SpanBuilder builder, TryParseResult result) diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperParseTreeRewriter.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperParseTreeRewriter.cs index 00d48921aa..2059522263 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperParseTreeRewriter.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperParseTreeRewriter.cs @@ -291,12 +291,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { // End tag TagHelper that states it shouldn't have an end tag. errorSink.OnError( - SourceLocationTracker.Advance(tagBlock.Start, "(); + CurrentErrors = new List(); StartSymbol(); } - protected List CurrentErrors { get; } + protected List CurrentErrors { get; } protected abstract int StartState { get; } @@ -64,7 +64,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public SourceLocation CurrentStart { get; private set; } - protected abstract TSymbol CreateSymbol(string content, TSymbolType type, IReadOnlyList errors); + protected abstract TSymbol CreateSymbol(string content, TSymbolType type, IReadOnlyList errors); protected abstract StateResult Dispatch(); @@ -205,7 +205,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (HaveContent) { // Perf: Don't allocate a new errors array unless necessary. - var errors = CurrentErrors.Count == 0 ? RazorError.EmptyArray : new RazorError[CurrentErrors.Count]; + var errors = CurrentErrors.Count == 0 ? RazorDiagnostic.EmptyArray : new RazorDiagnostic[CurrentErrors.Count]; for (var i = 0; i < CurrentErrors.Count; i++) { errors[i] = CurrentErrors[i]; diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/TokenizerBackedParser.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/TokenizerBackedParser.cs index 3017e96fa6..6f564eb442 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/TokenizerBackedParser.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/TokenizerBackedParser.cs @@ -168,11 +168,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (EndOfFile && ((mode & BalancingModes.NoErrorOnFailure) != BalancingModes.NoErrorOnFailure)) { Context.ErrorSink.OnError( - start, - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF( + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(start, contentLength: 1 /* { OR } */), Language.GetSample(left), - Language.GetSample(right)), - length: 1 /* { OR } */); + Language.GetSample(right))); } return Balance(mode, left, right, start); @@ -218,11 +217,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if ((mode & BalancingModes.NoErrorOnFailure) != BalancingModes.NoErrorOnFailure) { Context.ErrorSink.OnError( - start, - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF( + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(start, contentLength: 1 /* { OR } */), Language.GetSample(left), - Language.GetSample(right)), - length: 1 /* { OR } */); + Language.GetSample(right))); } if ((mode & BalancingModes.BacktrackOnFailure) == BalancingModes.BacktrackOnFailure) { @@ -435,44 +433,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return false; } - protected internal bool Required(TSymbolType expected, bool errorIfNotFound, Func errorBase) - { - var found = At(expected); - if (!found && errorIfNotFound) - { - string error; - if (Language.IsNewLine(CurrentSymbol)) - { - error = LegacyResources.ErrorComponent_Newline; - } - else if (Language.IsWhiteSpace(CurrentSymbol)) - { - error = LegacyResources.ErrorComponent_Whitespace; - } - else if (EndOfFile) - { - error = LegacyResources.ErrorComponent_EndOfFile; - } - else - { - error = LegacyResources.FormatErrorComponent_Character(CurrentSymbol.Content); - } - - int errorLength; - if (CurrentSymbol == null || CurrentSymbol.Content == null) - { - errorLength = 1; - } - else - { - errorLength = Math.Max(CurrentSymbol.Content.Length, 1); - } - - Context.ErrorSink.OnError(CurrentStart, errorBase(error), errorLength); - } - return found; - } - protected bool EnsureCurrent() { if (CurrentSymbol == null) @@ -594,7 +554,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy protected virtual void OutputSpanBeforeRazorComment() { - throw new InvalidOperationException(LegacyResources.Language_Does_Not_Support_RazorComment); + throw new InvalidOperationException(Resources.Language_Does_Not_Support_RazorComment); } private void CommentSpanConfig(SpanBuilder span) @@ -609,7 +569,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy !Language.KnowsSymbolType(KnownSymbolType.CommentStar) || !Language.KnowsSymbolType(KnownSymbolType.CommentBody)) { - throw new InvalidOperationException(LegacyResources.Language_Does_Not_Support_RazorComment); + throw new InvalidOperationException(Resources.Language_Does_Not_Support_RazorComment); } OutputSpanBeforeRazorComment(); using (PushSpanConfig(CommentSpanConfig)) @@ -634,9 +594,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { errorReported = true; Context.ErrorSink.OnError( - start, - LegacyResources.ParseError_RazorComment_Not_Terminated, - length: 2 /* @* */); + RazorDiagnosticFactory.CreateParsing_RazorCommentNotTerminated( + new SourceSpan(start, contentLength: 2 /* @* */))); } else { @@ -649,9 +608,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { errorReported = true; Context.ErrorSink.OnError( - start, - LegacyResources.ParseError_RazorComment_Not_Terminated, - length: 2 /* @* */); + RazorDiagnosticFactory.CreateParsing_RazorCommentNotTerminated( + new SourceSpan(start, contentLength: 2 /* @* */))); } } else diff --git a/src/Microsoft.AspNetCore.Razor.Language/LegacyRazorDiagnostic.cs b/src/Microsoft.AspNetCore.Razor.Language/LegacyRazorDiagnostic.cs deleted file mode 100644 index 17ab6a5c2b..0000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/LegacyRazorDiagnostic.cs +++ /dev/null @@ -1,40 +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; -using Microsoft.AspNetCore.Razor.Language.Legacy; - -namespace Microsoft.AspNetCore.Razor.Language -{ - internal class LegacyRazorDiagnostic : RazorDiagnostic - { - private readonly RazorError _error; - - public LegacyRazorDiagnostic(RazorError error) - { - _error = error; - } - - public override string Id => "RZ9999"; - - public override RazorDiagnosticSeverity Severity => RazorDiagnosticSeverity.Error; - - public override SourceSpan Span => new SourceSpan(_error.Location, _error.Length); - - public override string GetMessage(IFormatProvider formatProvider) - { - return _error.Message; - } - - public override bool Equals(RazorDiagnostic obj) - { - var other = obj as LegacyRazorDiagnostic; - return other == null ? false : _error.Equals(other._error); - } - - public override int GetHashCode() - { - return _error.GetHashCode(); - } - } -} diff --git a/src/Microsoft.AspNetCore.Razor.Language/LegacyResources.resx b/src/Microsoft.AspNetCore.Razor.Language/LegacyResources.resx deleted file mode 100644 index af753ed15b..0000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/LegacyResources.resx +++ /dev/null @@ -1,410 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Value cannot be null or an empty string. - - - Value must be between {0} and {1}. - - - Value must be a value from the "{0}" enumeration. - - - Value must be greater than {0}. - - - Value must be greater than or equal to {0}. - - - Value must be less than {0}. - - - Value must be less than or equal to {0}. - - - Value cannot be an empty string. It must either be null or a non-empty string. - - - code - This is a literal used when composing ParserError_* messages. Most blocks are named by the keyword that starts them, for example "if". However, for those without keywords, a (localizable) name must be used. This literal is ALWAYS used mid-sentence, thus should not be capitalized. - - - explicit expression - This is a literal used when composing ParserError_* messages. Most blocks are named by the keyword that starts them, for example "if". However, for those without keywords, a (localizable) name must be used. This literal is ALWAYS used mid-sentence, thus should not be capitalized. - - - Block cannot be built because a Type has not been specified in the BlockBuilder - - - <<character literal>> - - - <<comment>> - - - <<identifier>> - - - <<integer literal>> - - - <<keyword>> - - - <<newline sequence>> - - - <<real literal>> - - - <<string literal>> - - - <<white space>> - - - The '{0}' directive expects an identifier. - - - The '{0}' directive expects a namespace name. - - - The '{0}' directive expects a string surrounded by double quotes. - - - The '{0}' directive expects a type name. - - - "EndBlock" was called without a matching call to "StartBlock". - - - "{0}" character - - - end of file - - - line break - - - space or line break - - - <<newline sequence>> - - - <<razor comment>> - - - <<text>> - - - <<white space>> - - - Cannot use built-in RazorComment handler, language characteristics does not define the CommentStart, CommentStar and CommentBody known symbol types or parser does not override TokenizerBackedParser.OutputSpanBeforeRazorComment - - - The "@" character must be followed by a ":", "(", or a C# identifier. If you intended to switch to markup, use an HTML start tag, for example: - -@if(isLoggedIn) { - <p>Hello, @user!</p> -} - - - End of file was reached before the end of the block comment. All comments started with "/*" sequence must be terminated with a matching "*/" sequence. - - - Directive '{0}' must have a value. - - - An opening "{0}" is missing the corresponding closing "{1}". - - - The {0} block is missing a closing "{1}" character. Make sure you have a matching "{1}" character for all the "{2}" characters within this block, and that none of the "{1}" characters are being interpreted as markup. - - - Expected "{0}". - - - The {0} directive is not supported. - - - Optional quote around the directive '{0}' is missing the corresponding opening or closing quote. - - - The 'inherits' keyword must be followed by a type name on the same line. - - - Inline markup blocks (@<p>Content</p>) cannot be nested. Only one level of inline markup is allowed. - - - Markup in a code block must start with a tag and all start tags must be matched with end tags. Do not use unclosed tags like "<br>". Instead use self-closing tags like "<br/>". - - - The "{0}" element was not closed. All elements must be either self-closing or have a matching end tag. - - - Sections cannot be empty. The "@section" keyword must be followed by a block of markup surrounded by "{}". For example: - -@section Sidebar { - <!-- Markup and text goes here --> -} - - - Namespace imports and type aliases cannot be placed within code blocks. They must immediately follow an "@" character in markup. It is recommended that you put them at the top of the page, as in the following example: - -@using System.Drawing; -@{ - // OK here to use types from System.Drawing in the page. -} - - - Outer tag is missing a name. The first character of a markup block must be an HTML tag with a valid name. - - - End of file was reached before the end of the block comment. All comments that start with the "@*" sequence must be terminated with a matching "*@" sequence. - - - "{0}" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. - - - Section blocks ("{0}") cannot be nested. Only one level of section blocks are allowed. - - - Expected a "{0}" but found a "{1}". Block statements must be enclosed in "{{" and "}}". You cannot use single-statement control-flow statements in CSHTML pages. For example, the following is not allowed: - -@if(isLoggedIn) - <p>Hello, @user</p> - -Instead, wrap the contents of the block in "{{}}": - -@if(isLoggedIn) {{ - <p>Hello, @user</p> -}} - {0} is only ever a single character - - - "<text>" and "</text>" tags cannot contain attributes. - - - Encountered end tag "{0}" with no matching start tag. Are your start/end tags properly balanced? - - - Unexpected {0} after section keyword. Section names must start with an "_" or alphabetic character, and the remaining characters must be either "_" or alphanumeric. - - - "{0}" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{{" are valid. - "{{" is an escape sequence for string.Format, when outputted to the user it will be displayed as "{" - - - End-of-file was found after the "@" character. "@" must be followed by a valid code block. If you want to output an "@", escape it using the sequence: "@@" - - - End-of-file was found after the "@" character. "@" must be followed by a valid code block. If you want to output an "@", escape it using the sequence: "@@" - - - Unexpected "{" after "@" character. Once inside the body of a code block (@if {}, @{}, etc.) you do not need to use "@{" to switch to code. - - - A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{" are valid at the start of a code block and they must occur immediately following "@" with no space in between. - - - End of file or an unexpected character was reached before the "{0}" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("<br />") or have matching end tags ("<p>Hello</p>"). If you intended to display a "<" character, use the "&lt;" HTML entity. - - - Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. - - - Cannot complete the tree, StartBlock must be called at least once. - - - Cannot complete the tree, there are still open blocks. - - - Cannot finish span, there is no current block. Call StartBlock at least once before finishing a span - - - Cannot complete action, the parser has finished. Only CompleteParse can be called to extract the final parser results after the parser has finished - - - Parser was started with a null Context property. The Context property must be set BEFORE calling any methods on the parser. - - - Attribute '{0}' on tag helper element '{1}' requires a value. Tag helper bound attributes of type '{2}' cannot be empty or contain only whitespace. - - - @section Header { ... } - In CSHTML, the @section keyword is case-sensitive and lowercase (as with all C# keywords) - - - Cannot perform '{1}' operations on '{0}' instances with different file paths. - - - <<unknown>> - - - The tag helper attribute '{0}' in element '{1}' is missing a key. The syntax is '<{1} {0}{{ key }}="value">'. - - - TagHelper attributes must be well-formed. - - - The parent <{0}> tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) '{1}' are allowed. - - - Found an end tag (</{0}>) for tag helper '{1}' with tag structure that disallows an end tag ('{2}'). - - - Tag helpers '{0}' and '{1}' targeting element '{2}' must not expect different {3} values. - - - The <{0}> tag is not allowed by parent <{1}> tag helper. Only child tags with name(s) '{2}' are allowed. - - - Found a malformed '{0}' tag helper. Tag helpers must have a start and end tag or be self closing. - - - Missing close angle for tag helper '{0}'. - - - Tag Helper '{0}'s attributes must have names. - - - The tag helper '{0}' must not have C# in the element's attribute declaration area. - - - Code blocks (e.g. @{{var variable = 23;}}) must not appear in non-string tag helper attribute values. - Already in an expression (code) context. If necessary an explicit expression (e.g. @(@readonly)) may be used. - - - Inline markup blocks (e.g. @<p>content</p>) must not appear in non-string tag helper attribute values. - Expected a '{0}' attribute value, not a string. - - - In order to put a symbol back, it must have been the symbol which ended at the current position. The specified symbol ends at {0}, but the current position is {1} - - - Unexpected literal following the '{0}' directive. Expected '{1}'. - - - Unexpected end of file following the '{0}' directive. Expected '{1}'. - - \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Language/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Razor.Language/Properties/AssemblyInfo.cs index 2e1dafb7a8..7214d8baca 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Properties/AssemblyInfo.cs @@ -2,10 +2,15 @@ // 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.Performance, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.Razor.Extensions.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.GenerateTool, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.Language.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.TagHelperTool, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.Test.Common, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.Tools.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("rzc, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Razor.Workspaces.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] diff --git a/src/Microsoft.AspNetCore.Razor.Language/Properties/LegacyResources.Designer.cs b/src/Microsoft.AspNetCore.Razor.Language/Properties/LegacyResources.Designer.cs deleted file mode 100644 index 73042a77d8..0000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/Properties/LegacyResources.Designer.cs +++ /dev/null @@ -1,1296 +0,0 @@ -// -namespace Microsoft.AspNetCore.Razor.Language -{ - using System.Globalization; - using System.Reflection; - using System.Resources; - - internal static class LegacyResources - { - private static readonly ResourceManager _resourceManager - = new ResourceManager("Microsoft.AspNetCore.Razor.Language.LegacyResources", typeof(LegacyResources).GetTypeInfo().Assembly); - - /// - /// Value cannot be null or an empty string. - /// - internal static string Argument_Cannot_Be_Null_Or_Empty - { - get => GetString("Argument_Cannot_Be_Null_Or_Empty"); - } - - /// - /// Value cannot be null or an empty string. - /// - internal static string FormatArgument_Cannot_Be_Null_Or_Empty() - => GetString("Argument_Cannot_Be_Null_Or_Empty"); - - /// - /// Value must be between {0} and {1}. - /// - internal static string Argument_Must_Be_Between - { - get => GetString("Argument_Must_Be_Between"); - } - - /// - /// Value must be between {0} and {1}. - /// - internal static string FormatArgument_Must_Be_Between(object p0, object p1) - => string.Format(CultureInfo.CurrentCulture, GetString("Argument_Must_Be_Between"), p0, p1); - - /// - /// Value must be a value from the "{0}" enumeration. - /// - internal static string Argument_Must_Be_Enum_Member - { - get => GetString("Argument_Must_Be_Enum_Member"); - } - - /// - /// Value must be a value from the "{0}" enumeration. - /// - internal static string FormatArgument_Must_Be_Enum_Member(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("Argument_Must_Be_Enum_Member"), p0); - - /// - /// Value must be greater than {0}. - /// - internal static string Argument_Must_Be_GreaterThan - { - get => GetString("Argument_Must_Be_GreaterThan"); - } - - /// - /// Value must be greater than {0}. - /// - internal static string FormatArgument_Must_Be_GreaterThan(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("Argument_Must_Be_GreaterThan"), p0); - - /// - /// Value must be greater than or equal to {0}. - /// - internal static string Argument_Must_Be_GreaterThanOrEqualTo - { - get => GetString("Argument_Must_Be_GreaterThanOrEqualTo"); - } - - /// - /// Value must be greater than or equal to {0}. - /// - internal static string FormatArgument_Must_Be_GreaterThanOrEqualTo(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("Argument_Must_Be_GreaterThanOrEqualTo"), p0); - - /// - /// Value must be less than {0}. - /// - internal static string Argument_Must_Be_LessThan - { - get => GetString("Argument_Must_Be_LessThan"); - } - - /// - /// Value must be less than {0}. - /// - internal static string FormatArgument_Must_Be_LessThan(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("Argument_Must_Be_LessThan"), p0); - - /// - /// Value must be less than or equal to {0}. - /// - internal static string Argument_Must_Be_LessThanOrEqualTo - { - get => GetString("Argument_Must_Be_LessThanOrEqualTo"); - } - - /// - /// Value must be less than or equal to {0}. - /// - internal static string FormatArgument_Must_Be_LessThanOrEqualTo(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("Argument_Must_Be_LessThanOrEqualTo"), p0); - - /// - /// Value cannot be an empty string. It must either be null or a non-empty string. - /// - internal static string Argument_Must_Be_Null_Or_Non_Empty - { - get => GetString("Argument_Must_Be_Null_Or_Non_Empty"); - } - - /// - /// Value cannot be an empty string. It must either be null or a non-empty string. - /// - internal static string FormatArgument_Must_Be_Null_Or_Non_Empty() - => GetString("Argument_Must_Be_Null_Or_Non_Empty"); - - /// - /// code - /// - internal static string BlockName_Code - { - get => GetString("BlockName_Code"); - } - - /// - /// code - /// - internal static string FormatBlockName_Code() - => GetString("BlockName_Code"); - - /// - /// explicit expression - /// - internal static string BlockName_ExplicitExpression - { - get => GetString("BlockName_ExplicitExpression"); - } - - /// - /// explicit expression - /// - internal static string FormatBlockName_ExplicitExpression() - => GetString("BlockName_ExplicitExpression"); - - /// - /// Block cannot be built because a Type has not been specified in the BlockBuilder - /// - internal static string Block_Type_Not_Specified - { - get => GetString("Block_Type_Not_Specified"); - } - - /// - /// Block cannot be built because a Type has not been specified in the BlockBuilder - /// - internal static string FormatBlock_Type_Not_Specified() - => GetString("Block_Type_Not_Specified"); - - /// - /// <<character literal>> - /// - internal static string CSharpSymbol_CharacterLiteral - { - get => GetString("CSharpSymbol_CharacterLiteral"); - } - - /// - /// <<character literal>> - /// - internal static string FormatCSharpSymbol_CharacterLiteral() - => GetString("CSharpSymbol_CharacterLiteral"); - - /// - /// <<comment>> - /// - internal static string CSharpSymbol_Comment - { - get => GetString("CSharpSymbol_Comment"); - } - - /// - /// <<comment>> - /// - internal static string FormatCSharpSymbol_Comment() - => GetString("CSharpSymbol_Comment"); - - /// - /// <<identifier>> - /// - internal static string CSharpSymbol_Identifier - { - get => GetString("CSharpSymbol_Identifier"); - } - - /// - /// <<identifier>> - /// - internal static string FormatCSharpSymbol_Identifier() - => GetString("CSharpSymbol_Identifier"); - - /// - /// <<integer literal>> - /// - internal static string CSharpSymbol_IntegerLiteral - { - get => GetString("CSharpSymbol_IntegerLiteral"); - } - - /// - /// <<integer literal>> - /// - internal static string FormatCSharpSymbol_IntegerLiteral() - => GetString("CSharpSymbol_IntegerLiteral"); - - /// - /// <<keyword>> - /// - internal static string CSharpSymbol_Keyword - { - get => GetString("CSharpSymbol_Keyword"); - } - - /// - /// <<keyword>> - /// - internal static string FormatCSharpSymbol_Keyword() - => GetString("CSharpSymbol_Keyword"); - - /// - /// <<newline sequence>> - /// - internal static string CSharpSymbol_Newline - { - get => GetString("CSharpSymbol_Newline"); - } - - /// - /// <<newline sequence>> - /// - internal static string FormatCSharpSymbol_Newline() - => GetString("CSharpSymbol_Newline"); - - /// - /// <<real literal>> - /// - internal static string CSharpSymbol_RealLiteral - { - get => GetString("CSharpSymbol_RealLiteral"); - } - - /// - /// <<real literal>> - /// - internal static string FormatCSharpSymbol_RealLiteral() - => GetString("CSharpSymbol_RealLiteral"); - - /// - /// <<string literal>> - /// - internal static string CSharpSymbol_StringLiteral - { - get => GetString("CSharpSymbol_StringLiteral"); - } - - /// - /// <<string literal>> - /// - internal static string FormatCSharpSymbol_StringLiteral() - => GetString("CSharpSymbol_StringLiteral"); - - /// - /// <<white space>> - /// - internal static string CSharpSymbol_Whitespace - { - get => GetString("CSharpSymbol_Whitespace"); - } - - /// - /// <<white space>> - /// - internal static string FormatCSharpSymbol_Whitespace() - => GetString("CSharpSymbol_Whitespace"); - - /// - /// The '{0}' directive expects an identifier. - /// - internal static string DirectiveExpectsIdentifier - { - get => GetString("DirectiveExpectsIdentifier"); - } - - /// - /// The '{0}' directive expects an identifier. - /// - internal static string FormatDirectiveExpectsIdentifier(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("DirectiveExpectsIdentifier"), p0); - - /// - /// The '{0}' directive expects a namespace name. - /// - internal static string DirectiveExpectsNamespace - { - get => GetString("DirectiveExpectsNamespace"); - } - - /// - /// The '{0}' directive expects a namespace name. - /// - internal static string FormatDirectiveExpectsNamespace(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("DirectiveExpectsNamespace"), p0); - - /// - /// The '{0}' directive expects a string surrounded by double quotes. - /// - internal static string DirectiveExpectsQuotedStringLiteral - { - get => GetString("DirectiveExpectsQuotedStringLiteral"); - } - - /// - /// The '{0}' directive expects a string surrounded by double quotes. - /// - internal static string FormatDirectiveExpectsQuotedStringLiteral(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("DirectiveExpectsQuotedStringLiteral"), p0); - - /// - /// The '{0}' directive expects a type name. - /// - internal static string DirectiveExpectsTypeName - { - get => GetString("DirectiveExpectsTypeName"); - } - - /// - /// The '{0}' directive expects a type name. - /// - internal static string FormatDirectiveExpectsTypeName(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("DirectiveExpectsTypeName"), p0); - - /// - /// "EndBlock" was called without a matching call to "StartBlock". - /// - internal static string EndBlock_Called_Without_Matching_StartBlock - { - get => GetString("EndBlock_Called_Without_Matching_StartBlock"); - } - - /// - /// "EndBlock" was called without a matching call to "StartBlock". - /// - internal static string FormatEndBlock_Called_Without_Matching_StartBlock() - => GetString("EndBlock_Called_Without_Matching_StartBlock"); - - /// - /// "{0}" character - /// - internal static string ErrorComponent_Character - { - get => GetString("ErrorComponent_Character"); - } - - /// - /// "{0}" character - /// - internal static string FormatErrorComponent_Character(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("ErrorComponent_Character"), p0); - - /// - /// end of file - /// - internal static string ErrorComponent_EndOfFile - { - get => GetString("ErrorComponent_EndOfFile"); - } - - /// - /// end of file - /// - internal static string FormatErrorComponent_EndOfFile() - => GetString("ErrorComponent_EndOfFile"); - - /// - /// line break - /// - internal static string ErrorComponent_Newline - { - get => GetString("ErrorComponent_Newline"); - } - - /// - /// line break - /// - internal static string FormatErrorComponent_Newline() - => GetString("ErrorComponent_Newline"); - - /// - /// space or line break - /// - internal static string ErrorComponent_Whitespace - { - get => GetString("ErrorComponent_Whitespace"); - } - - /// - /// space or line break - /// - internal static string FormatErrorComponent_Whitespace() - => GetString("ErrorComponent_Whitespace"); - - /// - /// <<newline sequence>> - /// - internal static string HtmlSymbol_NewLine - { - get => GetString("HtmlSymbol_NewLine"); - } - - /// - /// <<newline sequence>> - /// - internal static string FormatHtmlSymbol_NewLine() - => GetString("HtmlSymbol_NewLine"); - - /// - /// <<razor comment>> - /// - internal static string HtmlSymbol_RazorComment - { - get => GetString("HtmlSymbol_RazorComment"); - } - - /// - /// <<razor comment>> - /// - internal static string FormatHtmlSymbol_RazorComment() - => GetString("HtmlSymbol_RazorComment"); - - /// - /// <<text>> - /// - internal static string HtmlSymbol_Text - { - get => GetString("HtmlSymbol_Text"); - } - - /// - /// <<text>> - /// - internal static string FormatHtmlSymbol_Text() - => GetString("HtmlSymbol_Text"); - - /// - /// <<white space>> - /// - internal static string HtmlSymbol_WhiteSpace - { - get => GetString("HtmlSymbol_WhiteSpace"); - } - - /// - /// <<white space>> - /// - internal static string FormatHtmlSymbol_WhiteSpace() - => GetString("HtmlSymbol_WhiteSpace"); - - /// - /// Cannot use built-in RazorComment handler, language characteristics does not define the CommentStart, CommentStar and CommentBody known symbol types or parser does not override TokenizerBackedParser.OutputSpanBeforeRazorComment - /// - internal static string Language_Does_Not_Support_RazorComment - { - get => GetString("Language_Does_Not_Support_RazorComment"); - } - - /// - /// Cannot use built-in RazorComment handler, language characteristics does not define the CommentStart, CommentStar and CommentBody known symbol types or parser does not override TokenizerBackedParser.OutputSpanBeforeRazorComment - /// - internal static string FormatLanguage_Does_Not_Support_RazorComment() - => GetString("Language_Does_Not_Support_RazorComment"); - - /// - /// The "@" character must be followed by a ":", "(", or a C# identifier. If you intended to switch to markup, use an HTML start tag, for example: - /// - /// @if(isLoggedIn) { - /// <p>Hello, @user!</p> - /// } - /// - internal static string ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start - { - get => GetString("ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start"); - } - - /// - /// The "@" character must be followed by a ":", "(", or a C# identifier. If you intended to switch to markup, use an HTML start tag, for example: - /// - /// @if(isLoggedIn) { - /// <p>Hello, @user!</p> - /// } - /// - internal static string FormatParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start() - => GetString("ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start"); - - /// - /// End of file was reached before the end of the block comment. All comments started with "/*" sequence must be terminated with a matching "*/" sequence. - /// - internal static string ParseError_BlockComment_Not_Terminated - { - get => GetString("ParseError_BlockComment_Not_Terminated"); - } - - /// - /// End of file was reached before the end of the block comment. All comments started with "/*" sequence must be terminated with a matching "*/" sequence. - /// - internal static string FormatParseError_BlockComment_Not_Terminated() - => GetString("ParseError_BlockComment_Not_Terminated"); - - /// - /// Directive '{0}' must have a value. - /// - internal static string ParseError_DirectiveMustHaveValue - { - get => GetString("ParseError_DirectiveMustHaveValue"); - } - - /// - /// Directive '{0}' must have a value. - /// - internal static string FormatParseError_DirectiveMustHaveValue(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_DirectiveMustHaveValue"), p0); - - /// - /// An opening "{0}" is missing the corresponding closing "{1}". - /// - internal static string ParseError_Expected_CloseBracket_Before_EOF - { - get => GetString("ParseError_Expected_CloseBracket_Before_EOF"); - } - - /// - /// An opening "{0}" is missing the corresponding closing "{1}". - /// - internal static string FormatParseError_Expected_CloseBracket_Before_EOF(object p0, object p1) - => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_Expected_CloseBracket_Before_EOF"), p0, p1); - - /// - /// The {0} block is missing a closing "{1}" character. Make sure you have a matching "{1}" character for all the "{2}" characters within this block, and that none of the "{1}" characters are being interpreted as markup. - /// - internal static string ParseError_Expected_EndOfBlock_Before_EOF - { - get => GetString("ParseError_Expected_EndOfBlock_Before_EOF"); - } - - /// - /// The {0} block is missing a closing "{1}" character. Make sure you have a matching "{1}" character for all the "{2}" characters within this block, and that none of the "{1}" characters are being interpreted as markup. - /// - internal static string FormatParseError_Expected_EndOfBlock_Before_EOF(object p0, object p1, object p2) - => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_Expected_EndOfBlock_Before_EOF"), p0, p1, p2); - - /// - /// Expected "{0}". - /// - internal static string ParseError_Expected_X - { - get => GetString("ParseError_Expected_X"); - } - - /// - /// Expected "{0}". - /// - internal static string FormatParseError_Expected_X(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_Expected_X"), p0); - - /// - /// The {0} directive is not supported. - /// - internal static string ParseError_HelperDirectiveNotAvailable - { - get => GetString("ParseError_HelperDirectiveNotAvailable"); - } - - /// - /// The {0} directive is not supported. - /// - internal static string FormatParseError_HelperDirectiveNotAvailable(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_HelperDirectiveNotAvailable"), p0); - - /// - /// Optional quote around the directive '{0}' is missing the corresponding opening or closing quote. - /// - internal static string ParseError_IncompleteQuotesAroundDirective - { - get => GetString("ParseError_IncompleteQuotesAroundDirective"); - } - - /// - /// Optional quote around the directive '{0}' is missing the corresponding opening or closing quote. - /// - internal static string FormatParseError_IncompleteQuotesAroundDirective(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_IncompleteQuotesAroundDirective"), p0); - - /// - /// The 'inherits' keyword must be followed by a type name on the same line. - /// - internal static string ParseError_InheritsKeyword_Must_Be_Followed_By_TypeName - { - get => GetString("ParseError_InheritsKeyword_Must_Be_Followed_By_TypeName"); - } - - /// - /// The 'inherits' keyword must be followed by a type name on the same line. - /// - internal static string FormatParseError_InheritsKeyword_Must_Be_Followed_By_TypeName() - => GetString("ParseError_InheritsKeyword_Must_Be_Followed_By_TypeName"); - - /// - /// Inline markup blocks (@<p>Content</p>) cannot be nested. Only one level of inline markup is allowed. - /// - internal static string ParseError_InlineMarkup_Blocks_Cannot_Be_Nested - { - get => GetString("ParseError_InlineMarkup_Blocks_Cannot_Be_Nested"); - } - - /// - /// Inline markup blocks (@<p>Content</p>) cannot be nested. Only one level of inline markup is allowed. - /// - internal static string FormatParseError_InlineMarkup_Blocks_Cannot_Be_Nested() - => GetString("ParseError_InlineMarkup_Blocks_Cannot_Be_Nested"); - - /// - /// Markup in a code block must start with a tag and all start tags must be matched with end tags. Do not use unclosed tags like "<br>". Instead use self-closing tags like "<br/>". - /// - internal static string ParseError_MarkupBlock_Must_Start_With_Tag - { - get => GetString("ParseError_MarkupBlock_Must_Start_With_Tag"); - } - - /// - /// Markup in a code block must start with a tag and all start tags must be matched with end tags. Do not use unclosed tags like "<br>". Instead use self-closing tags like "<br/>". - /// - internal static string FormatParseError_MarkupBlock_Must_Start_With_Tag() - => GetString("ParseError_MarkupBlock_Must_Start_With_Tag"); - - /// - /// The "{0}" element was not closed. All elements must be either self-closing or have a matching end tag. - /// - internal static string ParseError_MissingEndTag - { - get => GetString("ParseError_MissingEndTag"); - } - - /// - /// The "{0}" element was not closed. All elements must be either self-closing or have a matching end tag. - /// - internal static string FormatParseError_MissingEndTag(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_MissingEndTag"), p0); - - /// - /// Sections cannot be empty. The "@section" keyword must be followed by a block of markup surrounded by "{}". For example: - /// - /// @section Sidebar { - /// <!-- Markup and text goes here --> - /// } - /// - internal static string ParseError_MissingOpenBraceAfterSection - { - get => GetString("ParseError_MissingOpenBraceAfterSection"); - } - - /// - /// Sections cannot be empty. The "@section" keyword must be followed by a block of markup surrounded by "{}". For example: - /// - /// @section Sidebar { - /// <!-- Markup and text goes here --> - /// } - /// - internal static string FormatParseError_MissingOpenBraceAfterSection() - => GetString("ParseError_MissingOpenBraceAfterSection"); - - /// - /// Namespace imports and type aliases cannot be placed within code blocks. They must immediately follow an "@" character in markup. It is recommended that you put them at the top of the page, as in the following example: - /// - /// @using System.Drawing; - /// @{ - /// // OK here to use types from System.Drawing in the page. - /// } - /// - internal static string ParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock - { - get => GetString("ParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock"); - } - - /// - /// Namespace imports and type aliases cannot be placed within code blocks. They must immediately follow an "@" character in markup. It is recommended that you put them at the top of the page, as in the following example: - /// - /// @using System.Drawing; - /// @{ - /// // OK here to use types from System.Drawing in the page. - /// } - /// - internal static string FormatParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock() - => GetString("ParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock"); - - /// - /// Outer tag is missing a name. The first character of a markup block must be an HTML tag with a valid name. - /// - internal static string ParseError_OuterTagMissingName - { - get => GetString("ParseError_OuterTagMissingName"); - } - - /// - /// Outer tag is missing a name. The first character of a markup block must be an HTML tag with a valid name. - /// - internal static string FormatParseError_OuterTagMissingName() - => GetString("ParseError_OuterTagMissingName"); - - /// - /// End of file was reached before the end of the block comment. All comments that start with the "@*" sequence must be terminated with a matching "*@" sequence. - /// - internal static string ParseError_RazorComment_Not_Terminated - { - get => GetString("ParseError_RazorComment_Not_Terminated"); - } - - /// - /// End of file was reached before the end of the block comment. All comments that start with the "@*" sequence must be terminated with a matching "*@" sequence. - /// - internal static string FormatParseError_RazorComment_Not_Terminated() - => GetString("ParseError_RazorComment_Not_Terminated"); - - /// - /// "{0}" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. - /// - internal static string ParseError_ReservedWord - { - get => GetString("ParseError_ReservedWord"); - } - - /// - /// "{0}" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. - /// - internal static string FormatParseError_ReservedWord(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_ReservedWord"), p0); - - /// - /// Section blocks ("{0}") cannot be nested. Only one level of section blocks are allowed. - /// - internal static string ParseError_Sections_Cannot_Be_Nested - { - get => GetString("ParseError_Sections_Cannot_Be_Nested"); - } - - /// - /// Section blocks ("{0}") cannot be nested. Only one level of section blocks are allowed. - /// - internal static string FormatParseError_Sections_Cannot_Be_Nested(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_Sections_Cannot_Be_Nested"), p0); - - /// - /// Expected a "{0}" but found a "{1}". Block statements must be enclosed in "{{" and "}}". You cannot use single-statement control-flow statements in CSHTML pages. For example, the following is not allowed: - /// - /// @if(isLoggedIn) - /// <p>Hello, @user</p> - /// - /// Instead, wrap the contents of the block in "{{}}": - /// - /// @if(isLoggedIn) {{ - /// <p>Hello, @user</p> - /// }} - /// - internal static string ParseError_SingleLine_ControlFlowStatements_Not_Allowed - { - get => GetString("ParseError_SingleLine_ControlFlowStatements_Not_Allowed"); - } - - /// - /// Expected a "{0}" but found a "{1}". Block statements must be enclosed in "{{" and "}}". You cannot use single-statement control-flow statements in CSHTML pages. For example, the following is not allowed: - /// - /// @if(isLoggedIn) - /// <p>Hello, @user</p> - /// - /// Instead, wrap the contents of the block in "{{}}": - /// - /// @if(isLoggedIn) {{ - /// <p>Hello, @user</p> - /// }} - /// - internal static string FormatParseError_SingleLine_ControlFlowStatements_Not_Allowed(object p0, object p1) - => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_SingleLine_ControlFlowStatements_Not_Allowed"), p0, p1); - - /// - /// "<text>" and "</text>" tags cannot contain attributes. - /// - internal static string ParseError_TextTagCannotContainAttributes - { - get => GetString("ParseError_TextTagCannotContainAttributes"); - } - - /// - /// "<text>" and "</text>" tags cannot contain attributes. - /// - internal static string FormatParseError_TextTagCannotContainAttributes() - => GetString("ParseError_TextTagCannotContainAttributes"); - - /// - /// Encountered end tag "{0}" with no matching start tag. Are your start/end tags properly balanced? - /// - internal static string ParseError_UnexpectedEndTag - { - get => GetString("ParseError_UnexpectedEndTag"); - } - - /// - /// Encountered end tag "{0}" with no matching start tag. Are your start/end tags properly balanced? - /// - internal static string FormatParseError_UnexpectedEndTag(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_UnexpectedEndTag"), p0); - - /// - /// Unexpected {0} after section keyword. Section names must start with an "_" or alphabetic character, and the remaining characters must be either "_" or alphanumeric. - /// - internal static string ParseError_Unexpected_Character_At_Section_Name_Start - { - get => GetString("ParseError_Unexpected_Character_At_Section_Name_Start"); - } - - /// - /// Unexpected {0} after section keyword. Section names must start with an "_" or alphabetic character, and the remaining characters must be either "_" or alphanumeric. - /// - internal static string FormatParseError_Unexpected_Character_At_Section_Name_Start(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_Unexpected_Character_At_Section_Name_Start"), p0); - - /// - /// "{0}" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{{" are valid. - /// - internal static string ParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS - { - get => GetString("ParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS"); - } - - /// - /// "{0}" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{{" are valid. - /// - internal static string FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS"), p0); - - /// - /// End-of-file was found after the "@" character. "@" must be followed by a valid code block. If you want to output an "@", escape it using the sequence: "@@" - /// - internal static string ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock - { - get => GetString("ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock"); - } - - /// - /// End-of-file was found after the "@" character. "@" must be followed by a valid code block. If you want to output an "@", escape it using the sequence: "@@" - /// - internal static string FormatParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock() - => GetString("ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock"); - - /// - /// End-of-file was found after the "@" character. "@" must be followed by a valid code block. If you want to output an "@", escape it using the sequence: "@@" - /// - internal static string ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock1 - { - get => GetString("ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock1"); - } - - /// - /// End-of-file was found after the "@" character. "@" must be followed by a valid code block. If you want to output an "@", escape it using the sequence: "@@" - /// - internal static string FormatParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock1() - => GetString("ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock1"); - - /// - /// Unexpected "{" after "@" character. Once inside the body of a code block (@if {}, @{}, etc.) you do not need to use "@{" to switch to code. - /// - internal static string ParseError_Unexpected_Nested_CodeBlock - { - get => GetString("ParseError_Unexpected_Nested_CodeBlock"); - } - - /// - /// Unexpected "{" after "@" character. Once inside the body of a code block (@if {}, @{}, etc.) you do not need to use "@{" to switch to code. - /// - internal static string FormatParseError_Unexpected_Nested_CodeBlock() - => GetString("ParseError_Unexpected_Nested_CodeBlock"); - - /// - /// A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{" are valid at the start of a code block and they must occur immediately following "@" with no space in between. - /// - internal static string ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS - { - get => GetString("ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS"); - } - - /// - /// A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{" are valid at the start of a code block and they must occur immediately following "@" with no space in between. - /// - internal static string FormatParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS() - => GetString("ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS"); - - /// - /// End of file or an unexpected character was reached before the "{0}" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("<br />") or have matching end tags ("<p>Hello</p>"). If you intended to display a "<" character, use the "&lt;" HTML entity. - /// - internal static string ParseError_UnfinishedTag - { - get => GetString("ParseError_UnfinishedTag"); - } - - /// - /// End of file or an unexpected character was reached before the "{0}" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("<br />") or have matching end tags ("<p>Hello</p>"). If you intended to display a "<" character, use the "&lt;" HTML entity. - /// - internal static string FormatParseError_UnfinishedTag(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_UnfinishedTag"), p0); - - /// - /// Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. - /// - internal static string ParseError_Unterminated_String_Literal - { - get => GetString("ParseError_Unterminated_String_Literal"); - } - - /// - /// Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. - /// - internal static string FormatParseError_Unterminated_String_Literal() - => GetString("ParseError_Unterminated_String_Literal"); - - /// - /// Cannot complete the tree, StartBlock must be called at least once. - /// - internal static string ParserContext_CannotCompleteTree_NoRootBlock - { - get => GetString("ParserContext_CannotCompleteTree_NoRootBlock"); - } - - /// - /// Cannot complete the tree, StartBlock must be called at least once. - /// - internal static string FormatParserContext_CannotCompleteTree_NoRootBlock() - => GetString("ParserContext_CannotCompleteTree_NoRootBlock"); - - /// - /// Cannot complete the tree, there are still open blocks. - /// - internal static string ParserContext_CannotCompleteTree_OutstandingBlocks - { - get => GetString("ParserContext_CannotCompleteTree_OutstandingBlocks"); - } - - /// - /// Cannot complete the tree, there are still open blocks. - /// - internal static string FormatParserContext_CannotCompleteTree_OutstandingBlocks() - => GetString("ParserContext_CannotCompleteTree_OutstandingBlocks"); - - /// - /// Cannot finish span, there is no current block. Call StartBlock at least once before finishing a span - /// - internal static string ParserContext_NoCurrentBlock - { - get => GetString("ParserContext_NoCurrentBlock"); - } - - /// - /// Cannot finish span, there is no current block. Call StartBlock at least once before finishing a span - /// - internal static string FormatParserContext_NoCurrentBlock() - => GetString("ParserContext_NoCurrentBlock"); - - /// - /// Cannot complete action, the parser has finished. Only CompleteParse can be called to extract the final parser results after the parser has finished - /// - internal static string ParserContext_ParseComplete - { - get => GetString("ParserContext_ParseComplete"); - } - - /// - /// Cannot complete action, the parser has finished. Only CompleteParse can be called to extract the final parser results after the parser has finished - /// - internal static string FormatParserContext_ParseComplete() - => GetString("ParserContext_ParseComplete"); - - /// - /// Parser was started with a null Context property. The Context property must be set BEFORE calling any methods on the parser. - /// - internal static string Parser_Context_Not_Set - { - get => GetString("Parser_Context_Not_Set"); - } - - /// - /// Parser was started with a null Context property. The Context property must be set BEFORE calling any methods on the parser. - /// - internal static string FormatParser_Context_Not_Set() - => GetString("Parser_Context_Not_Set"); - - /// - /// Attribute '{0}' on tag helper element '{1}' requires a value. Tag helper bound attributes of type '{2}' cannot be empty or contain only whitespace. - /// - internal static string RewriterError_EmptyTagHelperBoundAttribute - { - get => GetString("RewriterError_EmptyTagHelperBoundAttribute"); - } - - /// - /// Attribute '{0}' on tag helper element '{1}' requires a value. Tag helper bound attributes of type '{2}' cannot be empty or contain only whitespace. - /// - internal static string FormatRewriterError_EmptyTagHelperBoundAttribute(object p0, object p1, object p2) - => string.Format(CultureInfo.CurrentCulture, GetString("RewriterError_EmptyTagHelperBoundAttribute"), p0, p1, p2); - - /// - /// @section Header { ... } - /// - internal static string SectionExample_CS - { - get => GetString("SectionExample_CS"); - } - - /// - /// @section Header { ... } - /// - internal static string FormatSectionExample_CS() - => GetString("SectionExample_CS"); - - /// - /// Cannot perform '{1}' operations on '{0}' instances with different file paths. - /// - internal static string SourceLocationFilePathDoesNotMatch - { - get => GetString("SourceLocationFilePathDoesNotMatch"); - } - - /// - /// Cannot perform '{1}' operations on '{0}' instances with different file paths. - /// - internal static string FormatSourceLocationFilePathDoesNotMatch(object p0, object p1) - => string.Format(CultureInfo.CurrentCulture, GetString("SourceLocationFilePathDoesNotMatch"), p0, p1); - - /// - /// <<unknown>> - /// - internal static string Symbol_Unknown - { - get => GetString("Symbol_Unknown"); - } - - /// - /// <<unknown>> - /// - internal static string FormatSymbol_Unknown() - => GetString("Symbol_Unknown"); - - /// - /// The tag helper attribute '{0}' in element '{1}' is missing a key. The syntax is '<{1} {0}{{ key }}="value">'. - /// - internal static string TagHelperBlockRewriter_IndexerAttributeNameMustIncludeKey - { - get => GetString("TagHelperBlockRewriter_IndexerAttributeNameMustIncludeKey"); - } - - /// - /// The tag helper attribute '{0}' in element '{1}' is missing a key. The syntax is '<{1} {0}{{ key }}="value">'. - /// - internal static string FormatTagHelperBlockRewriter_IndexerAttributeNameMustIncludeKey(object p0, object p1) - => string.Format(CultureInfo.CurrentCulture, GetString("TagHelperBlockRewriter_IndexerAttributeNameMustIncludeKey"), p0, p1); - - /// - /// TagHelper attributes must be well-formed. - /// - internal static string TagHelperBlockRewriter_TagHelperAttributeListMustBeWellFormed - { - get => GetString("TagHelperBlockRewriter_TagHelperAttributeListMustBeWellFormed"); - } - - /// - /// TagHelper attributes must be well-formed. - /// - internal static string FormatTagHelperBlockRewriter_TagHelperAttributeListMustBeWellFormed() - => GetString("TagHelperBlockRewriter_TagHelperAttributeListMustBeWellFormed"); - - /// - /// The parent <{0}> tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) '{1}' are allowed. - /// - internal static string TagHelperParseTreeRewriter_CannotHaveNonTagContent - { - get => GetString("TagHelperParseTreeRewriter_CannotHaveNonTagContent"); - } - - /// - /// The parent <{0}> tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) '{1}' are allowed. - /// - internal static string FormatTagHelperParseTreeRewriter_CannotHaveNonTagContent(object p0, object p1) - => string.Format(CultureInfo.CurrentCulture, GetString("TagHelperParseTreeRewriter_CannotHaveNonTagContent"), p0, p1); - - /// - /// Found an end tag (</{0}>) for tag helper '{1}' with tag structure that disallows an end tag ('{2}'). - /// - internal static string TagHelperParseTreeRewriter_EndTagTagHelperMustNotHaveAnEndTag - { - get => GetString("TagHelperParseTreeRewriter_EndTagTagHelperMustNotHaveAnEndTag"); - } - - /// - /// Found an end tag (</{0}>) for tag helper '{1}' with tag structure that disallows an end tag ('{2}'). - /// - internal static string FormatTagHelperParseTreeRewriter_EndTagTagHelperMustNotHaveAnEndTag(object p0, object p1, object p2) - => string.Format(CultureInfo.CurrentCulture, GetString("TagHelperParseTreeRewriter_EndTagTagHelperMustNotHaveAnEndTag"), p0, p1, p2); - - /// - /// Tag helpers '{0}' and '{1}' targeting element '{2}' must not expect different {3} values. - /// - internal static string TagHelperParseTreeRewriter_InconsistentTagStructure - { - get => GetString("TagHelperParseTreeRewriter_InconsistentTagStructure"); - } - - /// - /// Tag helpers '{0}' and '{1}' targeting element '{2}' must not expect different {3} values. - /// - internal static string FormatTagHelperParseTreeRewriter_InconsistentTagStructure(object p0, object p1, object p2, object p3) - => string.Format(CultureInfo.CurrentCulture, GetString("TagHelperParseTreeRewriter_InconsistentTagStructure"), p0, p1, p2, p3); - - /// - /// The <{0}> tag is not allowed by parent <{1}> tag helper. Only child tags with name(s) '{2}' are allowed. - /// - internal static string TagHelperParseTreeRewriter_InvalidNestedTag - { - get => GetString("TagHelperParseTreeRewriter_InvalidNestedTag"); - } - - /// - /// The <{0}> tag is not allowed by parent <{1}> tag helper. Only child tags with name(s) '{2}' are allowed. - /// - internal static string FormatTagHelperParseTreeRewriter_InvalidNestedTag(object p0, object p1, object p2) - => string.Format(CultureInfo.CurrentCulture, GetString("TagHelperParseTreeRewriter_InvalidNestedTag"), p0, p1, p2); - - /// - /// Found a malformed '{0}' tag helper. Tag helpers must have a start and end tag or be self closing. - /// - internal static string TagHelpersParseTreeRewriter_FoundMalformedTagHelper - { - get => GetString("TagHelpersParseTreeRewriter_FoundMalformedTagHelper"); - } - - /// - /// Found a malformed '{0}' tag helper. Tag helpers must have a start and end tag or be self closing. - /// - internal static string FormatTagHelpersParseTreeRewriter_FoundMalformedTagHelper(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("TagHelpersParseTreeRewriter_FoundMalformedTagHelper"), p0); - - /// - /// Missing close angle for tag helper '{0}'. - /// - internal static string TagHelpersParseTreeRewriter_MissingCloseAngle - { - get => GetString("TagHelpersParseTreeRewriter_MissingCloseAngle"); - } - - /// - /// Missing close angle for tag helper '{0}'. - /// - internal static string FormatTagHelpersParseTreeRewriter_MissingCloseAngle(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("TagHelpersParseTreeRewriter_MissingCloseAngle"), p0); - - /// - /// Tag Helper '{0}'s attributes must have names. - /// - internal static string TagHelpers_AttributesMustHaveAName - { - get => GetString("TagHelpers_AttributesMustHaveAName"); - } - - /// - /// Tag Helper '{0}'s attributes must have names. - /// - internal static string FormatTagHelpers_AttributesMustHaveAName(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("TagHelpers_AttributesMustHaveAName"), p0); - - /// - /// The tag helper '{0}' must not have C# in the element's attribute declaration area. - /// - internal static string TagHelpers_CannotHaveCSharpInTagDeclaration - { - get => GetString("TagHelpers_CannotHaveCSharpInTagDeclaration"); - } - - /// - /// The tag helper '{0}' must not have C# in the element's attribute declaration area. - /// - internal static string FormatTagHelpers_CannotHaveCSharpInTagDeclaration(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("TagHelpers_CannotHaveCSharpInTagDeclaration"), p0); - - /// - /// Code blocks (e.g. @{{var variable = 23;}}) must not appear in non-string tag helper attribute values. - /// Already in an expression (code) context. If necessary an explicit expression (e.g. @(@readonly)) may be used. - /// - internal static string TagHelpers_CodeBlocks_NotSupported_InAttributes - { - get => GetString("TagHelpers_CodeBlocks_NotSupported_InAttributes"); - } - - /// - /// Code blocks (e.g. @{{var variable = 23;}}) must not appear in non-string tag helper attribute values. - /// Already in an expression (code) context. If necessary an explicit expression (e.g. @(@readonly)) may be used. - /// - internal static string FormatTagHelpers_CodeBlocks_NotSupported_InAttributes() - => GetString("TagHelpers_CodeBlocks_NotSupported_InAttributes"); - - /// - /// Inline markup blocks (e.g. @<p>content</p>) must not appear in non-string tag helper attribute values. - /// Expected a '{0}' attribute value, not a string. - /// - internal static string TagHelpers_InlineMarkupBlocks_NotSupported_InAttributes - { - get => GetString("TagHelpers_InlineMarkupBlocks_NotSupported_InAttributes"); - } - - /// - /// Inline markup blocks (e.g. @<p>content</p>) must not appear in non-string tag helper attribute values. - /// Expected a '{0}' attribute value, not a string. - /// - internal static string FormatTagHelpers_InlineMarkupBlocks_NotSupported_InAttributes(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("TagHelpers_InlineMarkupBlocks_NotSupported_InAttributes"), p0); - - /// - /// In order to put a symbol back, it must have been the symbol which ended at the current position. The specified symbol ends at {0}, but the current position is {1} - /// - internal static string TokenizerView_CannotPutBack - { - get => GetString("TokenizerView_CannotPutBack"); - } - - /// - /// In order to put a symbol back, it must have been the symbol which ended at the current position. The specified symbol ends at {0}, but the current position is {1} - /// - internal static string FormatTokenizerView_CannotPutBack(object p0, object p1) - => string.Format(CultureInfo.CurrentCulture, GetString("TokenizerView_CannotPutBack"), p0, p1); - - /// - /// Unexpected literal following the '{0}' directive. Expected '{1}'. - /// - internal static string UnexpectedDirectiveLiteral - { - get => GetString("UnexpectedDirectiveLiteral"); - } - - /// - /// Unexpected literal following the '{0}' directive. Expected '{1}'. - /// - internal static string FormatUnexpectedDirectiveLiteral(object p0, object p1) - => string.Format(CultureInfo.CurrentCulture, GetString("UnexpectedDirectiveLiteral"), p0, p1); - - /// - /// Unexpected end of file following the '{0}' directive. Expected '{1}'. - /// - internal static string UnexpectedEOFAfterDirective - { - get => GetString("UnexpectedEOFAfterDirective"); - } - - /// - /// Unexpected end of file following the '{0}' directive. Expected '{1}'. - /// - internal static string FormatUnexpectedEOFAfterDirective(object p0, object p1) - => string.Format(CultureInfo.CurrentCulture, GetString("UnexpectedEOFAfterDirective"), p0, p1); - - private static string GetString(string name, params string[] formatterNames) - { - var value = _resourceManager.GetString(name); - - System.Diagnostics.Debug.Assert(value != null); - - if (formatterNames != null) - { - for (var i = 0; i < formatterNames.Length; i++) - { - value = value.Replace("{" + formatterNames[i] + "}", "{" + i + "}"); - } - } - - return value; - } - } -} diff --git a/src/Microsoft.AspNetCore.Razor.Language/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Razor.Language/Properties/Resources.Designer.cs index 1f95e0176c..a785a39bca 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Properties/Resources.Designer.cs @@ -10,6 +10,48 @@ namespace Microsoft.AspNetCore.Razor.Language private static readonly ResourceManager _resourceManager = new ResourceManager("Microsoft.AspNetCore.Razor.Language.Resources", typeof(Resources).GetTypeInfo().Assembly); + /// + /// Register Tag Helpers for use in the current document. + /// + internal static string AddTagHelperDirective_Description + { + get => GetString("AddTagHelperDirective_Description"); + } + + /// + /// Register Tag Helpers for use in the current document. + /// + internal static string FormatAddTagHelperDirective_Description() + => GetString("AddTagHelperDirective_Description"); + + /// + /// Add tag helpers from the specified type name and assembly name. Specify '*' for the type name to include all tag helper types from the specified assembly. + /// + internal static string AddTagHelperDirective_StringToken_Description + { + get => GetString("AddTagHelperDirective_StringToken_Description"); + } + + /// + /// Add tag helpers from the specified type name and assembly name. Specify '*' for the type name to include all tag helper types from the specified assembly. + /// + internal static string FormatAddTagHelperDirective_StringToken_Description() + => GetString("AddTagHelperDirective_StringToken_Description"); + + /// + /// TypeName, AssemblyName + /// + internal static string AddTagHelperDirective_StringToken_Name + { + get => GetString("AddTagHelperDirective_StringToken_Name"); + } + + /// + /// TypeName, AssemblyName + /// + internal static string FormatAddTagHelperDirective_StringToken_Name() + => GetString("AddTagHelperDirective_StringToken_Name"); + /// /// Value cannot be null or an empty string. /// @@ -24,6 +66,384 @@ namespace Microsoft.AspNetCore.Razor.Language internal static string FormatArgumentCannotBeNullOrEmpty() => GetString("ArgumentCannotBeNullOrEmpty"); + /// + /// Block cannot be built because a Type has not been specified in the BlockBuilder + /// + internal static string Block_Type_Not_Specified + { + get => GetString("Block_Type_Not_Specified"); + } + + /// + /// Block cannot be built because a Type has not been specified in the BlockBuilder + /// + internal static string FormatBlock_Type_Not_Specified() + => GetString("Block_Type_Not_Specified"); + + /// + /// Block directive '{0}' cannot be imported. + /// + internal static string BlockDirectiveCannotBeImported + { + get => GetString("BlockDirectiveCannotBeImported"); + } + + /// + /// Block directive '{0}' cannot be imported. + /// + internal static string FormatBlockDirectiveCannotBeImported(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("BlockDirectiveCannotBeImported"), p0); + + /// + /// code + /// + internal static string BlockName_Code + { + get => GetString("BlockName_Code"); + } + + /// + /// code + /// + internal static string FormatBlockName_Code() + => GetString("BlockName_Code"); + + /// + /// explicit expression + /// + internal static string BlockName_ExplicitExpression + { + get => GetString("BlockName_ExplicitExpression"); + } + + /// + /// explicit expression + /// + internal static string FormatBlockName_ExplicitExpression() + => GetString("BlockName_ExplicitExpression"); + + /// + /// Invalid newline sequence '{0}'. Support newline sequences are '\r\n' and '\n'. + /// + internal static string CodeWriter_InvalidNewLine + { + get => GetString("CodeWriter_InvalidNewLine"); + } + + /// + /// Invalid newline sequence '{0}'. Support newline sequences are '\r\n' and '\n'. + /// + internal static string FormatCodeWriter_InvalidNewLine(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("CodeWriter_InvalidNewLine"), p0); + + /// + /// <<character literal>> + /// + internal static string CSharpSymbol_CharacterLiteral + { + get => GetString("CSharpSymbol_CharacterLiteral"); + } + + /// + /// <<character literal>> + /// + internal static string FormatCSharpSymbol_CharacterLiteral() + => GetString("CSharpSymbol_CharacterLiteral"); + + /// + /// <<comment>> + /// + internal static string CSharpSymbol_Comment + { + get => GetString("CSharpSymbol_Comment"); + } + + /// + /// <<comment>> + /// + internal static string FormatCSharpSymbol_Comment() + => GetString("CSharpSymbol_Comment"); + + /// + /// <<identifier>> + /// + internal static string CSharpSymbol_Identifier + { + get => GetString("CSharpSymbol_Identifier"); + } + + /// + /// <<identifier>> + /// + internal static string FormatCSharpSymbol_Identifier() + => GetString("CSharpSymbol_Identifier"); + + /// + /// <<integer literal>> + /// + internal static string CSharpSymbol_IntegerLiteral + { + get => GetString("CSharpSymbol_IntegerLiteral"); + } + + /// + /// <<integer literal>> + /// + internal static string FormatCSharpSymbol_IntegerLiteral() + => GetString("CSharpSymbol_IntegerLiteral"); + + /// + /// <<keyword>> + /// + internal static string CSharpSymbol_Keyword + { + get => GetString("CSharpSymbol_Keyword"); + } + + /// + /// <<keyword>> + /// + internal static string FormatCSharpSymbol_Keyword() + => GetString("CSharpSymbol_Keyword"); + + /// + /// <<newline sequence>> + /// + internal static string CSharpSymbol_Newline + { + get => GetString("CSharpSymbol_Newline"); + } + + /// + /// <<newline sequence>> + /// + internal static string FormatCSharpSymbol_Newline() + => GetString("CSharpSymbol_Newline"); + + /// + /// <<real literal>> + /// + internal static string CSharpSymbol_RealLiteral + { + get => GetString("CSharpSymbol_RealLiteral"); + } + + /// + /// <<real literal>> + /// + internal static string FormatCSharpSymbol_RealLiteral() + => GetString("CSharpSymbol_RealLiteral"); + + /// + /// <<string literal>> + /// + internal static string CSharpSymbol_StringLiteral + { + get => GetString("CSharpSymbol_StringLiteral"); + } + + /// + /// <<string literal>> + /// + internal static string FormatCSharpSymbol_StringLiteral() + => GetString("CSharpSymbol_StringLiteral"); + + /// + /// <<white space>> + /// + internal static string CSharpSymbol_Whitespace + { + get => GetString("CSharpSymbol_Whitespace"); + } + + /// + /// <<white space>> + /// + internal static string FormatCSharpSymbol_Whitespace() + => GetString("CSharpSymbol_Whitespace"); + + /// + /// The document type '{0}' does not support the extension '{1}'. + /// + internal static string Diagnostic_CodeTarget_UnsupportedExtension + { + get => GetString("Diagnostic_CodeTarget_UnsupportedExtension"); + } + + /// + /// The document type '{0}' does not support the extension '{1}'. + /// + internal static string FormatDiagnostic_CodeTarget_UnsupportedExtension(object p0, object p1) + => string.Format(CultureInfo.CurrentCulture, GetString("Diagnostic_CodeTarget_UnsupportedExtension"), p0, p1); + + /// + /// Invalid directive keyword '{0}'. Directives must have a non-empty keyword that consists only of letters. + /// + internal static string DirectiveDescriptor_InvalidDirectiveKeyword + { + get => GetString("DirectiveDescriptor_InvalidDirectiveKeyword"); + } + + /// + /// Invalid directive keyword '{0}'. Directives must have a non-empty keyword that consists only of letters. + /// + internal static string FormatDirectiveDescriptor_InvalidDirectiveKeyword(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("DirectiveDescriptor_InvalidDirectiveKeyword"), p0); + + /// + /// A non-optional directive token cannot follow an optional directive token. + /// + internal static string DirectiveDescriptor_InvalidNonOptionalToken + { + get => GetString("DirectiveDescriptor_InvalidNonOptionalToken"); + } + + /// + /// A non-optional directive token cannot follow an optional directive token. + /// + internal static string FormatDirectiveDescriptor_InvalidNonOptionalToken() + => GetString("DirectiveDescriptor_InvalidNonOptionalToken"); + + /// + /// The '{0}' directive expects an identifier. + /// + internal static string DirectiveExpectsIdentifier + { + get => GetString("DirectiveExpectsIdentifier"); + } + + /// + /// The '{0}' directive expects an identifier. + /// + internal static string FormatDirectiveExpectsIdentifier(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("DirectiveExpectsIdentifier"), p0); + + /// + /// The '{0}' directive expects a namespace name. + /// + internal static string DirectiveExpectsNamespace + { + get => GetString("DirectiveExpectsNamespace"); + } + + /// + /// The '{0}' directive expects a namespace name. + /// + internal static string FormatDirectiveExpectsNamespace(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("DirectiveExpectsNamespace"), p0); + + /// + /// The '{0}' directive expects a string surrounded by double quotes. + /// + internal static string DirectiveExpectsQuotedStringLiteral + { + get => GetString("DirectiveExpectsQuotedStringLiteral"); + } + + /// + /// The '{0}' directive expects a string surrounded by double quotes. + /// + internal static string FormatDirectiveExpectsQuotedStringLiteral(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("DirectiveExpectsQuotedStringLiteral"), p0); + + /// + /// The '{0}' directive expects a type name. + /// + internal static string DirectiveExpectsTypeName + { + get => GetString("DirectiveExpectsTypeName"); + } + + /// + /// The '{0}' directive expects a type name. + /// + internal static string FormatDirectiveExpectsTypeName(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("DirectiveExpectsTypeName"), p0); + + /// + /// The '{0}` directive must appear at the start of the line. + /// + internal static string DirectiveMustAppearAtStartOfLine + { + get => GetString("DirectiveMustAppearAtStartOfLine"); + } + + /// + /// The '{0}` directive must appear at the start of the line. + /// + internal static string FormatDirectiveMustAppearAtStartOfLine(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("DirectiveMustAppearAtStartOfLine"), p0); + + /// + /// The '{0}' directives value(s) must be separated by whitespace. + /// + internal static string DirectiveTokensMustBeSeparatedByWhitespace + { + get => GetString("DirectiveTokensMustBeSeparatedByWhitespace"); + } + + /// + /// The '{0}' directives value(s) must be separated by whitespace. + /// + internal static string FormatDirectiveTokensMustBeSeparatedByWhitespace(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("DirectiveTokensMustBeSeparatedByWhitespace"), p0); + + /// + /// The document of kind '{0}' does not have a '{1}'. The document classifier must set a value for '{2}'. + /// + internal static string DocumentMissingTarget + { + get => GetString("DocumentMissingTarget"); + } + + /// + /// The document of kind '{0}' does not have a '{1}'. The document classifier must set a value for '{2}'. + /// + internal static string FormatDocumentMissingTarget(object p0, object p1, object p2) + => string.Format(CultureInfo.CurrentCulture, GetString("DocumentMissingTarget"), p0, p1, p2); + + /// + /// The '{0}' directive may only occur once per document. + /// + internal static string DuplicateDirective + { + get => GetString("DuplicateDirective"); + } + + /// + /// The '{0}' directive may only occur once per document. + /// + internal static string FormatDuplicateDirective(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("DuplicateDirective"), p0); + + /// + /// "EndBlock" was called without a matching call to "StartBlock". + /// + internal static string EndBlock_Called_Without_Matching_StartBlock + { + get => GetString("EndBlock_Called_Without_Matching_StartBlock"); + } + + /// + /// "EndBlock" was called without a matching call to "StartBlock". + /// + internal static string FormatEndBlock_Called_Without_Matching_StartBlock() + => GetString("EndBlock_Called_Without_Matching_StartBlock"); + + /// + /// line break + /// + internal static string ErrorComponent_Newline + { + get => GetString("ErrorComponent_Newline"); + } + + /// + /// line break + /// + internal static string FormatErrorComponent_Newline() + => GetString("ErrorComponent_Newline"); + /// /// The '{0}' feature requires a '{1}' provided by the '{2}'. /// @@ -38,6 +458,216 @@ namespace Microsoft.AspNetCore.Razor.Language internal static string FormatFeatureDependencyMissing(object p0, object p1, object p2) => string.Format(CultureInfo.CurrentCulture, GetString("FeatureDependencyMissing"), p0, p1, p2); + /// + /// The feature must be initialized by setting the '{0}' property. + /// + internal static string FeatureMustBeInitialized + { + get => GetString("FeatureMustBeInitialized"); + } + + /// + /// The feature must be initialized by setting the '{0}' property. + /// + internal static string FormatFeatureMustBeInitialized(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("FeatureMustBeInitialized"), p0); + + /// + /// Specify a C# code block. + /// + internal static string FunctionsDirective_Description + { + get => GetString("FunctionsDirective_Description"); + } + + /// + /// Specify a C# code block. + /// + internal static string FormatFunctionsDirective_Description() + => GetString("FunctionsDirective_Description"); + + /// + /// <<newline sequence>> + /// + internal static string HtmlSymbol_NewLine + { + get => GetString("HtmlSymbol_NewLine"); + } + + /// + /// <<newline sequence>> + /// + internal static string FormatHtmlSymbol_NewLine() + => GetString("HtmlSymbol_NewLine"); + + /// + /// <<razor comment>> + /// + internal static string HtmlSymbol_RazorComment + { + get => GetString("HtmlSymbol_RazorComment"); + } + + /// + /// <<razor comment>> + /// + internal static string FormatHtmlSymbol_RazorComment() + => GetString("HtmlSymbol_RazorComment"); + + /// + /// <<text>> + /// + internal static string HtmlSymbol_Text + { + get => GetString("HtmlSymbol_Text"); + } + + /// + /// <<text>> + /// + internal static string FormatHtmlSymbol_Text() + => GetString("HtmlSymbol_Text"); + + /// + /// <<white space>> + /// + internal static string HtmlSymbol_WhiteSpace + { + get => GetString("HtmlSymbol_WhiteSpace"); + } + + /// + /// <<white space>> + /// + internal static string FormatHtmlSymbol_WhiteSpace() + => GetString("HtmlSymbol_WhiteSpace"); + + /// + /// Specify the base class for the current document. + /// + internal static string InheritsDirective_Description + { + get => GetString("InheritsDirective_Description"); + } + + /// + /// Specify the base class for the current document. + /// + internal static string FormatInheritsDirective_Description() + => GetString("InheritsDirective_Description"); + + /// + /// The base type that the current page inherits. + /// + internal static string InheritsDirective_TypeToken_Description + { + get => GetString("InheritsDirective_TypeToken_Description"); + } + + /// + /// The base type that the current page inherits. + /// + internal static string FormatInheritsDirective_TypeToken_Description() + => GetString("InheritsDirective_TypeToken_Description"); + + /// + /// TypeName + /// + internal static string InheritsDirective_TypeToken_Name + { + get => GetString("InheritsDirective_TypeToken_Name"); + } + + /// + /// TypeName + /// + internal static string FormatInheritsDirective_TypeToken_Name() + => GetString("InheritsDirective_TypeToken_Name"); + + /// + /// The '{0}' operation is not valid when the builder is empty. + /// + internal static string IntermediateNodeBuilder_PopInvalid + { + get => GetString("IntermediateNodeBuilder_PopInvalid"); + } + + /// + /// The '{0}' operation is not valid when the builder is empty. + /// + internal static string FormatIntermediateNodeBuilder_PopInvalid(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("IntermediateNodeBuilder_PopInvalid"), p0); + + /// + /// The node '{0}' has a read-only child collection and cannot be modified. + /// + internal static string IntermediateNodeReference_CollectionIsReadOnly + { + get => GetString("IntermediateNodeReference_CollectionIsReadOnly"); + } + + /// + /// The node '{0}' has a read-only child collection and cannot be modified. + /// + internal static string FormatIntermediateNodeReference_CollectionIsReadOnly(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("IntermediateNodeReference_CollectionIsReadOnly"), p0); + + /// + /// The reference is invalid. The node '{0}' could not be found as a child of '{1}'. + /// + internal static string IntermediateNodeReference_NodeNotFound + { + get => GetString("IntermediateNodeReference_NodeNotFound"); + } + + /// + /// The reference is invalid. The node '{0}' could not be found as a child of '{1}'. + /// + internal static string FormatIntermediateNodeReference_NodeNotFound(object p0, object p1) + => string.Format(CultureInfo.CurrentCulture, GetString("IntermediateNodeReference_NodeNotFound"), p0, p1); + + /// + /// The reference is invalid. References initialized with the default constructor cannot modify nodes. + /// + internal static string IntermediateNodeReference_NotInitialized + { + get => GetString("IntermediateNodeReference_NotInitialized"); + } + + /// + /// The reference is invalid. References initialized with the default constructor cannot modify nodes. + /// + internal static string FormatIntermediateNodeReference_NotInitialized() + => GetString("IntermediateNodeReference_NotInitialized"); + + /// + /// The '{0}' node type can only be used as a direct child of a '{1}' node. + /// + internal static string IntermediateNodes_InvalidParentNode + { + get => GetString("IntermediateNodes_InvalidParentNode"); + } + + /// + /// The '{0}' node type can only be used as a direct child of a '{1}' node. + /// + internal static string FormatIntermediateNodes_InvalidParentNode(object p0, object p1) + => string.Format(CultureInfo.CurrentCulture, GetString("IntermediateNodes_InvalidParentNode"), p0, p1); + + /// + /// The node '{0}' is not the owner of change '{1}'. + /// + internal static string InvalidOperation_SpanIsNotChangeOwner + { + get => GetString("InvalidOperation_SpanIsNotChangeOwner"); + } + + /// + /// The node '{0}' is not the owner of change '{1}'. + /// + internal static string FormatInvalidOperation_SpanIsNotChangeOwner(object p0, object p1) + => string.Format(CultureInfo.CurrentCulture, GetString("InvalidOperation_SpanIsNotChangeOwner"), p0, p1); + /// /// Invalid tag helper directive look up text '{0}'. The correct look up text format is: "name, assemblyName". /// @@ -67,18 +697,32 @@ namespace Microsoft.AspNetCore.Razor.Language => string.Format(CultureInfo.CurrentCulture, GetString("InvalidTagHelperPrefixValue"), p0, p1, p2); /// - /// The '{0}' operation is not valid when the builder is empty. + /// The key must not be null. /// - internal static string IntermediateNodeBuilder_PopInvalid + internal static string KeyMustNotBeNull { - get => GetString("IntermediateNodeBuilder_PopInvalid"); + get => GetString("KeyMustNotBeNull"); } /// - /// The '{0}' operation is not valid when the builder is empty. + /// The key must not be null. /// - internal static string FormatIntermediateNodeBuilder_PopInvalid(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("IntermediateNodeBuilder_PopInvalid"), p0); + internal static string FormatKeyMustNotBeNull() + => GetString("KeyMustNotBeNull"); + + /// + /// Cannot use built-in RazorComment handler, language characteristics does not define the CommentStart, CommentStar and CommentBody known symbol types or parser does not override TokenizerBackedParser.OutputSpanBeforeRazorComment + /// + internal static string Language_Does_Not_Support_RazorComment + { + get => GetString("Language_Does_Not_Support_RazorComment"); + } + + /// + /// Cannot use built-in RazorComment handler, language characteristics does not define the CommentStart, CommentStar and CommentBody known symbol types or parser does not override TokenizerBackedParser.OutputSpanBeforeRazorComment + /// + internal static string FormatLanguage_Does_Not_Support_RazorComment() + => GetString("Language_Does_Not_Support_RazorComment"); /// /// The specified encoding '{0}' does not match the content's encoding '{1}'. @@ -94,6 +738,434 @@ namespace Microsoft.AspNetCore.Razor.Language internal static string FormatMismatchedContentEncoding(object p0, object p1) => string.Format(CultureInfo.CurrentCulture, GetString("MismatchedContentEncoding"), p0, p1); + /// + /// The "@" character must be followed by a ":", "(", or a C# identifier. If you intended to switch to markup, use an HTML start tag, for example: + /// + /// @if(isLoggedIn) {{ + /// <p>Hello, @user!</p> + /// }} + /// + internal static string ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start + { + get => GetString("ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start"); + } + + /// + /// The "@" character must be followed by a ":", "(", or a C# identifier. If you intended to switch to markup, use an HTML start tag, for example: + /// + /// @if(isLoggedIn) {{ + /// <p>Hello, @user!</p> + /// }} + /// + internal static string FormatParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start() + => GetString("ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start"); + + /// + /// End of file was reached before the end of the block comment. All comments started with "/*" sequence must be terminated with a matching "*/" sequence. + /// + internal static string ParseError_BlockComment_Not_Terminated + { + get => GetString("ParseError_BlockComment_Not_Terminated"); + } + + /// + /// End of file was reached before the end of the block comment. All comments started with "/*" sequence must be terminated with a matching "*/" sequence. + /// + internal static string FormatParseError_BlockComment_Not_Terminated() + => GetString("ParseError_BlockComment_Not_Terminated"); + + /// + /// Directive '{0}' must have a value. + /// + internal static string ParseError_DirectiveMustHaveValue + { + get => GetString("ParseError_DirectiveMustHaveValue"); + } + + /// + /// Directive '{0}' must have a value. + /// + internal static string FormatParseError_DirectiveMustHaveValue(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_DirectiveMustHaveValue"), p0); + + /// + /// An opening "{0}" is missing the corresponding closing "{1}". + /// + internal static string ParseError_Expected_CloseBracket_Before_EOF + { + get => GetString("ParseError_Expected_CloseBracket_Before_EOF"); + } + + /// + /// An opening "{0}" is missing the corresponding closing "{1}". + /// + internal static string FormatParseError_Expected_CloseBracket_Before_EOF(object p0, object p1) + => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_Expected_CloseBracket_Before_EOF"), p0, p1); + + /// + /// The {0} block is missing a closing "{1}" character. Make sure you have a matching "{1}" character for all the "{2}" characters within this block, and that none of the "{1}" characters are being interpreted as markup. + /// + internal static string ParseError_Expected_EndOfBlock_Before_EOF + { + get => GetString("ParseError_Expected_EndOfBlock_Before_EOF"); + } + + /// + /// The {0} block is missing a closing "{1}" character. Make sure you have a matching "{1}" character for all the "{2}" characters within this block, and that none of the "{1}" characters are being interpreted as markup. + /// + internal static string FormatParseError_Expected_EndOfBlock_Before_EOF(object p0, object p1, object p2) + => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_Expected_EndOfBlock_Before_EOF"), p0, p1, p2); + + /// + /// The {0} directive is not supported. + /// + internal static string ParseError_HelperDirectiveNotAvailable + { + get => GetString("ParseError_HelperDirectiveNotAvailable"); + } + + /// + /// The {0} directive is not supported. + /// + internal static string FormatParseError_HelperDirectiveNotAvailable(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_HelperDirectiveNotAvailable"), p0); + + /// + /// Optional quote around the directive '{0}' is missing the corresponding opening or closing quote. + /// + internal static string ParseError_IncompleteQuotesAroundDirective + { + get => GetString("ParseError_IncompleteQuotesAroundDirective"); + } + + /// + /// Optional quote around the directive '{0}' is missing the corresponding opening or closing quote. + /// + internal static string FormatParseError_IncompleteQuotesAroundDirective(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_IncompleteQuotesAroundDirective"), p0); + + /// + /// Inline markup blocks (@<p>Content</p>) cannot be nested. Only one level of inline markup is allowed. + /// + internal static string ParseError_InlineMarkup_Blocks_Cannot_Be_Nested + { + get => GetString("ParseError_InlineMarkup_Blocks_Cannot_Be_Nested"); + } + + /// + /// Inline markup blocks (@<p>Content</p>) cannot be nested. Only one level of inline markup is allowed. + /// + internal static string FormatParseError_InlineMarkup_Blocks_Cannot_Be_Nested() + => GetString("ParseError_InlineMarkup_Blocks_Cannot_Be_Nested"); + + /// + /// Markup in a code block must start with a tag and all start tags must be matched with end tags. Do not use unclosed tags like "<br>". Instead use self-closing tags like "<br/>". + /// + internal static string ParseError_MarkupBlock_Must_Start_With_Tag + { + get => GetString("ParseError_MarkupBlock_Must_Start_With_Tag"); + } + + /// + /// Markup in a code block must start with a tag and all start tags must be matched with end tags. Do not use unclosed tags like "<br>". Instead use self-closing tags like "<br/>". + /// + internal static string FormatParseError_MarkupBlock_Must_Start_With_Tag() + => GetString("ParseError_MarkupBlock_Must_Start_With_Tag"); + + /// + /// The "{0}" element was not closed. All elements must be either self-closing or have a matching end tag. + /// + internal static string ParseError_MissingEndTag + { + get => GetString("ParseError_MissingEndTag"); + } + + /// + /// The "{0}" element was not closed. All elements must be either self-closing or have a matching end tag. + /// + internal static string FormatParseError_MissingEndTag(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_MissingEndTag"), p0); + + /// + /// Namespace imports and type aliases cannot be placed within code blocks. They must immediately follow an "@" character in markup. It is recommended that you put them at the top of the page, as in the following example: + /// + /// @using System.Drawing; + /// @{{ + /// // OK here to use types from System.Drawing in the page. + /// }} + /// + internal static string ParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock + { + get => GetString("ParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock"); + } + + /// + /// Namespace imports and type aliases cannot be placed within code blocks. They must immediately follow an "@" character in markup. It is recommended that you put them at the top of the page, as in the following example: + /// + /// @using System.Drawing; + /// @{{ + /// // OK here to use types from System.Drawing in the page. + /// }} + /// + internal static string FormatParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock() + => GetString("ParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock"); + + /// + /// Outer tag is missing a name. The first character of a markup block must be an HTML tag with a valid name. + /// + internal static string ParseError_OuterTagMissingName + { + get => GetString("ParseError_OuterTagMissingName"); + } + + /// + /// Outer tag is missing a name. The first character of a markup block must be an HTML tag with a valid name. + /// + internal static string FormatParseError_OuterTagMissingName() + => GetString("ParseError_OuterTagMissingName"); + + /// + /// End of file was reached before the end of the block comment. All comments that start with the "@*" sequence must be terminated with a matching "*@" sequence. + /// + internal static string ParseError_RazorComment_Not_Terminated + { + get => GetString("ParseError_RazorComment_Not_Terminated"); + } + + /// + /// End of file was reached before the end of the block comment. All comments that start with the "@*" sequence must be terminated with a matching "*@" sequence. + /// + internal static string FormatParseError_RazorComment_Not_Terminated() + => GetString("ParseError_RazorComment_Not_Terminated"); + + /// + /// "{0}" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. + /// + internal static string ParseError_ReservedWord + { + get => GetString("ParseError_ReservedWord"); + } + + /// + /// "{0}" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. + /// + internal static string FormatParseError_ReservedWord(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_ReservedWord"), p0); + + /// + /// Section blocks ("{0}") cannot be nested. Only one level of section blocks are allowed. + /// + internal static string ParseError_Sections_Cannot_Be_Nested + { + get => GetString("ParseError_Sections_Cannot_Be_Nested"); + } + + /// + /// Section blocks ("{0}") cannot be nested. Only one level of section blocks are allowed. + /// + internal static string FormatParseError_Sections_Cannot_Be_Nested(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_Sections_Cannot_Be_Nested"), p0); + + /// + /// Expected a "{0}" but found a "{1}". Block statements must be enclosed in "{{" and "}}". You cannot use single-statement control-flow statements in CSHTML pages. For example, the following is not allowed: + /// + /// @if(isLoggedIn) + /// <p>Hello, @user</p> + /// + /// Instead, wrap the contents of the block in "{{}}": + /// + /// @if(isLoggedIn) {{ + /// <p>Hello, @user</p> + /// }} + /// + internal static string ParseError_SingleLine_ControlFlowStatements_Not_Allowed + { + get => GetString("ParseError_SingleLine_ControlFlowStatements_Not_Allowed"); + } + + /// + /// Expected a "{0}" but found a "{1}". Block statements must be enclosed in "{{" and "}}". You cannot use single-statement control-flow statements in CSHTML pages. For example, the following is not allowed: + /// + /// @if(isLoggedIn) + /// <p>Hello, @user</p> + /// + /// Instead, wrap the contents of the block in "{{}}": + /// + /// @if(isLoggedIn) {{ + /// <p>Hello, @user</p> + /// }} + /// + internal static string FormatParseError_SingleLine_ControlFlowStatements_Not_Allowed(object p0, object p1) + => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_SingleLine_ControlFlowStatements_Not_Allowed"), p0, p1); + + /// + /// "<text>" and "</text>" tags cannot contain attributes. + /// + internal static string ParseError_TextTagCannotContainAttributes + { + get => GetString("ParseError_TextTagCannotContainAttributes"); + } + + /// + /// "<text>" and "</text>" tags cannot contain attributes. + /// + internal static string FormatParseError_TextTagCannotContainAttributes() + => GetString("ParseError_TextTagCannotContainAttributes"); + + /// + /// "{0}" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{{" are valid. + /// + internal static string ParseError_Unexpected_Character_At_Start_Of_CodeBlock + { + get => GetString("ParseError_Unexpected_Character_At_Start_Of_CodeBlock"); + } + + /// + /// "{0}" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{{" are valid. + /// + internal static string FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_Unexpected_Character_At_Start_Of_CodeBlock"), p0); + + /// + /// End-of-file was found after the "@" character. "@" must be followed by a valid code block. If you want to output an "@", escape it using the sequence: "@@" + /// + internal static string ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock + { + get => GetString("ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock"); + } + + /// + /// End-of-file was found after the "@" character. "@" must be followed by a valid code block. If you want to output an "@", escape it using the sequence: "@@" + /// + internal static string FormatParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock() + => GetString("ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock"); + + /// + /// Unexpected "{{" after "@" character. Once inside the body of a code block (@if {{}}, @{{}}, etc.) you do not need to use "@{{" to switch to code. + /// + internal static string ParseError_Unexpected_Nested_CodeBlock + { + get => GetString("ParseError_Unexpected_Nested_CodeBlock"); + } + + /// + /// Unexpected "{{" after "@" character. Once inside the body of a code block (@if {{}}, @{{}}, etc.) you do not need to use "@{{" to switch to code. + /// + internal static string FormatParseError_Unexpected_Nested_CodeBlock() + => GetString("ParseError_Unexpected_Nested_CodeBlock"); + + /// + /// A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{{" are valid at the start of a code block and they must occur immediately following "@" with no space in between. + /// + internal static string ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock + { + get => GetString("ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock"); + } + + /// + /// A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{{" are valid at the start of a code block and they must occur immediately following "@" with no space in between. + /// + internal static string FormatParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock() + => GetString("ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock"); + + /// + /// Encountered end tag "{0}" with no matching start tag. Are your start/end tags properly balanced? + /// + internal static string ParseError_UnexpectedEndTag + { + get => GetString("ParseError_UnexpectedEndTag"); + } + + /// + /// Encountered end tag "{0}" with no matching start tag. Are your start/end tags properly balanced? + /// + internal static string FormatParseError_UnexpectedEndTag(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_UnexpectedEndTag"), p0); + + /// + /// End of file or an unexpected character was reached before the "{0}" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("<br />") or have matching end tags ("<p>Hello</p>"). If you intended to display a "<" character, use the "&lt;" HTML entity. + /// + internal static string ParseError_UnfinishedTag + { + get => GetString("ParseError_UnfinishedTag"); + } + + /// + /// End of file or an unexpected character was reached before the "{0}" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("<br />") or have matching end tags ("<p>Hello</p>"). If you intended to display a "<" character, use the "&lt;" HTML entity. + /// + internal static string FormatParseError_UnfinishedTag(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_UnfinishedTag"), p0); + + /// + /// Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. + /// + internal static string ParseError_Unterminated_String_Literal + { + get => GetString("ParseError_Unterminated_String_Literal"); + } + + /// + /// Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. + /// + internal static string FormatParseError_Unterminated_String_Literal() + => GetString("ParseError_Unterminated_String_Literal"); + + /// + /// Parser was started with a null Context property. The Context property must be set BEFORE calling any methods on the parser. + /// + internal static string Parser_Context_Not_Set + { + get => GetString("Parser_Context_Not_Set"); + } + + /// + /// Parser was started with a null Context property. The Context property must be set BEFORE calling any methods on the parser. + /// + internal static string FormatParser_Context_Not_Set() + => GetString("Parser_Context_Not_Set"); + + /// + /// Cannot complete the tree, StartBlock must be called at least once. + /// + internal static string ParserContext_CannotCompleteTree_NoRootBlock + { + get => GetString("ParserContext_CannotCompleteTree_NoRootBlock"); + } + + /// + /// Cannot complete the tree, StartBlock must be called at least once. + /// + internal static string FormatParserContext_CannotCompleteTree_NoRootBlock() + => GetString("ParserContext_CannotCompleteTree_NoRootBlock"); + + /// + /// Cannot complete the tree, there are still open blocks. + /// + internal static string ParserContext_CannotCompleteTree_OutstandingBlocks + { + get => GetString("ParserContext_CannotCompleteTree_OutstandingBlocks"); + } + + /// + /// Cannot complete the tree, there are still open blocks. + /// + internal static string FormatParserContext_CannotCompleteTree_OutstandingBlocks() + => GetString("ParserContext_CannotCompleteTree_OutstandingBlocks"); + + /// + /// Cannot finish span, there is no current block. Call StartBlock at least once before finishing a span + /// + internal static string ParserContext_NoCurrentBlock + { + get => GetString("ParserContext_NoCurrentBlock"); + } + + /// + /// Cannot finish span, there is no current block. Call StartBlock at least once before finishing a span + /// + internal static string FormatParserContext_NoCurrentBlock() + => GetString("ParserContext_NoCurrentBlock"); + /// /// The '{0}' phase requires a '{1}' provided by the '{2}'. /// @@ -122,20 +1194,6 @@ namespace Microsoft.AspNetCore.Razor.Language internal static string FormatPhaseMustBeInitialized(object p0) => string.Format(CultureInfo.CurrentCulture, GetString("PhaseMustBeInitialized"), p0); - /// - /// Tag helper directive assembly name cannot be null or empty. - /// - internal static string TagHelperAssemblyNameCannotBeEmptyOrNull - { - get => GetString("TagHelperAssemblyNameCannotBeEmptyOrNull"); - } - - /// - /// Tag helper directive assembly name cannot be null or empty. - /// - internal static string FormatTagHelperAssemblyNameCannotBeEmptyOrNull() - => GetString("TagHelperAssemblyNameCannotBeEmptyOrNull"); - /// /// Path must begin with a forward slash '/'. /// @@ -150,34 +1208,6 @@ namespace Microsoft.AspNetCore.Razor.Language internal static string FormatRazorProject_PathMustStartWithForwardSlash() => GetString("RazorProject_PathMustStartWithForwardSlash"); - /// - /// A non-optional directive token cannot follow an optional directive token. - /// - internal static string DirectiveDescriptor_InvalidNonOptionalToken - { - get => GetString("DirectiveDescriptor_InvalidNonOptionalToken"); - } - - /// - /// A non-optional directive token cannot follow an optional directive token. - /// - internal static string FormatDirectiveDescriptor_InvalidNonOptionalToken() - => GetString("DirectiveDescriptor_InvalidNonOptionalToken"); - - /// - /// The document of kind '{0}' does not have a '{1}'. The document classifier must set a value for '{2}'. - /// - internal static string DocumentMissingTarget - { - get => GetString("DocumentMissingTarget"); - } - - /// - /// The document of kind '{0}' does not have a '{1}'. The document classifier must set a value for '{2}'. - /// - internal static string FormatDocumentMissingTarget(object p0, object p1, object p2) - => string.Format(CultureInfo.CurrentCulture, GetString("DocumentMissingTarget"), p0, p1, p2); - /// /// The item '{0}' could not be found. /// @@ -192,6 +1222,146 @@ namespace Microsoft.AspNetCore.Razor.Language internal static string FormatRazorTemplateEngine_ItemCouldNotBeFound(object p0) => string.Format(CultureInfo.CurrentCulture, GetString("RazorTemplateEngine_ItemCouldNotBeFound"), p0); + /// + /// Remove Tag Helpers for use in the current document. + /// + internal static string RemoveTagHelperDirective_Description + { + get => GetString("RemoveTagHelperDirective_Description"); + } + + /// + /// Remove Tag Helpers for use in the current document. + /// + internal static string FormatRemoveTagHelperDirective_Description() + => GetString("RemoveTagHelperDirective_Description"); + + /// + /// Remove tag helpers from the specified type name and assembly name. Specify '*' for the type name to remove all tag helper types from the specified assembly. + /// + internal static string RemoveTagHelperDirective_StringToken_Description + { + get => GetString("RemoveTagHelperDirective_StringToken_Description"); + } + + /// + /// Remove tag helpers from the specified type name and assembly name. Specify '*' for the type name to remove all tag helper types from the specified assembly. + /// + internal static string FormatRemoveTagHelperDirective_StringToken_Description() + => GetString("RemoveTagHelperDirective_StringToken_Description"); + + /// + /// TypeName, AssemblyName + /// + internal static string RemoveTagHelperDirective_StringToken_Name + { + get => GetString("RemoveTagHelperDirective_StringToken_Name"); + } + + /// + /// TypeName, AssemblyName + /// + internal static string FormatRemoveTagHelperDirective_StringToken_Name() + => GetString("RemoveTagHelperDirective_StringToken_Name"); + + /// + /// The '{0}' requires a '{1}' delegate to be set. + /// + internal static string RenderingContextRequiresDelegate + { + get => GetString("RenderingContextRequiresDelegate"); + } + + /// + /// The '{0}' requires a '{1}' delegate to be set. + /// + internal static string FormatRenderingContextRequiresDelegate(object p0, object p1) + => string.Format(CultureInfo.CurrentCulture, GetString("RenderingContextRequiresDelegate"), p0, p1); + + /// + /// Attribute '{0}' on tag helper element '{1}' requires a value. Tag helper bound attributes of type '{2}' cannot be empty or contain only whitespace. + /// + internal static string RewriterError_EmptyTagHelperBoundAttribute + { + get => GetString("RewriterError_EmptyTagHelperBoundAttribute"); + } + + /// + /// Attribute '{0}' on tag helper element '{1}' requires a value. Tag helper bound attributes of type '{2}' cannot be empty or contain only whitespace. + /// + internal static string FormatRewriterError_EmptyTagHelperBoundAttribute(object p0, object p1, object p2) + => string.Format(CultureInfo.CurrentCulture, GetString("RewriterError_EmptyTagHelperBoundAttribute"), p0, p1, p2); + + /// + /// Define a section to be rendered in the configured layout page. + /// + internal static string SectionDirective_Description + { + get => GetString("SectionDirective_Description"); + } + + /// + /// Define a section to be rendered in the configured layout page. + /// + internal static string FormatSectionDirective_Description() + => GetString("SectionDirective_Description"); + + /// + /// The name of the section. + /// + internal static string SectionDirective_NameToken_Description + { + get => GetString("SectionDirective_NameToken_Description"); + } + + /// + /// The name of the section. + /// + internal static string FormatSectionDirective_NameToken_Description() + => GetString("SectionDirective_NameToken_Description"); + + /// + /// SectionName + /// + internal static string SectionDirective_NameToken_Name + { + get => GetString("SectionDirective_NameToken_Name"); + } + + /// + /// SectionName + /// + internal static string FormatSectionDirective_NameToken_Name() + => GetString("SectionDirective_NameToken_Name"); + + /// + /// @section Header { ... } + /// + internal static string SectionExample + { + get => GetString("SectionExample"); + } + + /// + /// @section Header { ... } + /// + internal static string FormatSectionExample() + => GetString("SectionExample"); + + /// + /// <<unknown>> + /// + internal static string Symbol_Unknown + { + get => GetString("Symbol_Unknown"); + } + + /// + /// <<unknown>> + /// + internal static string FormatSymbol_Unknown() + => GetString("Symbol_Unknown"); + /// /// Invalid tag helper bound property '{1}' on tag helper '{0}'. Tag helpers cannot bind to HTML attributes with name '{2}' because the name contains a '{3}' character. /// @@ -375,298 +1545,102 @@ namespace Microsoft.AspNetCore.Razor.Language => GetString("TagHelper_InvalidTargetedTagNameNullOrWhitespace"); /// - /// The node '{0}' is not the owner of change '{1}'. + /// Tag helper directive assembly name cannot be null or empty. /// - internal static string InvalidOperation_SpanIsNotChangeOwner + internal static string TagHelperAssemblyNameCannotBeEmptyOrNull { - get => GetString("InvalidOperation_SpanIsNotChangeOwner"); + get => GetString("TagHelperAssemblyNameCannotBeEmptyOrNull"); } /// - /// The node '{0}' is not the owner of change '{1}'. + /// Tag helper directive assembly name cannot be null or empty. /// - internal static string FormatInvalidOperation_SpanIsNotChangeOwner(object p0, object p1) - => string.Format(CultureInfo.CurrentCulture, GetString("InvalidOperation_SpanIsNotChangeOwner"), p0, p1); + internal static string FormatTagHelperAssemblyNameCannotBeEmptyOrNull() + => GetString("TagHelperAssemblyNameCannotBeEmptyOrNull"); /// - /// Invalid directive keyword '{0}'. Directives must have a non-empty keyword that consists only of letters. + /// The tag helper attribute '{0}' in element '{1}' is missing a key. The syntax is '<{1} {0}{{ key }}="value">'. /// - internal static string DirectiveDescriptor_InvalidDirectiveKeyword + internal static string TagHelperBlockRewriter_IndexerAttributeNameMustIncludeKey { - get => GetString("DirectiveDescriptor_InvalidDirectiveKeyword"); + get => GetString("TagHelperBlockRewriter_IndexerAttributeNameMustIncludeKey"); } /// - /// Invalid directive keyword '{0}'. Directives must have a non-empty keyword that consists only of letters. + /// The tag helper attribute '{0}' in element '{1}' is missing a key. The syntax is '<{1} {0}{{ key }}="value">'. /// - internal static string FormatDirectiveDescriptor_InvalidDirectiveKeyword(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("DirectiveDescriptor_InvalidDirectiveKeyword"), p0); + internal static string FormatTagHelperBlockRewriter_IndexerAttributeNameMustIncludeKey(object p0, object p1) + => string.Format(CultureInfo.CurrentCulture, GetString("TagHelperBlockRewriter_IndexerAttributeNameMustIncludeKey"), p0, p1); /// - /// The feature must be initialized by setting the '{0}' property. + /// TagHelper attributes must be well-formed. /// - internal static string FeatureMustBeInitialized + internal static string TagHelperBlockRewriter_TagHelperAttributeListMustBeWellFormed { - get => GetString("FeatureMustBeInitialized"); + get => GetString("TagHelperBlockRewriter_TagHelperAttributeListMustBeWellFormed"); } /// - /// The feature must be initialized by setting the '{0}' property. + /// TagHelper attributes must be well-formed. /// - internal static string FormatFeatureMustBeInitialized(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("FeatureMustBeInitialized"), p0); + internal static string FormatTagHelperBlockRewriter_TagHelperAttributeListMustBeWellFormed() + => GetString("TagHelperBlockRewriter_TagHelperAttributeListMustBeWellFormed"); /// - /// The document type '{0}' does not support the extension '{1}'. + /// The parent <{0}> tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) '{1}' are allowed. /// - internal static string Diagnostic_CodeTarget_UnsupportedExtension + internal static string TagHelperParseTreeRewriter_CannotHaveNonTagContent { - get => GetString("Diagnostic_CodeTarget_UnsupportedExtension"); + get => GetString("TagHelperParseTreeRewriter_CannotHaveNonTagContent"); } /// - /// The document type '{0}' does not support the extension '{1}'. + /// The parent <{0}> tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) '{1}' are allowed. /// - internal static string FormatDiagnostic_CodeTarget_UnsupportedExtension(object p0, object p1) - => string.Format(CultureInfo.CurrentCulture, GetString("Diagnostic_CodeTarget_UnsupportedExtension"), p0, p1); + internal static string FormatTagHelperParseTreeRewriter_CannotHaveNonTagContent(object p0, object p1) + => string.Format(CultureInfo.CurrentCulture, GetString("TagHelperParseTreeRewriter_CannotHaveNonTagContent"), p0, p1); /// - /// The '{0}` directive must appear at the start of the line. + /// Found an end tag (</{0}>) for tag helper '{1}' with tag structure that disallows an end tag ('{2}'). /// - internal static string DirectiveMustAppearAtStartOfLine + internal static string TagHelperParseTreeRewriter_EndTagTagHelperMustNotHaveAnEndTag { - get => GetString("DirectiveMustAppearAtStartOfLine"); + get => GetString("TagHelperParseTreeRewriter_EndTagTagHelperMustNotHaveAnEndTag"); } /// - /// The '{0}` directive must appear at the start of the line. + /// Found an end tag (</{0}>) for tag helper '{1}' with tag structure that disallows an end tag ('{2}'). /// - internal static string FormatDirectiveMustAppearAtStartOfLine(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("DirectiveMustAppearAtStartOfLine"), p0); + internal static string FormatTagHelperParseTreeRewriter_EndTagTagHelperMustNotHaveAnEndTag(object p0, object p1, object p2) + => string.Format(CultureInfo.CurrentCulture, GetString("TagHelperParseTreeRewriter_EndTagTagHelperMustNotHaveAnEndTag"), p0, p1, p2); /// - /// The '{0}' directives value(s) must be separated by whitespace. + /// Tag helpers '{0}' and '{1}' targeting element '{2}' must not expect different {3} values. /// - internal static string DirectiveTokensMustBeSeparatedByWhitespace + internal static string TagHelperParseTreeRewriter_InconsistentTagStructure { - get => GetString("DirectiveTokensMustBeSeparatedByWhitespace"); + get => GetString("TagHelperParseTreeRewriter_InconsistentTagStructure"); } /// - /// The '{0}' directives value(s) must be separated by whitespace. + /// Tag helpers '{0}' and '{1}' targeting element '{2}' must not expect different {3} values. /// - internal static string FormatDirectiveTokensMustBeSeparatedByWhitespace(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("DirectiveTokensMustBeSeparatedByWhitespace"), p0); + internal static string FormatTagHelperParseTreeRewriter_InconsistentTagStructure(object p0, object p1, object p2, object p3) + => string.Format(CultureInfo.CurrentCulture, GetString("TagHelperParseTreeRewriter_InconsistentTagStructure"), p0, p1, p2, p3); /// - /// The key must not be null. + /// The <{0}> tag is not allowed by parent <{1}> tag helper. Only child tags with name(s) '{2}' are allowed. /// - internal static string KeyMustNotBeNull + internal static string TagHelperParseTreeRewriter_InvalidNestedTag { - get => GetString("KeyMustNotBeNull"); + get => GetString("TagHelperParseTreeRewriter_InvalidNestedTag"); } /// - /// The key must not be null. + /// The <{0}> tag is not allowed by parent <{1}> tag helper. Only child tags with name(s) '{2}' are allowed. /// - internal static string FormatKeyMustNotBeNull() - => GetString("KeyMustNotBeNull"); - - /// - /// The reference is invalid. The node '{0}' could not be found as a child of '{1}'. - /// - internal static string IntermediateNodeReference_NodeNotFound - { - get => GetString("IntermediateNodeReference_NodeNotFound"); - } - - /// - /// The reference is invalid. The node '{0}' could not be found as a child of '{1}'. - /// - internal static string FormatIntermediateNodeReference_NodeNotFound(object p0, object p1) - => string.Format(CultureInfo.CurrentCulture, GetString("IntermediateNodeReference_NodeNotFound"), p0, p1); - - /// - /// The reference is invalid. References initialized with the default constructor cannot modify nodes. - /// - internal static string IntermediateNodeReference_NotInitialized - { - get => GetString("IntermediateNodeReference_NotInitialized"); - } - - /// - /// The reference is invalid. References initialized with the default constructor cannot modify nodes. - /// - internal static string FormatIntermediateNodeReference_NotInitialized() - => GetString("IntermediateNodeReference_NotInitialized"); - - /// - /// The node '{0}' has a read-only child collection and cannot be modified. - /// - internal static string IntermediateNodeReference_CollectionIsReadOnly - { - get => GetString("IntermediateNodeReference_CollectionIsReadOnly"); - } - - /// - /// The node '{0}' has a read-only child collection and cannot be modified. - /// - internal static string FormatIntermediateNodeReference_CollectionIsReadOnly(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("IntermediateNodeReference_CollectionIsReadOnly"), p0); - - /// - /// The '{0}' directive may only occur once per document. - /// - internal static string DuplicateDirective - { - get => GetString("DuplicateDirective"); - } - - /// - /// The '{0}' directive may only occur once per document. - /// - internal static string FormatDuplicateDirective(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("DuplicateDirective"), p0); - - /// - /// Block directive '{0}' cannot be imported. - /// - internal static string BlockDirectiveCannotBeImported - { - get => GetString("BlockDirectiveCannotBeImported"); - } - - /// - /// Block directive '{0}' cannot be imported. - /// - internal static string FormatBlockDirectiveCannotBeImported(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("BlockDirectiveCannotBeImported"), p0); - - /// - /// Unreachable code. This can happen when a new {0} is introduced. - /// - internal static string UnexpectedDirectiveKind - { - get => GetString("UnexpectedDirectiveKind"); - } - - /// - /// Unreachable code. This can happen when a new {0} is introduced. - /// - internal static string FormatUnexpectedDirectiveKind(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("UnexpectedDirectiveKind"), p0); - - /// - /// The '{0}' requires a '{1}' delegate to be set. - /// - internal static string RenderingContextRequiresDelegate - { - get => GetString("RenderingContextRequiresDelegate"); - } - - /// - /// The '{0}' requires a '{1}' delegate to be set. - /// - internal static string FormatRenderingContextRequiresDelegate(object p0, object p1) - => string.Format(CultureInfo.CurrentCulture, GetString("RenderingContextRequiresDelegate"), p0, p1); - - /// - /// The '{0}' node type can only be used as a direct child of a '{1}' node. - /// - internal static string IntermediateNodes_InvalidParentNode - { - get => GetString("IntermediateNodes_InvalidParentNode"); - } - - /// - /// The '{0}' node type can only be used as a direct child of a '{1}' node. - /// - internal static string FormatIntermediateNodes_InvalidParentNode(object p0, object p1) - => string.Format(CultureInfo.CurrentCulture, GetString("IntermediateNodes_InvalidParentNode"), p0, p1); - - /// - /// Invalid newline sequence '{0}'. Support newline sequences are '\r\n' and '\n'. - /// - internal static string CodeWriter_InvalidNewLine - { - get => GetString("CodeWriter_InvalidNewLine"); - } - - /// - /// Invalid newline sequence '{0}'. Support newline sequences are '\r\n' and '\n'. - /// - internal static string FormatCodeWriter_InvalidNewLine(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("CodeWriter_InvalidNewLine"), p0); - - /// - /// Register Tag Helpers for use in the current document. - /// - internal static string AddTagHelperDirective_Description - { - get => GetString("AddTagHelperDirective_Description"); - } - - /// - /// Register Tag Helpers for use in the current document. - /// - internal static string FormatAddTagHelperDirective_Description() - => GetString("AddTagHelperDirective_Description"); - - /// - /// Specify a C# code block. - /// - internal static string FunctionsDirective_Description - { - get => GetString("FunctionsDirective_Description"); - } - - /// - /// Specify a C# code block. - /// - internal static string FormatFunctionsDirective_Description() - => GetString("FunctionsDirective_Description"); - - /// - /// Specify the base class for the current document. - /// - internal static string InheritsDirective_Description - { - get => GetString("InheritsDirective_Description"); - } - - /// - /// Specify the base class for the current document. - /// - internal static string FormatInheritsDirective_Description() - => GetString("InheritsDirective_Description"); - - /// - /// Remove Tag Helpers for use in the current document. - /// - internal static string RemoveTagHelperDirective_Description - { - get => GetString("RemoveTagHelperDirective_Description"); - } - - /// - /// Remove Tag Helpers for use in the current document. - /// - internal static string FormatRemoveTagHelperDirective_Description() - => GetString("RemoveTagHelperDirective_Description"); - - /// - /// Define a section to be rendered in the configured layout page. - /// - internal static string SectionDirective_Description - { - get => GetString("SectionDirective_Description"); - } - - /// - /// Define a section to be rendered in the configured layout page. - /// - internal static string FormatSectionDirective_Description() - => GetString("SectionDirective_Description"); + internal static string FormatTagHelperParseTreeRewriter_InvalidNestedTag(object p0, object p1, object p2) + => string.Format(CultureInfo.CurrentCulture, GetString("TagHelperParseTreeRewriter_InvalidNestedTag"), p0, p1, p2); /// /// Specify a prefix that is required in an element name for it to be included in Tag Helper processing. @@ -682,90 +1656,6 @@ namespace Microsoft.AspNetCore.Razor.Language internal static string FormatTagHelperPrefixDirective_Description() => GetString("TagHelperPrefixDirective_Description"); - /// - /// Add tag helpers from the specified type name and assembly name. Specify '*' for the type name to include all tag helper types from the specified assembly. - /// - internal static string AddTagHelperDirective_StringToken_Description - { - get => GetString("AddTagHelperDirective_StringToken_Description"); - } - - /// - /// Add tag helpers from the specified type name and assembly name. Specify '*' for the type name to include all tag helper types from the specified assembly. - /// - internal static string FormatAddTagHelperDirective_StringToken_Description() - => GetString("AddTagHelperDirective_StringToken_Description"); - - /// - /// TypeName, AssemblyName - /// - internal static string AddTagHelperDirective_StringToken_Name - { - get => GetString("AddTagHelperDirective_StringToken_Name"); - } - - /// - /// TypeName, AssemblyName - /// - internal static string FormatAddTagHelperDirective_StringToken_Name() - => GetString("AddTagHelperDirective_StringToken_Name"); - - /// - /// The base type that the current page inherits. - /// - internal static string InheritsDirective_TypeToken_Description - { - get => GetString("InheritsDirective_TypeToken_Description"); - } - - /// - /// The base type that the current page inherits. - /// - internal static string FormatInheritsDirective_TypeToken_Description() - => GetString("InheritsDirective_TypeToken_Description"); - - /// - /// TypeName - /// - internal static string InheritsDirective_TypeToken_Name - { - get => GetString("InheritsDirective_TypeToken_Name"); - } - - /// - /// TypeName - /// - internal static string FormatInheritsDirective_TypeToken_Name() - => GetString("InheritsDirective_TypeToken_Name"); - - /// - /// Remove tag helpers from the specified type name and assembly name. Specify '*' for the type name to remove all tag helper types from the specified assembly. - /// - internal static string RemoveTagHelperDirective_StringToken_Description - { - get => GetString("RemoveTagHelperDirective_StringToken_Description"); - } - - /// - /// Remove tag helpers from the specified type name and assembly name. Specify '*' for the type name to remove all tag helper types from the specified assembly. - /// - internal static string FormatRemoveTagHelperDirective_StringToken_Description() - => GetString("RemoveTagHelperDirective_StringToken_Description"); - - /// - /// TypeName, AssemblyName - /// - internal static string RemoveTagHelperDirective_StringToken_Name - { - get => GetString("RemoveTagHelperDirective_StringToken_Name"); - } - - /// - /// TypeName, AssemblyName - /// - internal static string FormatRemoveTagHelperDirective_StringToken_Name() - => GetString("RemoveTagHelperDirective_StringToken_Name"); - /// /// The tag prefix to apply to tag helpers. /// @@ -795,32 +1685,176 @@ namespace Microsoft.AspNetCore.Razor.Language => GetString("TagHelperPrefixDirective_PrefixToken_Name"); /// - /// The name of the section. + /// Tag Helper '{0}'s attributes must have names. /// - internal static string SectionDirective_NameToken_Description + internal static string TagHelpers_AttributesMustHaveAName { - get => GetString("SectionDirective_NameToken_Description"); + get => GetString("TagHelpers_AttributesMustHaveAName"); } /// - /// The name of the section. + /// Tag Helper '{0}'s attributes must have names. /// - internal static string FormatSectionDirective_NameToken_Description() - => GetString("SectionDirective_NameToken_Description"); + internal static string FormatTagHelpers_AttributesMustHaveAName(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("TagHelpers_AttributesMustHaveAName"), p0); /// - /// SectionName + /// The tag helper '{0}' must not have C# in the element's attribute declaration area. /// - internal static string SectionDirective_NameToken_Name + internal static string TagHelpers_CannotHaveCSharpInTagDeclaration { - get => GetString("SectionDirective_NameToken_Name"); + get => GetString("TagHelpers_CannotHaveCSharpInTagDeclaration"); } /// - /// SectionName + /// The tag helper '{0}' must not have C# in the element's attribute declaration area. /// - internal static string FormatSectionDirective_NameToken_Name() - => GetString("SectionDirective_NameToken_Name"); + internal static string FormatTagHelpers_CannotHaveCSharpInTagDeclaration(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("TagHelpers_CannotHaveCSharpInTagDeclaration"), p0); + + /// + /// Code blocks (e.g. @{{var variable = 23;}}) must not appear in non-string tag helper attribute values. + /// Already in an expression (code) context. If necessary an explicit expression (e.g. @(@readonly)) may be used. + /// + internal static string TagHelpers_CodeBlocks_NotSupported_InAttributes + { + get => GetString("TagHelpers_CodeBlocks_NotSupported_InAttributes"); + } + + /// + /// Code blocks (e.g. @{{var variable = 23;}}) must not appear in non-string tag helper attribute values. + /// Already in an expression (code) context. If necessary an explicit expression (e.g. @(@readonly)) may be used. + /// + internal static string FormatTagHelpers_CodeBlocks_NotSupported_InAttributes() + => GetString("TagHelpers_CodeBlocks_NotSupported_InAttributes"); + + /// + /// Inline markup blocks (e.g. @<p>content</p>) must not appear in non-string tag helper attribute values. + /// Expected a '{0}' attribute value, not a string. + /// + internal static string TagHelpers_InlineMarkupBlocks_NotSupported_InAttributes + { + get => GetString("TagHelpers_InlineMarkupBlocks_NotSupported_InAttributes"); + } + + /// + /// Inline markup blocks (e.g. @<p>content</p>) must not appear in non-string tag helper attribute values. + /// Expected a '{0}' attribute value, not a string. + /// + internal static string FormatTagHelpers_InlineMarkupBlocks_NotSupported_InAttributes(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("TagHelpers_InlineMarkupBlocks_NotSupported_InAttributes"), p0); + + /// + /// Found a malformed '{0}' tag helper. Tag helpers must have a start and end tag or be self closing. + /// + internal static string TagHelpersParseTreeRewriter_FoundMalformedTagHelper + { + get => GetString("TagHelpersParseTreeRewriter_FoundMalformedTagHelper"); + } + + /// + /// Found a malformed '{0}' tag helper. Tag helpers must have a start and end tag or be self closing. + /// + internal static string FormatTagHelpersParseTreeRewriter_FoundMalformedTagHelper(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("TagHelpersParseTreeRewriter_FoundMalformedTagHelper"), p0); + + /// + /// Missing close angle for tag helper '{0}'. + /// + internal static string TagHelpersParseTreeRewriter_MissingCloseAngle + { + get => GetString("TagHelpersParseTreeRewriter_MissingCloseAngle"); + } + + /// + /// Missing close angle for tag helper '{0}'. + /// + internal static string FormatTagHelpersParseTreeRewriter_MissingCloseAngle(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("TagHelpersParseTreeRewriter_MissingCloseAngle"), p0); + + /// + /// Unreachable code. This can happen when a new {0} is introduced. + /// + internal static string UnexpectedDirectiveKind + { + get => GetString("UnexpectedDirectiveKind"); + } + + /// + /// Unreachable code. This can happen when a new {0} is introduced. + /// + internal static string FormatUnexpectedDirectiveKind(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("UnexpectedDirectiveKind"), p0); + + /// + /// Unexpected literal following the '{0}' directive. Expected '{1}'. + /// + internal static string UnexpectedDirectiveLiteral + { + get => GetString("UnexpectedDirectiveLiteral"); + } + + /// + /// Unexpected literal following the '{0}' directive. Expected '{1}'. + /// + internal static string FormatUnexpectedDirectiveLiteral(object p0, object p1) + => string.Format(CultureInfo.CurrentCulture, GetString("UnexpectedDirectiveLiteral"), p0, p1); + + /// + /// Unexpected end of file following the '{0}' directive. Expected '{1}'. + /// + internal static string UnexpectedEOFAfterDirective + { + get => GetString("UnexpectedEOFAfterDirective"); + } + + /// + /// Unexpected end of file following the '{0}' directive. Expected '{1}'. + /// + internal static string FormatUnexpectedEOFAfterDirective(object p0, object p1) + => string.Format(CultureInfo.CurrentCulture, GetString("UnexpectedEOFAfterDirective"), p0, p1); + + /// + /// The hash algorithm '{0}' is not supported for checksum generation. Supported algorithms are: '{1}'. Set '{2}' to '{3}' to suppress automatic checksum generation. + /// + internal static string UnsupportedChecksumAlgorithm + { + get => GetString("UnsupportedChecksumAlgorithm"); + } + + /// + /// The hash algorithm '{0}' is not supported for checksum generation. Supported algorithms are: '{1}'. Set '{2}' to '{3}' to suppress automatic checksum generation. + /// + internal static string FormatUnsupportedChecksumAlgorithm(object p0, object p1, object p2, object p3) + => string.Format(CultureInfo.CurrentCulture, GetString("UnsupportedChecksumAlgorithm"), p0, p1, p2, p3); + + /// + /// The '{0}.{1}' property must not be null. + /// + internal static string PropertyMustNotBeNull + { + get => GetString("PropertyMustNotBeNull"); + } + + /// + /// The '{0}.{1}' property must not be null. + /// + internal static string FormatPropertyMustNotBeNull(object p0, object p1) + => string.Format(CultureInfo.CurrentCulture, GetString("PropertyMustNotBeNull"), p0, p1); + + /// + /// The '{0}' is missing feature '{1}'. + /// + internal static string RazorProjectEngineMissingFeatureDependency + { + get => GetString("RazorProjectEngineMissingFeatureDependency"); + } + + /// + /// The '{0}' is missing feature '{1}'. + /// + internal static string FormatRazorProjectEngineMissingFeatureDependency(object p0, object p1) + => string.Format(CultureInfo.CurrentCulture, GetString("RazorProjectEngineMissingFeatureDependency"), p0, p1); /// /// The Razor language version '{0}' is unrecognized or not supported by this version of Razor. @@ -836,6 +1870,34 @@ namespace Microsoft.AspNetCore.Razor.Language internal static string FormatRazorLanguageVersion_InvalidVersion(object p0) => string.Format(CultureInfo.CurrentCulture, GetString("RazorLanguageVersion_InvalidVersion"), p0); + /// + /// File path '{0}' does not belong to the directory '{1}'. + /// + internal static string VirtualFileSystem_FileDoesNotBelongToDirectory + { + get => GetString("VirtualFileSystem_FileDoesNotBelongToDirectory"); + } + + /// + /// File path '{0}' does not belong to the directory '{1}'. + /// + internal static string FormatVirtualFileSystem_FileDoesNotBelongToDirectory(object p0, object p1) + => string.Format(CultureInfo.CurrentCulture, GetString("VirtualFileSystem_FileDoesNotBelongToDirectory"), p0, p1); + + /// + /// The file path '{0}' is invalid. File path is the root relative path of the file starting with '/' and should not contain any '\' characters. + /// + internal static string VirtualFileSystem_InvalidRelativePath + { + get => GetString("VirtualFileSystem_InvalidRelativePath"); + } + + /// + /// The file path '{0}' is invalid. File path is the root relative path of the file starting with '/' and should not contain any '\' characters. + /// + internal static string FormatVirtualFileSystem_InvalidRelativePath(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("VirtualFileSystem_InvalidRelativePath"), p0); + private static string GetString(string name, params string[] formatterNames) { var value = _resourceManager.GetString(name); diff --git a/src/Microsoft.AspNetCore.Razor.Language/ProvideRazorExtensionInitializerAttribute.cs b/src/Microsoft.AspNetCore.Razor.Language/ProvideRazorExtensionInitializerAttribute.cs new file mode 100644 index 0000000000..374419a676 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/ProvideRazorExtensionInitializerAttribute.cs @@ -0,0 +1,31 @@ +// 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; + +namespace Microsoft.AspNetCore.Razor.Language +{ + [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true, Inherited = false)] + public class ProvideRazorExtensionInitializerAttribute : Attribute + { + public ProvideRazorExtensionInitializerAttribute(string extensionName, Type initializerType) + { + if (extensionName == null) + { + throw new ArgumentNullException(nameof(extensionName)); + } + + if (initializerType == null) + { + throw new ArgumentNullException(nameof(initializerType)); + } + + ExtensionName = extensionName; + InitializerType = initializerType; + } + + public string ExtensionName { get; } + + public Type InitializerType { get; } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorCodeDocument.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorCodeDocument.cs index 6ee41d0be5..0d57df2815 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorCodeDocument.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorCodeDocument.cs @@ -30,6 +30,23 @@ namespace Microsoft.AspNetCore.Razor.Language return new DefaultRazorCodeDocument(source, imports); } + public static RazorCodeDocument Create( + RazorSourceDocument source, + IEnumerable imports, + RazorParserOptions parserOptions, + RazorCodeGenerationOptions codeGenerationOptions) + { + if (source == null) + { + throw new ArgumentNullException(nameof(source)); + } + + var codeDocument = new DefaultRazorCodeDocument(source, imports); + codeDocument.SetParserOptions(parserOptions); + codeDocument.SetCodeGenerationOptions(codeGenerationOptions); + return codeDocument; + } + public abstract IReadOnlyList Imports { get; } public abstract ItemCollection Items { get; } diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorCodeDocumentExtensions.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorCodeDocumentExtensions.cs index 6cee701d3e..85df33837a 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorCodeDocumentExtensions.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorCodeDocumentExtensions.cs @@ -9,8 +9,6 @@ namespace Microsoft.AspNetCore.Razor.Language { public static class RazorCodeDocumentExtensions { - private static object TagHelperPrefixKey = new object(); - public static TagHelperDocumentContext GetTagHelperContext(this RazorCodeDocument document) { if (document == null) @@ -111,6 +109,46 @@ namespace Microsoft.AspNetCore.Razor.Language document.Items[typeof(RazorCSharpDocument)] = csharp; } + public static RazorParserOptions GetParserOptions(this RazorCodeDocument document) + { + if (document == null) + { + throw new ArgumentNullException(nameof(document)); + } + + return (RazorParserOptions)document.Items[typeof(RazorParserOptions)]; + } + + public static void SetParserOptions(this RazorCodeDocument document, RazorParserOptions parserOptions) + { + if (document == null) + { + throw new ArgumentNullException(nameof(document)); + } + + document.Items[typeof(RazorParserOptions)] = parserOptions; + } + + public static RazorCodeGenerationOptions GetCodeGenerationOptions(this RazorCodeDocument document) + { + if (document == null) + { + throw new ArgumentNullException(nameof(document)); + } + + return (RazorCodeGenerationOptions)document.Items[typeof(RazorCodeGenerationOptions)]; + } + + public static void SetCodeGenerationOptions(this RazorCodeDocument document, RazorCodeGenerationOptions codeGenerationOptions) + { + if (document == null) + { + throw new ArgumentNullException(nameof(document)); + } + + document.Items[typeof(RazorCodeGenerationOptions)] = codeGenerationOptions; + } + private class ImportSyntaxTreesHolder { public ImportSyntaxTreesHolder(IReadOnlyList syntaxTrees) diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorCodeGenerationOptions.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorCodeGenerationOptions.cs index 6e73d6a004..60da959c2d 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorCodeGenerationOptions.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorCodeGenerationOptions.cs @@ -9,12 +9,22 @@ namespace Microsoft.AspNetCore.Razor.Language { public static RazorCodeGenerationOptions CreateDefault() { - return new DefaultRazorCodeGenerationOptions(indentWithTabs: false, indentSize: 4, designTime: false, suppressChecksum: false); + return new DefaultRazorCodeGenerationOptions( + indentWithTabs: false, + indentSize: 4, + designTime: false, + suppressChecksum: false, + supressMetadataAttributes: false); } public static RazorCodeGenerationOptions CreateDesignTimeDefault() { - return new DefaultRazorCodeGenerationOptions(indentWithTabs: false, indentSize: 4, designTime: true, suppressChecksum: false); + return new DefaultRazorCodeGenerationOptions( + indentWithTabs: false, + indentSize: 4, + designTime: true, + suppressChecksum: false, + supressMetadataAttributes: true); } public static RazorCodeGenerationOptions Create(Action configure) @@ -38,7 +48,11 @@ namespace Microsoft.AspNetCore.Razor.Language throw new ArgumentNullException(nameof(configure)); } - var builder = new DefaultRazorCodeGenerationOptionsBuilder(designTime: true); + var builder = new DefaultRazorCodeGenerationOptionsBuilder(designTime: true) + { + SuppressMetadataAttributes = true, + }; + configure(builder); var options = builder.Build(); @@ -51,6 +65,33 @@ namespace Microsoft.AspNetCore.Razor.Language public abstract int IndentSize { get; } + /// + /// Gets a value that indicates whether to suppress the default #pragma checksum directive in the + /// generated C# code. If false the checkum directive will be included, otherwise it will not be + /// generated. Defaults to false, meaning that the checksum will be included. + /// + /// + /// The #pragma checksum is required to enable debugging and should only be supressed for testing + /// purposes. + /// public abstract bool SuppressChecksum { get; } + + /// + /// Gets a value that indicates whether to suppress the default metadata attributes in the generated + /// C# code. If false the default attributes will be included, otherwise they will not be generated. + /// Defaults to false at run time, meaning that the attributes will be included. Defaults to + /// true at design time, meaning that the attributes will not be included. + /// + /// + /// + /// The Microsoft.AspNetCore.Razor.Runtime package includes a default set of attributes intended + /// for runtimes to discover metadata about the compiled code. + /// + /// + /// The default metadata attributes should be suppressed if code generation targets a runtime without + /// a reference to Microsoft.AspNetCore.Razor.Runtime, or for testing purposes. + /// + /// + public virtual bool SuppressMetadataAttributes { get; protected set; } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorCodeGenerationOptionsBuilder.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorCodeGenerationOptionsBuilder.cs index 3b24c23bfe..be4c9dff3d 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorCodeGenerationOptionsBuilder.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorCodeGenerationOptionsBuilder.cs @@ -5,14 +5,47 @@ namespace Microsoft.AspNetCore.Razor.Language { public abstract class RazorCodeGenerationOptionsBuilder { + public virtual RazorConfiguration Configuration => null; + public abstract bool DesignTime { get; } public abstract int IndentSize { get; set; } public abstract bool IndentWithTabs { get; set; } + /// + /// Gets or sets a value that indicates whether to suppress the default #pragma checksum directive in the + /// generated C# code. If false the checkum directive will be included, otherwise it will not be + /// generated. Defaults to false, meaning that the checksum will be included. + /// + /// + /// The #pragma checksum is required to enable debugging and should only be supressed for testing + /// purposes. + /// public abstract bool SuppressChecksum { get; set; } + /// + /// Gets or setsa value that indicates whether to suppress the default metadata attributes in the generated + /// C# code. If false the default attributes will be included, otherwise they will not be generated. + /// Defaults to false at run time, meaning that the attributes will be included. Defaults to + /// true at design time, meaning that the attributes will not be included. + /// + /// + /// + /// The Microsoft.AspNetCore.Razor.Runtime package includes a default set of attributes intended + /// for runtimes to discover metadata about the compiled code. + /// + /// + /// The default metadata attributes should be suppressed if code generation targets a runtime without + /// a reference to Microsoft.AspNetCore.Razor.Runtime, or for testing purposes. + /// + /// + public virtual bool SuppressMetadataAttributes { get; set; } + public abstract RazorCodeGenerationOptions Build(); + + public virtual void SetDesignTime(bool designTime) + { + } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorConfiguration.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorConfiguration.cs index 0f00751497..f68db61f22 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorConfiguration.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorConfiguration.cs @@ -12,22 +12,12 @@ namespace Microsoft.AspNetCore.Razor.Language public static readonly RazorConfiguration Default = new RazorConfiguration( RazorLanguageVersion.Latest, "unnamed", - Array.Empty(), - designTime: false); - - // This is used only in some back-compat scenarios. We don't expose it because there's no - // use case for anyone else to use it. - internal static readonly RazorConfiguration DefaultDesignTime = new RazorConfiguration( - RazorLanguageVersion.Latest, - "unnamed", - Array.Empty(), - designTime: true); + Array.Empty()); public RazorConfiguration( RazorLanguageVersion languageVersion, string configurationName, - IEnumerable extensions, - bool designTime) + IEnumerable extensions) { if (languageVersion == null) { @@ -47,7 +37,6 @@ namespace Microsoft.AspNetCore.Razor.Language LanguageVersion = languageVersion; ConfigurationName = configurationName; Extensions = extensions.ToArray(); - DesignTime = designTime; } public string ConfigurationName { get; } @@ -55,7 +44,5 @@ namespace Microsoft.AspNetCore.Razor.Language public IReadOnlyList Extensions { get; } public RazorLanguageVersion LanguageVersion { get; } - - public bool DesignTime { get; } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorDiagnostic.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorDiagnostic.cs index 0edb2fdf93..a4bd3c2b5e 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorDiagnostic.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorDiagnostic.cs @@ -2,12 +2,12 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNetCore.Razor.Language.Legacy; namespace Microsoft.AspNetCore.Razor.Language { public abstract class RazorDiagnostic : IEquatable, IFormattable { + internal static readonly RazorDiagnostic[] EmptyArray = new RazorDiagnostic[0]; internal static readonly object[] EmptyArgs = new object[0]; public abstract string Id { get; } @@ -44,16 +44,6 @@ namespace Microsoft.AspNetCore.Razor.Language return new DefaultRazorDiagnostic(descriptor, span, args); } - internal static RazorDiagnostic Create(RazorError error) - { - if (error == null) - { - throw new ArgumentNullException(nameof(error)); - } - - return new LegacyRazorDiagnostic(error); - } - public override string ToString() { return ((IFormattable)this).ToString(null, null); diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorDiagnosticFactory.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorDiagnosticFactory.cs index bf19f615b3..cf1ad34dd6 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorDiagnosticFactory.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorDiagnosticFactory.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 Microsoft.AspNetCore.Razor.Language.Legacy; namespace Microsoft.AspNetCore.Razor.Language { @@ -13,11 +14,11 @@ namespace Microsoft.AspNetCore.Razor.Language // General Errors ID Offset = 0 - public static readonly RazorDiagnosticDescriptor Directive_BlockDirectiveCannotBeImported = - new RazorDiagnosticDescriptor( - $"{DiagnosticPrefix}0000", - () => Resources.BlockDirectiveCannotBeImported, - RazorDiagnosticSeverity.Error); + internal static readonly RazorDiagnosticDescriptor Directive_BlockDirectiveCannotBeImported = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}0000", + () => Resources.BlockDirectiveCannotBeImported, + RazorDiagnosticSeverity.Error); public static RazorDiagnostic CreateDirective_BlockDirectiveCannotBeImported(string directive) { return RazorDiagnostic.Create(Directive_BlockDirectiveCannotBeImported, SourceSpan.Undefined, directive); @@ -29,13 +30,400 @@ namespace Microsoft.AspNetCore.Razor.Language // Language Errors ID Offset = 1000 + internal static readonly RazorDiagnosticDescriptor Parsing_UnterminatedStringLiteral = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1000", + () => Resources.ParseError_Unterminated_String_Literal, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_UnterminatedStringLiteral(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_UnterminatedStringLiteral, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_BlockCommentNotTerminated = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1001", + () => Resources.ParseError_BlockComment_Not_Terminated, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_BlockCommentNotTerminated(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_BlockCommentNotTerminated, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_HelperDirectiveNotAvailable = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1002", + () => Resources.ParseError_HelperDirectiveNotAvailable, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_HelperDirectiveNotAvailable(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_HelperDirectiveNotAvailable, location, SyntaxConstants.CSharp.HelperKeyword); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_UnexpectedWhiteSpaceAtStartOfCodeBlock = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1003", + () => Resources.ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_UnexpectedWhiteSpaceAtStartOfCodeBlock(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_UnexpectedWhiteSpaceAtStartOfCodeBlock, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_UnexpectedEndOfFileAtStartOfCodeBlock = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1004", + () => Resources.ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_UnexpectedEndOfFileAtStartOfCodeBlock(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_UnexpectedEndOfFileAtStartOfCodeBlock, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_UnexpectedCharacterAtStartOfCodeBlock = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1005", + () => Resources.ParseError_Unexpected_Character_At_Start_Of_CodeBlock, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_UnexpectedCharacterAtStartOfCodeBlock(SourceSpan location, string content) + { + return RazorDiagnostic.Create(Parsing_UnexpectedCharacterAtStartOfCodeBlock, location, content); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_ExpectedEndOfBlockBeforeEOF = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1006", + () => Resources.ParseError_Expected_EndOfBlock_Before_EOF, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_ExpectedEndOfBlockBeforeEOF(SourceSpan location, string blockName, string closeBlock, string openBlock) + { + return RazorDiagnostic.Create(Parsing_ExpectedEndOfBlockBeforeEOF, location, blockName, closeBlock, openBlock); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_ReservedWord = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1007", + () => Resources.ParseError_ReservedWord, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_ReservedWord(SourceSpan location, string content) + { + return RazorDiagnostic.Create(Parsing_ReservedWord, location, content); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_SingleLineControlFlowStatementsNotAllowed = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1008", + () => Resources.ParseError_SingleLine_ControlFlowStatements_Not_Allowed, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_SingleLineControlFlowStatementsNotAllowed(SourceSpan location, string expected, string actual) + { + return RazorDiagnostic.Create(Parsing_SingleLineControlFlowStatementsNotAllowed, location, expected, actual); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_AtInCodeMustBeFollowedByColonParenOrIdentifierStart = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1009", + () => Resources.ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_AtInCodeMustBeFollowedByColonParenOrIdentifierStart(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_AtInCodeMustBeFollowedByColonParenOrIdentifierStart, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_UnexpectedNestedCodeBlock = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1010", + () => Resources.ParseError_Unexpected_Nested_CodeBlock, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_UnexpectedNestedCodeBlock(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_UnexpectedNestedCodeBlock, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_DirectiveTokensMustBeSeparatedByWhitespace = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1011", + () => Resources.DirectiveTokensMustBeSeparatedByWhitespace, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_DirectiveTokensMustBeSeparatedByWhitespace(SourceSpan location, string directiveName) + { + return RazorDiagnostic.Create(Parsing_DirectiveTokensMustBeSeparatedByWhitespace, location, directiveName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_UnexpectedEOFAfterDirective = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1012", + () => Resources.UnexpectedEOFAfterDirective, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_UnexpectedEOFAfterDirective(SourceSpan location, string directiveName, string expectedToken) + { + return RazorDiagnostic.Create(Parsing_UnexpectedEOFAfterDirective, location, directiveName, expectedToken); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_DirectiveExpectsTypeName = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1013", + () => Resources.DirectiveExpectsTypeName, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_DirectiveExpectsTypeName(SourceSpan location, string directiveName) + { + return RazorDiagnostic.Create(Parsing_DirectiveExpectsTypeName, location, directiveName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_DirectiveExpectsNamespace = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1014", + () => Resources.DirectiveExpectsNamespace, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_DirectiveExpectsNamespace(SourceSpan location, string directiveName) + { + return RazorDiagnostic.Create(Parsing_DirectiveExpectsNamespace, location, directiveName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_DirectiveExpectsIdentifier = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1015", + () => Resources.DirectiveExpectsIdentifier, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_DirectiveExpectsIdentifier(SourceSpan location, string directiveName) + { + return RazorDiagnostic.Create(Parsing_DirectiveExpectsIdentifier, location, directiveName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_DirectiveExpectsQuotedStringLiteral = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1016", + () => Resources.DirectiveExpectsQuotedStringLiteral, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_DirectiveExpectsQuotedStringLiteral(SourceSpan location, string directiveName) + { + return RazorDiagnostic.Create(Parsing_DirectiveExpectsQuotedStringLiteral, location, directiveName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_UnexpectedDirectiveLiteral = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1017", + () => Resources.UnexpectedDirectiveLiteral, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_UnexpectedDirectiveLiteral(SourceSpan location, string directiveName, string expected) + { + return RazorDiagnostic.Create(Parsing_UnexpectedDirectiveLiteral, location, directiveName, expected); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_DirectiveMustHaveValue = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1018", + () => Resources.ParseError_DirectiveMustHaveValue, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_DirectiveMustHaveValue(SourceSpan location, string directiveName) + { + return RazorDiagnostic.Create(Parsing_DirectiveMustHaveValue, location, directiveName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_IncompleteQuotesAroundDirective = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1019", + () => Resources.ParseError_IncompleteQuotesAroundDirective, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_IncompleteQuotesAroundDirective(SourceSpan location, string directiveName) + { + return RazorDiagnostic.Create(Parsing_IncompleteQuotesAroundDirective, location, directiveName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_InvalidTagHelperPrefixValue = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1020", + () => Resources.InvalidTagHelperPrefixValue, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_InvalidTagHelperPrefixValue(SourceSpan location, string directiveName, char character, string prefix) + { + return RazorDiagnostic.Create(Parsing_InvalidTagHelperPrefixValue, location, directiveName, character, prefix); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_InvalidTagHelperLookupText = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1020", + () => Resources.InvalidTagHelperLookupText, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_InvalidTagHelperLookupText(SourceSpan location, string lookupText) + { + return RazorDiagnostic.Create(Parsing_InvalidTagHelperLookupText, location, lookupText); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_MarkupBlockMustStartWithTag = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1021", + () => Resources.ParseError_MarkupBlock_Must_Start_With_Tag, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_MarkupBlockMustStartWithTag(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_MarkupBlockMustStartWithTag, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_OuterTagMissingName = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1022", + () => Resources.ParseError_OuterTagMissingName, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_OuterTagMissingName(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_OuterTagMissingName, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_TextTagCannotContainAttributes = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1023", + () => Resources.ParseError_TextTagCannotContainAttributes, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_TextTagCannotContainAttributes(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_TextTagCannotContainAttributes, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_UnfinishedTag = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1024", + () => Resources.ParseError_UnfinishedTag, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_UnfinishedTag(SourceSpan location, string tagName) + { + return RazorDiagnostic.Create(Parsing_UnfinishedTag, location, tagName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_MissingEndTag = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1025", + () => Resources.ParseError_MissingEndTag, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_MissingEndTag(SourceSpan location, string tagName) + { + return RazorDiagnostic.Create(Parsing_MissingEndTag, location, tagName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_UnexpectedEndTag = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1026", + () => Resources.ParseError_UnexpectedEndTag, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_UnexpectedEndTag(SourceSpan location, string tagName) + { + return RazorDiagnostic.Create(Parsing_UnexpectedEndTag, location, tagName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_ExpectedCloseBracketBeforeEOF = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1027", + () => Resources.ParseError_Expected_CloseBracket_Before_EOF, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_ExpectedCloseBracketBeforeEOF(SourceSpan location, string openBrace, string closeBrace) + { + return RazorDiagnostic.Create(Parsing_ExpectedCloseBracketBeforeEOF, location, openBrace, closeBrace); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_RazorCommentNotTerminated = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1028", + () => Resources.ParseError_RazorComment_Not_Terminated, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_RazorCommentNotTerminated(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_RazorCommentNotTerminated, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_TagHelperIndexerAttributeNameMustIncludeKey = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1029", + () => Resources.TagHelperBlockRewriter_IndexerAttributeNameMustIncludeKey, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_TagHelperIndexerAttributeNameMustIncludeKey(SourceSpan location, string attributeName, string tagName) + { + return RazorDiagnostic.Create(Parsing_TagHelperIndexerAttributeNameMustIncludeKey, location, attributeName, tagName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_TagHelperAttributeListMustBeWellFormed = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1030", + () => Resources.TagHelperBlockRewriter_TagHelperAttributeListMustBeWellFormed, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_TagHelperAttributeListMustBeWellFormed(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_TagHelperAttributeListMustBeWellFormed, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_TagHelpersCannotHaveCSharpInTagDeclaration = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1031", + () => Resources.TagHelpers_CannotHaveCSharpInTagDeclaration, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_TagHelpersCannotHaveCSharpInTagDeclaration(SourceSpan location, string tagName) + { + return RazorDiagnostic.Create(Parsing_TagHelpersCannotHaveCSharpInTagDeclaration, location, tagName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_TagHelperAttributesMustHaveAName = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1032", + () => Resources.TagHelpers_AttributesMustHaveAName, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_TagHelperAttributesMustHaveAName(SourceSpan location, string tagName) + { + return RazorDiagnostic.Create(Parsing_TagHelperAttributesMustHaveAName, location, tagName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_TagHelperMustNotHaveAnEndTag = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1033", + () => Resources.TagHelperParseTreeRewriter_EndTagTagHelperMustNotHaveAnEndTag, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_TagHelperMustNotHaveAnEndTag(SourceSpan location, string tagName, string displayName, TagStructure tagStructure) + { + var diagnostic = RazorDiagnostic.Create( + Parsing_TagHelperMustNotHaveAnEndTag, + location, + tagName, + displayName, + tagStructure); + + return diagnostic; + } + + internal static readonly RazorDiagnosticDescriptor Parsing_TagHelperFoundMalformedTagHelper = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1034", + () => Resources.TagHelpersParseTreeRewriter_FoundMalformedTagHelper, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_TagHelperFoundMalformedTagHelper(SourceSpan location, string tagName) + { + var diagnostic = RazorDiagnostic.Create( + Parsing_TagHelperFoundMalformedTagHelper, + location, + tagName); + + return diagnostic; + } + + internal static readonly RazorDiagnosticDescriptor Parsing_TagHelperMissingCloseAngle = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1035", + () => Resources.TagHelpersParseTreeRewriter_MissingCloseAngle, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_TagHelperMissingCloseAngle(SourceSpan location, string tagName) + { + var diagnostic = RazorDiagnostic.Create( + Parsing_TagHelperMissingCloseAngle, + location, + tagName); + + return diagnostic; + } + #endregion #region Semantic Errors // Semantic Errors ID Offset = 2000 - public static readonly RazorDiagnosticDescriptor CodeTarget_UnsupportedExtension = + internal static readonly RazorDiagnosticDescriptor CodeTarget_UnsupportedExtension = new RazorDiagnosticDescriptor( $"{DiagnosticPrefix}2000", () => Resources.Diagnostic_CodeTarget_UnsupportedExtension, @@ -50,11 +438,117 @@ namespace Microsoft.AspNetCore.Razor.Language $"{DiagnosticPrefix}2001", () => Resources.DuplicateDirective, RazorDiagnosticSeverity.Error); - public static RazorDiagnostic CreateParsing_DuplicateDirective(string directive, SourceSpan location) + public static RazorDiagnostic CreateParsing_DuplicateDirective(SourceSpan location, string directive) { return RazorDiagnostic.Create(Parsing_DuplicateDirective, location, directive); } + internal static readonly RazorDiagnosticDescriptor Parsing_SectionsCannotBeNested = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}2002", + () => Resources.ParseError_Sections_Cannot_Be_Nested, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_SectionsCannotBeNested(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_SectionsCannotBeNested, location, Resources.SectionExample); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_InlineMarkupBlocksCannotBeNested = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}2003", + () => Resources.ParseError_InlineMarkup_Blocks_Cannot_Be_Nested, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_InlineMarkupBlocksCannotBeNested(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_InlineMarkupBlocksCannotBeNested, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_NamespaceImportAndTypeAliasCannotExistWithinCodeBlock = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}2004", + () => Resources.ParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_NamespaceImportAndTypeAliasCannotExistWithinCodeBlock(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_NamespaceImportAndTypeAliasCannotExistWithinCodeBlock, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_DirectiveMustAppearAtStartOfLine = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}2005", + () => Resources.DirectiveMustAppearAtStartOfLine, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_DirectiveMustAppearAtStartOfLine(SourceSpan location, string directiveName) + { + return RazorDiagnostic.Create(Parsing_DirectiveMustAppearAtStartOfLine, location, directiveName); + } + + internal static readonly RazorDiagnosticDescriptor TagHelper_CodeBlocksNotSupportedInAttributes = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}2006", + () => Resources.TagHelpers_CodeBlocks_NotSupported_InAttributes, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateTagHelper_CodeBlocksNotSupportedInAttributes(SourceSpan location) + { + var diagnostic = RazorDiagnostic.Create(TagHelper_CodeBlocksNotSupportedInAttributes, location); + return diagnostic; + } + + internal static readonly RazorDiagnosticDescriptor TagHelper_InlineMarkupBlocksNotSupportedInAttributes = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}2007", + () => Resources.TagHelpers_InlineMarkupBlocks_NotSupported_InAttributes, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateTagHelper_InlineMarkupBlocksNotSupportedInAttributes(SourceSpan location, string expectedTypeName) + { + var diagnostic = RazorDiagnostic.Create( + TagHelper_InlineMarkupBlocksNotSupportedInAttributes, + location, + expectedTypeName); + + return diagnostic; + } + + internal static readonly RazorDiagnosticDescriptor TagHelper_EmptyBoundAttribute = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}2008", + () => Resources.RewriterError_EmptyTagHelperBoundAttribute, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateTagHelper_EmptyBoundAttribute(SourceSpan location, string attributeName, string tagName, string propertyTypeName) + { + return RazorDiagnostic.Create(TagHelper_EmptyBoundAttribute, location, attributeName, tagName, propertyTypeName); + } + + internal static readonly RazorDiagnosticDescriptor TagHelper_CannotHaveNonTagContent = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}2009", + () => Resources.TagHelperParseTreeRewriter_CannotHaveNonTagContent, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateTagHelper_CannotHaveNonTagContent(SourceSpan location, string tagName, string allowedChildren) + { + return RazorDiagnostic.Create(TagHelper_CannotHaveNonTagContent, location, tagName, allowedChildren); + } + + internal static readonly RazorDiagnosticDescriptor TagHelper_InvalidNestedTag = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}2010", + () => Resources.TagHelperParseTreeRewriter_InvalidNestedTag, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateTagHelper_InvalidNestedTag(SourceSpan location, string tagName, string parent, string allowedChildren) + { + return RazorDiagnostic.Create(TagHelper_InvalidNestedTag, location, tagName, parent, allowedChildren); + } + + internal static readonly RazorDiagnosticDescriptor TagHelper_InconsistentTagStructure = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}2011", + () => Resources.TagHelperParseTreeRewriter_InconsistentTagStructure, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateTagHelper_InconsistentTagStructure(SourceSpan location, string firstDescriptor, string secondDescriptor, string tagName) + { + return RazorDiagnostic.Create(TagHelper_InconsistentTagStructure, location, firstDescriptor, secondDescriptor, tagName, nameof(TagMatchingRuleDescriptor.TagStructure)); + } + #endregion #region TagHelper Errors @@ -116,7 +610,7 @@ namespace Microsoft.AspNetCore.Razor.Language () => Resources.TagHelper_InvalidBoundAttributeName, RazorDiagnosticSeverity.Error); public static RazorDiagnostic CreateTagHelper_InvalidBoundAttributeName( - string tagHelperDisplayName, + string tagHelperDisplayName, string propertyDisplayName, string invalidName, char invalidCharacter) @@ -258,7 +752,7 @@ namespace Microsoft.AspNetCore.Razor.Language internal static readonly RazorDiagnosticDescriptor TagHelper_InvalidTargetedAttributeNameNullOrWhitespace = new RazorDiagnosticDescriptor( - $"{DiagnosticPrefix}3009", + $"{DiagnosticPrefix}3011", () => Resources.TagHelper_InvalidTargetedAttributeNameNullOrWhitespace, RazorDiagnosticSeverity.Error); public static RazorDiagnostic CreateTagHelper_InvalidTargetedAttributeNameNullOrWhitespace() @@ -272,7 +766,7 @@ namespace Microsoft.AspNetCore.Razor.Language internal static readonly RazorDiagnosticDescriptor TagHelper_InvalidTargetedAttributeName = new RazorDiagnosticDescriptor( - $"{DiagnosticPrefix}3010", + $"{DiagnosticPrefix}3012", () => Resources.TagHelper_InvalidTargetedAttributeName, RazorDiagnosticSeverity.Error); public static RazorDiagnostic CreateTagHelper_InvalidTargetedAttributeName(string invalidAttributeName, char invalidCharacter) diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorEngine.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorEngine.cs index aa06b9f9ab..13f2f6be73 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorEngine.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorEngine.cs @@ -3,6 +3,8 @@ using System; using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Razor.Language.Extensions; @@ -15,33 +17,33 @@ namespace Microsoft.AspNetCore.Razor.Language return Create(configure: null); } - public static RazorEngine Create(Action configure) => CreateCore(RazorConfiguration.Default, configure); + public static RazorEngine Create(Action configure) => CreateCore(RazorConfiguration.Default, false, configure); public static RazorEngine CreateDesignTime() { return CreateDesignTime(configure: null); } - public static RazorEngine CreateDesignTime(Action configure) => CreateCore(RazorConfiguration.DefaultDesignTime, configure); + public static RazorEngine CreateDesignTime(Action configure) => CreateCore(RazorConfiguration.Default, true, configure); // Internal since RazorEngine APIs are going to be obsolete. - internal static RazorEngine CreateCore(RazorConfiguration configuration, Action configure) + internal static RazorEngine CreateCore(RazorConfiguration configuration, bool designTime, Action configure) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } - var builder = new DefaultRazorEngineBuilder(configuration.DesignTime); + var builder = new DefaultRazorEngineBuilder(designTime); AddDefaults(builder); - if (configuration.DesignTime) + if (designTime) { - AddDesignTimeDefaults(configuration, builder); + AddDefaultDesignTimeFeatures(configuration, builder.Features); } else { - AddRuntimeDefaults(configuration, builder); + AddDefaultRuntimeFeatures(configuration, builder.Features); } configure?.Invoke(builder); @@ -50,37 +52,66 @@ namespace Microsoft.AspNetCore.Razor.Language public static RazorEngine CreateEmpty(Action configure) { + if (configure == null) + { + throw new ArgumentNullException(nameof(configure)); + } + var builder = new DefaultRazorEngineBuilder(designTime: false); - configure?.Invoke(builder); + configure(builder); + return builder.Build(); + } + + public static RazorEngine CreateDesignTimeEmpty(Action configure) + { + if (configure == null) + { + throw new ArgumentNullException(nameof(configure)); + } + + var builder = new DefaultRazorEngineBuilder(designTime: true); + configure(builder); return builder.Build(); } internal static void AddDefaults(IRazorEngineBuilder builder) { - builder.Phases.Add(new DefaultRazorParsingPhase()); - builder.Phases.Add(new DefaultRazorSyntaxTreePhase()); - builder.Phases.Add(new DefaultRazorTagHelperBinderPhase()); - builder.Phases.Add(new DefaultRazorIntermediateNodeLoweringPhase()); - builder.Phases.Add(new DefaultRazorDocumentClassifierPhase()); - builder.Phases.Add(new DefaultRazorDirectiveClassifierPhase()); - builder.Phases.Add(new DefaultRazorOptimizationPhase()); - builder.Phases.Add(new DefaultRazorCSharpLoweringPhase()); + AddDefaultPhases(builder.Phases); + AddDefaultFeatures(builder.Features); + } + internal static void AddDefaultPhases(IList phases) + { + phases.Add(new DefaultRazorParsingPhase()); + phases.Add(new DefaultRazorSyntaxTreePhase()); + phases.Add(new DefaultRazorTagHelperBinderPhase()); + phases.Add(new DefaultRazorIntermediateNodeLoweringPhase()); + phases.Add(new DefaultRazorDocumentClassifierPhase()); + phases.Add(new DefaultRazorDirectiveClassifierPhase()); + phases.Add(new DefaultRazorOptimizationPhase()); + phases.Add(new DefaultRazorCSharpLoweringPhase()); + } + + internal static void AddDefaultFeatures(ICollection features) + { // General extensibility - builder.Features.Add(new DefaultRazorDirectiveFeature()); - builder.Features.Add(new DefaultRazorTargetExtensionFeature()); + features.Add(new DefaultRazorDirectiveFeature()); + var targetExtensionFeature = new DefaultRazorTargetExtensionFeature(); + features.Add(targetExtensionFeature); + features.Add(new DefaultMetadataIdentifierFeature()); // Syntax Tree passes - builder.Features.Add(new DefaultDirectiveSyntaxTreePass()); - builder.Features.Add(new HtmlNodeOptimizationPass()); + features.Add(new DefaultDirectiveSyntaxTreePass()); + features.Add(new HtmlNodeOptimizationPass()); // Intermediate Node Passes - builder.Features.Add(new DefaultDocumentClassifierPass()); - builder.Features.Add(new DirectiveRemovalOptimizationPass()); - builder.Features.Add(new DefaultTagHelperOptimizationPass()); + features.Add(new DefaultDocumentClassifierPass()); + features.Add(new MetadataAttributePass()); + features.Add(new DirectiveRemovalOptimizationPass()); + features.Add(new DefaultTagHelperOptimizationPass()); // Default Code Target Extensions - // (currently none) + targetExtensionFeature.TargetExtensions.Add(new MetadataAttributeTargetExtension()); // Default configuration var configurationFeature = new DefaultDocumentClassifierPassFeature(); @@ -105,36 +136,42 @@ namespace Microsoft.AspNetCore.Razor.Language method.Modifiers.Add("override"); }); - builder.Features.Add(configurationFeature); + features.Add(configurationFeature); } - internal static void AddRuntimeDefaults(RazorConfiguration configuration, IRazorEngineBuilder builder) + internal static void AddDefaultRuntimeFeatures(RazorConfiguration configuration, ICollection features) { // Configure options - builder.Features.Add(new DefaultRazorParserOptionsFeature(designTime: false, version: configuration.LanguageVersion)); - builder.Features.Add(new DefaultRazorCodeGenerationOptionsFeature(designTime: false)); + features.Add(new DefaultRazorParserOptionsFeature(designTime: false, version: configuration.LanguageVersion)); + features.Add(new DefaultRazorCodeGenerationOptionsFeature(designTime: false)); // Intermediate Node Passes - builder.Features.Add(new PreallocatedTagHelperAttributeOptimizationPass()); + features.Add(new PreallocatedTagHelperAttributeOptimizationPass()); // Code Target Extensions - builder.AddTargetExtension(new DefaultTagHelperTargetExtension() { DesignTime = false }); - builder.AddTargetExtension(new PreallocatedAttributeTargetExtension()); + var targetExtension = features.OfType().FirstOrDefault(); + Debug.Assert(targetExtension != null); + + targetExtension.TargetExtensions.Add(new DefaultTagHelperTargetExtension()); + targetExtension.TargetExtensions.Add(new PreallocatedAttributeTargetExtension()); } - internal static void AddDesignTimeDefaults(RazorConfiguration configuration, IRazorEngineBuilder builder) + internal static void AddDefaultDesignTimeFeatures(RazorConfiguration configuration, ICollection features) { // Configure options - builder.Features.Add(new DefaultRazorParserOptionsFeature(designTime: true, version: configuration.LanguageVersion)); - builder.Features.Add(new DefaultRazorCodeGenerationOptionsFeature(designTime: true)); - builder.Features.Add(new SuppressChecksumOptionsFeature()); + features.Add(new DefaultRazorParserOptionsFeature(designTime: true, version: configuration.LanguageVersion)); + features.Add(new DefaultRazorCodeGenerationOptionsFeature(designTime: true)); + features.Add(new SuppressChecksumOptionsFeature()); // Intermediate Node Passes - builder.Features.Add(new DesignTimeDirectivePass()); + features.Add(new DesignTimeDirectivePass()); // Code Target Extensions - builder.AddTargetExtension(new DefaultTagHelperTargetExtension() { DesignTime = true }); - builder.AddTargetExtension(new DesignTimeDirectiveTargetExtension()); + var targetExtension = features.OfType().FirstOrDefault(); + Debug.Assert(targetExtension != null); + + targetExtension.TargetExtensions.Add(new DefaultTagHelperTargetExtension()); + targetExtension.TargetExtensions.Add(new DesignTimeDirectiveTargetExtension()); } public abstract IReadOnlyList Features { get; } @@ -144,3 +181,4 @@ namespace Microsoft.AspNetCore.Razor.Language public abstract void Process(RazorCodeDocument document); } } + diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorExtensionInitializer.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorExtensionInitializer.cs new file mode 100644 index 0000000000..5117115af6 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorExtensionInitializer.cs @@ -0,0 +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. + +namespace Microsoft.AspNetCore.Razor.Language +{ + public abstract class RazorExtensionInitializer + { + public abstract void Initialize(RazorProjectEngineBuilder builder); + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorParserOptionsBuilder.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorParserOptionsBuilder.cs index 74b11fcc26..b036e3d58d 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorParserOptionsBuilder.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorParserOptionsBuilder.cs @@ -1,21 +1,26 @@ // 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.Collections.Generic; namespace Microsoft.AspNetCore.Razor.Language { public abstract class RazorParserOptionsBuilder { + public virtual RazorConfiguration Configuration => null; + public abstract bool DesignTime { get; } public abstract ICollection Directives { get; } public abstract bool ParseLeadingDirectives { get; set; } - public virtual RazorLanguageVersion Version { get; } + public virtual RazorLanguageVersion LanguageVersion { get; } public abstract RazorParserOptions Build(); + + public virtual void SetDesignTime(bool designTime) + { + } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorProject.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorProject.cs index 473e6382e1..74b772e142 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorProject.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorProject.cs @@ -129,9 +129,10 @@ namespace Microsoft.AspNetCore.Razor.Language /// /// The directory to root the file system at. /// A + [Obsolete("This method is obsolete and will be removed in a future version. Please use " + nameof(RazorProjectFileSystem) + "." + nameof(RazorProjectFileSystem.Create) + " instead.")] public static RazorProject Create(string rootDirectoryPath) { - return new FileSystemRazorProject(rootDirectoryPath); + return new DefaultRazorProjectFileSystem(rootDirectoryPath); } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngine.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngine.cs new file mode 100644 index 0000000000..e76bdffc94 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngine.cs @@ -0,0 +1,188 @@ +// 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.Collections.Generic; +using System.Reflection; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.Language.Extensions; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public abstract class RazorProjectEngine + { + public abstract RazorConfiguration Configuration { get; } + + public abstract RazorProjectFileSystem FileSystem { get; } + + public abstract RazorEngine Engine { get; } + + public IReadOnlyList EngineFeatures => Engine.Features; + + public IReadOnlyList Phases => Engine.Phases; + + public abstract IReadOnlyList ProjectFeatures { get; } + + public virtual RazorCodeDocument Process(RazorProjectItem projectItem) + { + if (projectItem == null) + { + throw new ArgumentNullException(nameof(projectItem)); + } + + var codeDocument = CreateCodeDocumentCore(projectItem); + ProcessCore(codeDocument); + return codeDocument; + } + + public virtual RazorCodeDocument ProcessDesignTime(RazorProjectItem projectItem) + { + if (projectItem == null) + { + throw new ArgumentNullException(nameof(projectItem)); + } + + var codeDocument = CreateCodeDocumentDesignTimeCore(projectItem); + ProcessCore(codeDocument); + return codeDocument; + } + + protected abstract RazorCodeDocument CreateCodeDocumentCore(RazorProjectItem projectItem); + + protected abstract RazorCodeDocument CreateCodeDocumentDesignTimeCore(RazorProjectItem projectItem); + + protected abstract void ProcessCore(RazorCodeDocument codeDocument); + + public static RazorProjectEngine Create(RazorConfiguration configuration, RazorProjectFileSystem fileSystem) => Create(configuration, fileSystem, configure: null); + + public static RazorProjectEngine Create( + RazorConfiguration configuration, + RazorProjectFileSystem fileSystem, + Action configure) + { + if (fileSystem == null) + { + throw new ArgumentNullException(nameof(fileSystem)); + } + + if (configuration == null) + { + throw new ArgumentNullException(nameof(configuration)); + } + + var builder = new DefaultRazorProjectEngineBuilder(configuration, fileSystem); + + // The intialization order is somewhat important. + // + // Defaults -> Extensions -> Additional customization + // + // This allows extensions to rely on default features, and customizations to override choices made by + // extensions. + RazorEngine.AddDefaultPhases(builder.Phases); + AddDefaultsFeatures(builder.Features); + + LoadExtensions(builder, configuration.Extensions); + + configure?.Invoke(builder); + + return builder.Build(); + } + + private static void AddDefaultsFeatures(ICollection features) + { + features.Add(new DefaultImportProjectFeature()); + + // General extensibility + features.Add(new DefaultRazorDirectiveFeature()); + features.Add(new DefaultMetadataIdentifierFeature()); + + // Options features + features.Add(new DefaultRazorParserOptionsFactoryProjectFeature()); + features.Add(new DefaultRazorCodeGenerationOptionsFactoryProjectFeature()); + + // Legacy options features + // + // These features are obsolete as of 2.1. Our code will resolve this but not invoke them. + features.Add(new DefaultRazorParserOptionsFeature(designTime: false, version: RazorLanguageVersion.Version_2_0)); + features.Add(new DefaultRazorCodeGenerationOptionsFeature(designTime: false)); + + // Syntax Tree passes + features.Add(new DefaultDirectiveSyntaxTreePass()); + features.Add(new HtmlNodeOptimizationPass()); + features.Add(new PreallocatedTagHelperAttributeOptimizationPass()); + + // Intermediate Node Passes + features.Add(new DefaultDocumentClassifierPass()); + features.Add(new MetadataAttributePass()); + features.Add(new DesignTimeDirectivePass()); + features.Add(new DirectiveRemovalOptimizationPass()); + features.Add(new DefaultTagHelperOptimizationPass()); + + // Default Code Target Extensions + var targetExtensionFeature = new DefaultRazorTargetExtensionFeature(); + features.Add(targetExtensionFeature); + targetExtensionFeature.TargetExtensions.Add(new MetadataAttributeTargetExtension()); + targetExtensionFeature.TargetExtensions.Add(new DefaultTagHelperTargetExtension()); + targetExtensionFeature.TargetExtensions.Add(new PreallocatedAttributeTargetExtension()); + targetExtensionFeature.TargetExtensions.Add(new DesignTimeDirectiveTargetExtension()); + + // Default configuration + var configurationFeature = new DefaultDocumentClassifierPassFeature(); + features.Add(configurationFeature); + configurationFeature.ConfigureClass.Add((document, @class) => + { + @class.ClassName = "Template"; + @class.Modifiers.Add("public"); + }); + + configurationFeature.ConfigureNamespace.Add((document, @namespace) => + { + @namespace.Content = "Razor"; + }); + + configurationFeature.ConfigureMethod.Add((document, method) => + { + method.MethodName = "ExecuteAsync"; + method.ReturnType = $"global::{typeof(Task).FullName}"; + + method.Modifiers.Add("public"); + method.Modifiers.Add("async"); + method.Modifiers.Add("override"); + }); + } + + private static void LoadExtensions(RazorProjectEngineBuilder builder, IReadOnlyList extensions) + { + for (var i = 0; i < extensions.Count; i++) + { + // For now we only handle AssemblyExtension - which is not user-constructable. We're keeping a tight + // lid on how things work until we add official support for extensibility everywhere. So, this is + // intentionally inflexible for the time being. + var extension = extensions[i] as AssemblyExtension; + if (extension == null) + { + continue; + } + + // It's not an error to have an assembly with no initializers. This is useful to specify a dependency + // that doesn't really provide any Razor configuration. + var attributes = extension.Assembly.GetCustomAttributes(); + foreach (var attribute in attributes) + { + // Using extension names and requiring them to line up allows a single assembly to ship multiple + // extensions/initializers for different configurations. + if (!string.Equals(attribute.ExtensionName, extension.ExtensionName, StringComparison.Ordinal)) + { + continue; + } + + // There's no real protection/exception handling here because this set isn't really user-extensible + // right now. This would be a great place to add some additional diagnostics and hardening in the + // future. + var initializer = (RazorExtensionInitializer)Activator.CreateInstance(attribute.InitializerType); + initializer.Initialize(builder); + } + } + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilder.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilder.cs new file mode 100644 index 0000000000..9fe4356fa9 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilder.cs @@ -0,0 +1,20 @@ +// 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 Microsoft.AspNetCore.Razor.Language +{ + public abstract class RazorProjectEngineBuilder + { + public abstract RazorConfiguration Configuration { get; } + + public abstract RazorProjectFileSystem FileSystem { get; } + + public abstract ICollection Features { get; } + + public abstract IList Phases { get; } + + public abstract RazorProjectEngine Build(); + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilderExtensions.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilderExtensions.cs new file mode 100644 index 0000000000..48695a6f97 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilderExtensions.cs @@ -0,0 +1,234 @@ +// 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.Collections.Generic; +using System.IO; +using System.Linq; +using Microsoft.AspNetCore.Razor.Language.CodeGeneration; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public static class RazorProjectEngineBuilderExtensions + { + /// + /// Registers a class configuration delegate that gets invoked during code generation. + /// + /// The . + /// invoked to configure + /// during code generation. + /// The . + public static RazorProjectEngineBuilder ConfigureClass( + this RazorProjectEngineBuilder builder, + Action configureClass) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + if (configureClass == null) + { + throw new ArgumentNullException(nameof(configureClass)); + } + + var configurationFeature = GetDefaultDocumentClassifierPassFeature(builder); + configurationFeature.ConfigureClass.Add(configureClass); + return builder; + } + + /// + /// Sets the base type for generated types. + /// + /// The . + /// The name of the base type. + /// The . + public static RazorProjectEngineBuilder SetBaseType(this RazorProjectEngineBuilder builder, string baseType) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + var configurationFeature = GetDefaultDocumentClassifierPassFeature(builder); + configurationFeature.ConfigureClass.Add((document, @class) => @class.BaseType = baseType); + return builder; + } + + /// + /// Sets the namespace for generated types. + /// + /// The . + /// The name of the namespace. + /// The . + public static RazorProjectEngineBuilder SetNamespace(this RazorProjectEngineBuilder builder, string namespaceName) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + var configurationFeature = GetDefaultDocumentClassifierPassFeature(builder); + configurationFeature.ConfigureNamespace.Add((document, @namespace) => @namespace.Content = namespaceName); + return builder; + } + + public static void SetImportFeature(this RazorProjectEngineBuilder builder, IImportProjectFeature feature) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + if (feature == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + // Remove any existing import features in favor of the new one we're given. + var existingFeatures = builder.Features.OfType().ToArray(); + foreach (var existingFeature in existingFeatures) + { + builder.Features.Remove(existingFeature); + } + + builder.Features.Add(feature); + } + + /// + /// Adds the specified . + /// + /// The . + /// The to add. + /// The . + public static RazorProjectEngineBuilder AddTargetExtension(this RazorProjectEngineBuilder builder, ICodeTargetExtension extension) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + if (extension == null) + { + throw new ArgumentNullException(nameof(extension)); + } + + var targetExtensionFeature = GetTargetExtensionFeature(builder); + targetExtensionFeature.TargetExtensions.Add(extension); + + return builder; + } + + /// + /// Adds the specified . + /// + /// The . + /// The to add. + /// The . + public static RazorProjectEngineBuilder AddDirective(this RazorProjectEngineBuilder builder, DirectiveDescriptor directive) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + if (directive == null) + { + throw new ArgumentNullException(nameof(directive)); + } + + var directiveFeature = GetDirectiveFeature(builder); + directiveFeature.Directives.Add(directive); + + return builder; + } + + /// + /// Adds the provided s as imports to all project items processed + /// by the . + /// + /// The . + /// The collection of imports. + /// The . + public static RazorProjectEngineBuilder AddDefaultImports(this RazorProjectEngineBuilder builder, params RazorProjectItem[] imports) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + var existingImportFeature = builder.Features.OfType().First(); + var testImportFeature = new AdditionalImportsProjectFeature(existingImportFeature, imports); + builder.SetImportFeature(testImportFeature); + + return builder; + } + + private static IRazorDirectiveFeature GetDirectiveFeature(RazorProjectEngineBuilder builder) + { + var directiveFeature = builder.Features.OfType().FirstOrDefault(); + if (directiveFeature == null) + { + directiveFeature = new DefaultRazorDirectiveFeature(); + builder.Features.Add(directiveFeature); + } + + return directiveFeature; + } + + private static IRazorTargetExtensionFeature GetTargetExtensionFeature(RazorProjectEngineBuilder builder) + { + var targetExtensionFeature = builder.Features.OfType().FirstOrDefault(); + if (targetExtensionFeature == null) + { + targetExtensionFeature = new DefaultRazorTargetExtensionFeature(); + builder.Features.Add(targetExtensionFeature); + } + + return targetExtensionFeature; + } + + private static DefaultDocumentClassifierPassFeature GetDefaultDocumentClassifierPassFeature(RazorProjectEngineBuilder builder) + { + var configurationFeature = builder.Features.OfType().FirstOrDefault(); + if (configurationFeature == null) + { + configurationFeature = new DefaultDocumentClassifierPassFeature(); + builder.Features.Add(configurationFeature); + } + + return configurationFeature; + } + + private class AdditionalImportsProjectFeature : RazorProjectEngineFeatureBase, IImportProjectFeature + { + private readonly IImportProjectFeature _existingImportFeature; + private readonly RazorProjectItem[] _imports; + + public override RazorProjectEngine ProjectEngine + { + get => base.ProjectEngine; + set + { + _existingImportFeature.ProjectEngine = value; + base.ProjectEngine = value; + } + } + + public AdditionalImportsProjectFeature(IImportProjectFeature existingImportFeature, params RazorProjectItem[] imports) + { + _existingImportFeature = existingImportFeature; + _imports = imports; + } + + public IReadOnlyList GetImports(RazorProjectItem projectItem) + { + var imports = _existingImportFeature.GetImports(projectItem).ToList(); + imports.AddRange(_imports); + + return imports; + } + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineFeatureBase.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineFeatureBase.cs new file mode 100644 index 0000000000..ec170659e4 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineFeatureBase.cs @@ -0,0 +1,31 @@ +// 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; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public abstract class RazorProjectEngineFeatureBase : IRazorProjectEngineFeature + { + private RazorProjectEngine _projectEngine; + + public virtual RazorProjectEngine ProjectEngine + { + get => _projectEngine; + set + { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + _projectEngine = value; + OnInitialized(); + } + } + + protected virtual void OnInitialized() + { + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectFileSystem.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectFileSystem.cs new file mode 100644 index 0000000000..799c6bda65 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectFileSystem.cs @@ -0,0 +1,27 @@ +// 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; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public abstract class RazorProjectFileSystem : RazorProject + { + internal static readonly RazorProjectFileSystem Empty = new EmptyProjectFileSystem(); + + /// + /// Create a Razor project file system based off of a root directory. + /// + /// The directory to root the file system at. + /// A + public new static RazorProjectFileSystem Create(string rootDirectoryPath) + { + if (string.IsNullOrEmpty(rootDirectoryPath)) + { + throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(rootDirectoryPath)); + } + + return new DefaultRazorProjectFileSystem(rootDirectoryPath); + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectItem.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectItem.cs index 67b0e04dfd..6aecb94daa 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectItem.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectItem.cs @@ -7,7 +7,7 @@ using System.IO; namespace Microsoft.AspNetCore.Razor.Language { /// - /// An item in . + /// An item in a . /// [DebuggerDisplay("{" + nameof(DebuggerToString) + "()}")] public abstract class RazorProjectItem @@ -18,15 +18,23 @@ namespace Microsoft.AspNetCore.Razor.Language public abstract string BasePath { get; } /// - /// File path relative to . + /// File path relative to . This property uses the project path syntax, + /// using / as a path separator and does not follow the operating system's file system + /// conventions. /// public abstract string FilePath { get; } /// - /// The absolute path to the file, including the file name. + /// The absolute physical (file system) path to the file, including the file name. /// public abstract string PhysicalPath { get; } + /// + /// The relative physical (file system) path to the file, including the file name. Relative to the + /// physical path of the . + /// + public virtual string RelativePhysicalPath => null; + /// /// Gets the file contents as readonly . /// diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorSourceDocument.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorSourceDocument.cs index 868e25db88..31acb7dfd6 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorSourceDocument.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorSourceDocument.cs @@ -3,6 +3,7 @@ using System; using System.IO; +using System.Security.Cryptography; using System.Text; namespace Microsoft.AspNetCore.Razor.Language @@ -17,15 +18,33 @@ namespace Microsoft.AspNetCore.Razor.Language internal static readonly RazorSourceDocument[] EmptyArray = new RazorSourceDocument[0]; /// - /// Encoding of the file that the text was read from. + /// Gets the encoding of the text in the original source document. /// + /// + /// Depending on the method used to create a the encoding may be used to + /// read the file contents, or it may be solely informational. Refer to the documentation on the method + /// used to create the for details. + /// public abstract Encoding Encoding { get; } /// - /// Path of the file the content was read from. + /// Gets the file path of the orginal source document. /// + /// + /// The file path may be either an absolute path or project-relative path. An absolute path is required + /// to generate debuggable assemblies. + /// public abstract string FilePath { get; } + /// + /// Gets the project-relative path to the source file. May be null. + /// + /// + /// The relative path (if provided) is used for display (error messages). The project-relative path may also + /// be used to embed checksums of the original source documents to support runtime recompilation of Razor code. + /// + public virtual string RelativePath => null; + /// /// Gets a character at given position. /// @@ -57,6 +76,29 @@ namespace Microsoft.AspNetCore.Razor.Language /// The checksum. public abstract byte[] GetChecksum(); + /// + /// Gets the name of the algorithm used to compute the checksum returned by . + /// + /// + /// This member did not exist in the 2.0 release, so it is possible for an implementation to return + /// the wrong value (or null). Implementations of should + /// override this member and specify their choice of hash algorithm even if it is the same as the + /// default (SHA1). + /// + public virtual string GetChecksumAlgorithm() + { + return HashAlgorithmName.SHA1.Name; + } + + /// + /// Gets the file path in a format that should be used for display. + /// + /// The if set, or the . + public virtual string GetFilePathForDisplay() + { + return RelativePath ?? FilePath; + } + /// /// Reads the from the specified . /// @@ -70,7 +112,8 @@ namespace Microsoft.AspNetCore.Razor.Language throw new ArgumentNullException(nameof(stream)); } - return new StreamSourceDocument(stream, encoding: null, fileName: fileName); + var properties = new RazorSourceDocumentProperties(fileName, relativePath: null); + return new StreamSourceDocument(stream, null, properties); } /// @@ -92,7 +135,35 @@ namespace Microsoft.AspNetCore.Razor.Language throw new ArgumentNullException(nameof(encoding)); } - return new StreamSourceDocument(stream, encoding, fileName); + var properties = new RazorSourceDocumentProperties(fileName, relativePath: null); + return new StreamSourceDocument(stream, encoding, properties); + } + + /// + /// Reads the from the specified . + /// + /// The to read from. + /// The to use to read the . + /// Properties to configure the . + /// The . + public static RazorSourceDocument ReadFrom(Stream stream, Encoding encoding, RazorSourceDocumentProperties properties) + { + if (stream == null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (encoding == null) + { + throw new ArgumentNullException(nameof(encoding)); + } + + if (properties == null) + { + throw new ArgumentNullException(nameof(properties)); + } + + return new StreamSourceDocument(stream, encoding, properties); } /// @@ -107,32 +178,73 @@ namespace Microsoft.AspNetCore.Razor.Language throw new ArgumentNullException(nameof(projectItem)); } - var path = projectItem.PhysicalPath; - if (string.IsNullOrEmpty(path)) + // ProjectItem.PhysicalPath is usually an absolute (rooted) path. + var filePath = projectItem.PhysicalPath; + if (string.IsNullOrEmpty(filePath)) { - path = projectItem.FilePath; + // Fall back to the relative path only if necessary. + filePath = projectItem.RelativePhysicalPath; } - using (var inputStream = projectItem.Read()) + if (string.IsNullOrEmpty(filePath)) { - return ReadFrom(inputStream, path); + // Then fall back to the FilePath (yeah it's a bad name) which is like an MVC view engine path + // It's much better to have something than nothing. + filePath = projectItem.FilePath; + } + + using (var stream = projectItem.Read()) + { + // Autodetect the encoding. + var relativePath = projectItem.RelativePhysicalPath ?? projectItem.FilePath; + return new StreamSourceDocument(stream, null, new RazorSourceDocumentProperties(filePath, relativePath)); } } /// /// Creates a from the specified . /// - /// The template content. + /// The source document content. /// The file name of the . /// The . /// Uses public static RazorSourceDocument Create(string content, string fileName) - => Create(content, fileName, Encoding.UTF8); + { + if (content == null) + { + throw new ArgumentNullException(nameof(content)); + } + + return Create(content, fileName, Encoding.UTF8); + } + /// /// Creates a from the specified . /// - /// The template content. + /// The source document content. + /// Properties to configure the . + /// The . + /// Uses + public static RazorSourceDocument Create(string content, RazorSourceDocumentProperties properties) + { + if (content == null) + { + throw new ArgumentNullException(nameof(content)); + } + + if (properties == null) + { + throw new ArgumentNullException(nameof(properties)); + } + + return Create(content, Encoding.UTF8, properties); + } + + /// + /// Creates a from the specified . + /// + /// The source document content. /// The file name of the . /// The of the file was read from. /// The . @@ -148,7 +260,35 @@ namespace Microsoft.AspNetCore.Razor.Language throw new ArgumentNullException(nameof(encoding)); } - return new StringSourceDocument(content, encoding, fileName); + var properties = new RazorSourceDocumentProperties(fileName, relativePath: null); + return new StringSourceDocument(content, encoding, properties); + } + + /// + /// Creates a from the specified . + /// + /// The source document content. + /// The encoding of the source document. + /// Properties to configure the . + /// The . + public static RazorSourceDocument Create(string content, Encoding encoding, RazorSourceDocumentProperties properties) + { + if (content == null) + { + throw new ArgumentNullException(nameof(content)); + } + + if (encoding == null) + { + throw new ArgumentNullException(nameof(encoding)); + } + + if (properties == null) + { + throw new ArgumentNullException(nameof(properties)); + } + + return new StringSourceDocument(content, encoding, properties); } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorSourceDocumentProperties.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorSourceDocumentProperties.cs new file mode 100644 index 0000000000..ed48c00181 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorSourceDocumentProperties.cs @@ -0,0 +1,57 @@ +// 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.AspNetCore.Razor.Language +{ + /// + /// Use to configure optional properties for creating a . + /// + public sealed class RazorSourceDocumentProperties + { + /// + /// A with default values. + /// + internal static readonly RazorSourceDocumentProperties Default = new RazorSourceDocumentProperties(); + + /// + /// Creates a new . + /// + public RazorSourceDocumentProperties() + { + } + + /// + /// Creates a new . + /// + /// + /// The path to the source file. Provide an rooted path if possible. May be null. + /// + /// + /// The project-relative path to the source file. May be null. Must be a non-rooted path. + /// + public RazorSourceDocumentProperties(string filePath, string relativePath) + { + // We don't do any magic or validation here since we don't need to do any I/O or interation + // with the file system. We didn't validate anything in 2.0 so we don't want any compat risk. + FilePath = filePath; + RelativePath = relativePath; + } + + /// + /// Gets the path to the source file. May be an absolute or project-relative path. May be null. + /// + /// + /// An absolute path must be provided to generate debuggable assemblies. + /// + public string FilePath { get; } + + /// + /// Gets the project-relative path to the source file. May be null. + /// + /// + /// The relative path (if provided) is used for display (error messages). The project-relative path may also + /// be used to embed checksums of the original source documents to support runtime recompilation of Razor code. + /// + public string RelativePath { get; } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorTemplateEngine.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorTemplateEngine.cs index 73bbb4d9cf..298666b56f 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorTemplateEngine.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorTemplateEngine.cs @@ -184,7 +184,6 @@ namespace Microsoft.AspNetCore.Razor.Language } var result = new List(); - var importProjectItems = GetImportItems(projectItem); foreach (var importItem in importProjectItems) { diff --git a/src/Microsoft.AspNetCore.Razor.Language/Resources.resx b/src/Microsoft.AspNetCore.Razor.Language/Resources.resx index 35b511066d..195a9d791b 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Resources.resx +++ b/src/Microsoft.AspNetCore.Razor.Language/Resources.resx @@ -117,45 +117,315 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Register Tag Helpers for use in the current document. + + + Add tag helpers from the specified type name and assembly name. Specify '*' for the type name to include all tag helper types from the specified assembly. + + + TypeName, AssemblyName + Value cannot be null or an empty string. + + Block cannot be built because a Type has not been specified in the BlockBuilder + + + Block directive '{0}' cannot be imported. + + + code + This is a literal used when composing ParserError_* messages. Most blocks are named by the keyword that starts them, for example "if". However, for those without keywords, a (localizable) name must be used. This literal is ALWAYS used mid-sentence, thus should not be capitalized. + + + explicit expression + This is a literal used when composing ParserError_* messages. Most blocks are named by the keyword that starts them, for example "if". However, for those without keywords, a (localizable) name must be used. This literal is ALWAYS used mid-sentence, thus should not be capitalized. + + + Invalid newline sequence '{0}'. Support newline sequences are '\r\n' and '\n'. + + + <<character literal>> + + + <<comment>> + + + <<identifier>> + + + <<integer literal>> + + + <<keyword>> + + + <<newline sequence>> + + + <<real literal>> + + + <<string literal>> + + + <<white space>> + + + The document type '{0}' does not support the extension '{1}'. + + + Invalid directive keyword '{0}'. Directives must have a non-empty keyword that consists only of letters. + + + A non-optional directive token cannot follow an optional directive token. + + + The '{0}' directive expects an identifier. + + + The '{0}' directive expects a namespace name. + + + The '{0}' directive expects a string surrounded by double quotes. + + + The '{0}' directive expects a type name. + + + The '{0}` directive must appear at the start of the line. + + + The '{0}' directives value(s) must be separated by whitespace. + + + The document of kind '{0}' does not have a '{1}'. The document classifier must set a value for '{2}'. + + + The '{0}' directive may only occur once per document. + + + "EndBlock" was called without a matching call to "StartBlock". + + + line break + The '{0}' feature requires a '{1}' provided by the '{2}'. + + The feature must be initialized by setting the '{0}' property. + + + Specify a C# code block. + + + <<newline sequence>> + + + <<razor comment>> + + + <<text>> + + + <<white space>> + + + Specify the base class for the current document. + + + The base type that the current page inherits. + + + TypeName + + + The '{0}' operation is not valid when the builder is empty. + + + The node '{0}' has a read-only child collection and cannot be modified. + + + The reference is invalid. The node '{0}' could not be found as a child of '{1}'. + + + The reference is invalid. References initialized with the default constructor cannot modify nodes. + + + The '{0}' node type can only be used as a direct child of a '{1}' node. + + + The node '{0}' is not the owner of change '{1}'. + Invalid tag helper directive look up text '{0}'. The correct look up text format is: "name, assemblyName". Invalid tag helper directive '{0}' value. '{1}' is not allowed in prefix '{2}'. - - The '{0}' operation is not valid when the builder is empty. + + The key must not be null. + + + Cannot use built-in RazorComment handler, language characteristics does not define the CommentStart, CommentStar and CommentBody known symbol types or parser does not override TokenizerBackedParser.OutputSpanBeforeRazorComment The specified encoding '{0}' does not match the content's encoding '{1}'. + + The "@" character must be followed by a ":", "(", or a C# identifier. If you intended to switch to markup, use an HTML start tag, for example: + +@if(isLoggedIn) {{ + <p>Hello, @user!</p> +}} + "{{" is an escape sequence for string.Format, when outputted to the user it will be displayed as "{" + + + End of file was reached before the end of the block comment. All comments started with "/*" sequence must be terminated with a matching "*/" sequence. + + + Directive '{0}' must have a value. + + + An opening "{0}" is missing the corresponding closing "{1}". + + + The {0} block is missing a closing "{1}" character. Make sure you have a matching "{1}" character for all the "{2}" characters within this block, and that none of the "{1}" characters are being interpreted as markup. + + + The {0} directive is not supported. + + + Optional quote around the directive '{0}' is missing the corresponding opening or closing quote. + + + Inline markup blocks (@<p>Content</p>) cannot be nested. Only one level of inline markup is allowed. + + + Markup in a code block must start with a tag and all start tags must be matched with end tags. Do not use unclosed tags like "<br>". Instead use self-closing tags like "<br/>". + + + The "{0}" element was not closed. All elements must be either self-closing or have a matching end tag. + + + Namespace imports and type aliases cannot be placed within code blocks. They must immediately follow an "@" character in markup. It is recommended that you put them at the top of the page, as in the following example: + +@using System.Drawing; +@{{ + // OK here to use types from System.Drawing in the page. +}} + "{{" is an escape sequence for string.Format, when outputted to the user it will be displayed as "{" + + + Outer tag is missing a name. The first character of a markup block must be an HTML tag with a valid name. + + + End of file was reached before the end of the block comment. All comments that start with the "@*" sequence must be terminated with a matching "*@" sequence. + + + "{0}" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. + + + Section blocks ("{0}") cannot be nested. Only one level of section blocks are allowed. + + + Expected a "{0}" but found a "{1}". Block statements must be enclosed in "{{" and "}}". You cannot use single-statement control-flow statements in CSHTML pages. For example, the following is not allowed: + +@if(isLoggedIn) + <p>Hello, @user</p> + +Instead, wrap the contents of the block in "{{}}": + +@if(isLoggedIn) {{ + <p>Hello, @user</p> +}} + {0} is only ever a single character + + + "<text>" and "</text>" tags cannot contain attributes. + + + "{0}" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{{" are valid. + "{{" is an escape sequence for string.Format, when outputted to the user it will be displayed as "{" + + + End-of-file was found after the "@" character. "@" must be followed by a valid code block. If you want to output an "@", escape it using the sequence: "@@" + + + Unexpected "{{" after "@" character. Once inside the body of a code block (@if {{}}, @{{}}, etc.) you do not need to use "@{{" to switch to code. + "{{" is an escape sequence for string.Format, when outputted to the user it will be displayed as "{" + + + A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{{" are valid at the start of a code block and they must occur immediately following "@" with no space in between. + "{{" is an escape sequence for string.Format, when outputted to the user it will be displayed as "{" + + + Encountered end tag "{0}" with no matching start tag. Are your start/end tags properly balanced? + + + End of file or an unexpected character was reached before the "{0}" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("<br />") or have matching end tags ("<p>Hello</p>"). If you intended to display a "<" character, use the "&lt;" HTML entity. + + + Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. + + + Parser was started with a null Context property. The Context property must be set BEFORE calling any methods on the parser. + + + Cannot complete the tree, StartBlock must be called at least once. + + + Cannot complete the tree, there are still open blocks. + + + Cannot finish span, there is no current block. Call StartBlock at least once before finishing a span + The '{0}' phase requires a '{1}' provided by the '{2}'. The phase must be initialized by setting the '{0}' property. - - Tag helper directive assembly name cannot be null or empty. - Path must begin with a forward slash '/'. - - A non-optional directive token cannot follow an optional directive token. - - - The document of kind '{0}' does not have a '{1}'. The document classifier must set a value for '{2}'. - The item '{0}' could not be found. + + Remove Tag Helpers for use in the current document. + + + Remove tag helpers from the specified type name and assembly name. Specify '*' for the type name to remove all tag helper types from the specified assembly. + + + TypeName, AssemblyName + + + The '{0}' requires a '{1}' delegate to be set. + + + Attribute '{0}' on tag helper element '{1}' requires a value. Tag helper bound attributes of type '{2}' cannot be empty or contain only whitespace. + + + Define a section to be rendered in the configured layout page. + + + The name of the section. + + + SectionName + + + @section Header { ... } + In CSHTML, the @section keyword is case-sensitive and lowercase (as with all C# keywords) + + + <<unknown>> + Invalid tag helper bound property '{1}' on tag helper '{0}'. Tag helpers cannot bind to HTML attributes with name '{2}' because the name contains a '{3}' character. @@ -195,103 +465,81 @@ Targeted tag name cannot be null or whitespace. - - The node '{0}' is not the owner of change '{1}'. + + Tag helper directive assembly name cannot be null or empty. - - Invalid directive keyword '{0}'. Directives must have a non-empty keyword that consists only of letters. + + The tag helper attribute '{0}' in element '{1}' is missing a key. The syntax is '<{1} {0}{{ key }}="value">'. - - The feature must be initialized by setting the '{0}' property. + + TagHelper attributes must be well-formed. - - The document type '{0}' does not support the extension '{1}'. + + The parent <{0}> tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) '{1}' are allowed. - - The '{0}` directive must appear at the start of the line. + + Found an end tag (</{0}>) for tag helper '{1}' with tag structure that disallows an end tag ('{2}'). - - The '{0}' directives value(s) must be separated by whitespace. + + Tag helpers '{0}' and '{1}' targeting element '{2}' must not expect different {3} values. - - The key must not be null. - - - The reference is invalid. The node '{0}' could not be found as a child of '{1}'. - - - The reference is invalid. References initialized with the default constructor cannot modify nodes. - - - The node '{0}' has a read-only child collection and cannot be modified. - - - The '{0}' directive may only occur once per document. - - - Block directive '{0}' cannot be imported. - - - Unreachable code. This can happen when a new {0} is introduced. - - - The '{0}' requires a '{1}' delegate to be set. - - - The '{0}' node type can only be used as a direct child of a '{1}' node. - - - Invalid newline sequence '{0}'. Support newline sequences are '\r\n' and '\n'. - - - Register Tag Helpers for use in the current document. - - - Specify a C# code block. - - - Specify the base class for the current document. - - - Remove Tag Helpers for use in the current document. - - - Define a section to be rendered in the configured layout page. + + The <{0}> tag is not allowed by parent <{1}> tag helper. Only child tags with name(s) '{2}' are allowed. Specify a prefix that is required in an element name for it to be included in Tag Helper processing. - - Add tag helpers from the specified type name and assembly name. Specify '*' for the type name to include all tag helper types from the specified assembly. - - - TypeName, AssemblyName - - - The base type that the current page inherits. - - - TypeName - - - Remove tag helpers from the specified type name and assembly name. Specify '*' for the type name to remove all tag helper types from the specified assembly. - - - TypeName, AssemblyName - The tag prefix to apply to tag helpers. Prefix - - The name of the section. + + Tag Helper '{0}'s attributes must have names. - - SectionName + + The tag helper '{0}' must not have C# in the element's attribute declaration area. + + + Code blocks (e.g. @{{var variable = 23;}}) must not appear in non-string tag helper attribute values. + Already in an expression (code) context. If necessary an explicit expression (e.g. @(@readonly)) may be used. + + + Inline markup blocks (e.g. @<p>content</p>) must not appear in non-string tag helper attribute values. + Expected a '{0}' attribute value, not a string. + + + Found a malformed '{0}' tag helper. Tag helpers must have a start and end tag or be self closing. + + + Missing close angle for tag helper '{0}'. + + + Unreachable code. This can happen when a new {0} is introduced. + + + Unexpected literal following the '{0}' directive. Expected '{1}'. + + + Unexpected end of file following the '{0}' directive. Expected '{1}'. + + + The hash algorithm '{0}' is not supported for checksum generation. Supported algorithms are: '{1}'. Set '{2}' to '{3}' to suppress automatic checksum generation. + + + The '{0}.{1}' property must not be null. + + + The '{0}' is missing feature '{1}'. The Razor language version '{0}' is unrecognized or not supported by this version of Razor. + + File path '{0}' does not belong to the directory '{1}'. + + + The file path '{0}' is invalid. File path is the root relative path of the file starting with '/' and should not contain any '\' characters. + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Language/SourceLocation.cs b/src/Microsoft.AspNetCore.Razor.Language/SourceLocation.cs index bb5ac8b973..de58f7c2aa 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/SourceLocation.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/SourceLocation.cs @@ -116,9 +116,10 @@ namespace Microsoft.AspNetCore.Razor.Language /// public bool Equals(SourceLocation other) { - // LineIndex and CharacterIndex can be calculated from AbsoluteIndex and the document content. return string.Equals(FilePath, other.FilePath, StringComparison.Ordinal) && - AbsoluteIndex == other.AbsoluteIndex; + AbsoluteIndex == other.AbsoluteIndex && + LineIndex == other.LineIndex && + CharacterIndex == other.CharacterIndex; } public static bool operator==(SourceLocation left, SourceLocation right) diff --git a/src/Microsoft.AspNetCore.Razor.Language/SourceSpan.cs b/src/Microsoft.AspNetCore.Razor.Language/SourceSpan.cs index 970aab07b4..5da785c911 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/SourceSpan.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/SourceSpan.cs @@ -30,6 +30,11 @@ namespace Microsoft.AspNetCore.Razor.Language FilePath = filePath; } + public SourceSpan(int absoluteIndex, int lineIndex, int characterIndex, int length) + : this(filePath: null, absoluteIndex: absoluteIndex, lineIndex: lineIndex, characterIndex: characterIndex, length: length) + { + } + public int Length { get; } public int AbsoluteIndex { get; } diff --git a/src/Microsoft.AspNetCore.Razor.Language/StreamSourceDocument.cs b/src/Microsoft.AspNetCore.Razor.Language/StreamSourceDocument.cs index 2c0fab062c..1b9d239e7b 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/StreamSourceDocument.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/StreamSourceDocument.cs @@ -15,15 +15,21 @@ namespace Microsoft.AspNetCore.Razor.Language private readonly byte[] _checksum; - public StreamSourceDocument(Stream stream, Encoding encoding, string fileName) + public StreamSourceDocument(Stream stream, Encoding encoding, RazorSourceDocumentProperties properties) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } + if (properties == null) + { + throw new ArgumentNullException(nameof(properties)); + } + + // Notice we don't validate the encoding here. StreamSourceDocument can compute it. _checksum = ComputeChecksum(stream); - _innerSourceDocument = CreateInnerSourceDocument(stream, encoding, fileName); + _innerSourceDocument = CreateInnerSourceDocument(stream, encoding, properties); } public override char this[int position] => _innerSourceDocument[position]; @@ -36,6 +42,8 @@ namespace Microsoft.AspNetCore.Razor.Language public override RazorSourceLineCollection Lines => _innerSourceDocument.Lines; + public override string RelativePath => _innerSourceDocument.RelativePath; + public override void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count) => _innerSourceDocument.CopyTo(sourceIndex, destination, destinationIndex, count); @@ -58,7 +66,7 @@ namespace Microsoft.AspNetCore.Razor.Language } } - private static RazorSourceDocument CreateInnerSourceDocument(Stream stream, Encoding encoding, string fileName) + private static RazorSourceDocument CreateInnerSourceDocument(Stream stream, Encoding encoding, RazorSourceDocumentProperties properties) { var streamLength = (int)stream.Length; var content = string.Empty; @@ -98,14 +106,14 @@ namespace Microsoft.AspNetCore.Razor.Language reader, LargeObjectHeapLimitInChars, contentEncoding, - fileName); + properties); } content = reader.ReadToEnd(); } } - return new StringSourceDocument(content, contentEncoding, fileName); + return new StringSourceDocument(content, contentEncoding, properties); } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/StringSourceDocument.cs b/src/Microsoft.AspNetCore.Razor.Language/StringSourceDocument.cs index 5f528024c2..a89ac1b25a 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/StringSourceDocument.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/StringSourceDocument.cs @@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Razor.Language private readonly RazorSourceLineCollection _lines; private byte[] _checksum; - public StringSourceDocument(string content, Encoding encoding, string filePath) + public StringSourceDocument(string content, Encoding encoding, RazorSourceDocumentProperties properties) { if (content == null) { @@ -25,9 +25,15 @@ namespace Microsoft.AspNetCore.Razor.Language throw new ArgumentNullException(nameof(encoding)); } + if (properties == null) + { + throw new ArgumentNullException(nameof(properties)); + } + _content = content; Encoding = encoding; - FilePath = filePath; + FilePath = properties.FilePath; + RelativePath = properties.RelativePath; _lines = new DefaultRazorSourceLineCollection(this); } @@ -37,11 +43,13 @@ namespace Microsoft.AspNetCore.Razor.Language public override Encoding Encoding { get; } public override string FilePath { get; } - + public override int Length => _content.Length; public override RazorSourceLineCollection Lines => _lines; + public override string RelativePath { get; } + public override void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count) { if (destination == null) diff --git a/src/Microsoft.AspNetCore.Razor.Language/VirtualRazorProjectFileSystem.cs b/src/Microsoft.AspNetCore.Razor.Language/VirtualRazorProjectFileSystem.cs new file mode 100644 index 0000000000..6b3737fb73 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/VirtualRazorProjectFileSystem.cs @@ -0,0 +1,215 @@ +// 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.Collections.Generic; +using System.Diagnostics; +using System.Linq; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal class VirtualRazorProjectFileSystem : RazorProjectFileSystem + { + private readonly DirectoryNode _root = new DirectoryNode("/"); + + public override IEnumerable EnumerateItems(string basePath) + { + basePath = NormalizeAndEnsureValidPath(basePath); + var directory = _root.GetDirectory(basePath); + return directory?.EnumerateItems() ?? Enumerable.Empty(); + } + + public override RazorProjectItem GetItem(string path) + { + path = NormalizeAndEnsureValidPath(path); + return _root.GetItem(path) ?? new NotFoundProjectItem(string.Empty, path); + } + + public void Add(RazorProjectItem projectItem) + { + if (projectItem == null) + { + throw new ArgumentNullException(nameof(projectItem)); + } + + var filePath = NormalizeAndEnsureValidPath(projectItem.FilePath); + _root.AddFile(new FileNode(filePath, projectItem)); + } + + // Internal for testing + [DebuggerDisplay("{Path}")] + internal class DirectoryNode + { + public DirectoryNode(string path) + { + Path = path; + } + + public string Path { get; } + + public List Directories { get; } = new List(); + + public List Files { get; } = new List(); + + public void AddFile(FileNode fileNode) + { + var filePath = fileNode.Path; + if (!filePath.StartsWith(Path, StringComparison.OrdinalIgnoreCase)) + { + var message = Resources.FormatVirtualFileSystem_FileDoesNotBelongToDirectory(fileNode.Path, Path); + throw new InvalidOperationException(message); + } + + // Look for the first / that appears in the path after the current directory path. + var directoryPath = GetDirectoryPath(filePath); + var directory = GetOrAddDirectory(this, directoryPath, createIfNotExists: true); + Debug.Assert(directory != null); + directory.Files.Add(fileNode); + } + + public DirectoryNode GetDirectory(string path) + { + if (!path.StartsWith(Path, StringComparison.OrdinalIgnoreCase)) + { + var message = Resources.FormatVirtualFileSystem_FileDoesNotBelongToDirectory(path, Path); + throw new InvalidOperationException(message); + } + + return GetOrAddDirectory(this, path); + } + + public IEnumerable EnumerateItems() + { + foreach (var file in Files) + { + yield return file.ProjectItem; + } + + foreach (var directory in Directories) + { + foreach (var file in directory.EnumerateItems()) + { + yield return file; + } + } + } + + public RazorProjectItem GetItem(string path) + { + if (!path.StartsWith(Path, StringComparison.OrdinalIgnoreCase)) + { + throw new InvalidOperationException(Resources.FormatVirtualFileSystem_FileDoesNotBelongToDirectory(path, Path)); + } + + var directoryPath = GetDirectoryPath(path); + var directory = GetOrAddDirectory(this, directoryPath); + if (directory == null) + { + return null; + } + + foreach (var file in directory.Files) + { + var filePath = file.Path; + var directoryLength = directory.Path.Length; + + // path, filePath -> /Views/Home/Index.cshtml + // directory.Path -> /Views/Home/ + // We only need to match the file name portion since we've already matched the directory segment. + if (string.Compare(path, directoryLength, filePath, directoryLength, path.Length - directoryLength, StringComparison.OrdinalIgnoreCase) == 0) + { + return file.ProjectItem; + } + } + + return null; + } + + private static string GetDirectoryPath(string path) + { + // /dir1/dir2/file.cshtml -> /dir1/dir2/ + var fileNameIndex = path.LastIndexOf('/'); + if (fileNameIndex == -1) + { + return path; + } + + return path.Substring(0, fileNameIndex + 1); + } + + private static DirectoryNode GetOrAddDirectory( + DirectoryNode directory, + string path, + bool createIfNotExists = false) + { + Debug.Assert(!string.IsNullOrEmpty(path)); + if (path[path.Length - 1] != '/') + { + path += '/'; + } + + int index; + while ((index = path.IndexOf('/', directory.Path.Length)) != -1 && index != path.Length) + { + var subDirectory = FindSubDirectory(directory, path); + + if (subDirectory == null) + { + if (createIfNotExists) + { + var directoryPath = path.Substring(0, index + 1); // + 1 to include trailing slash + subDirectory = new DirectoryNode(directoryPath); + directory.Directories.Add(subDirectory); + } + else + { + return null; + } + } + + directory = subDirectory; + } + + return directory; + } + + private static DirectoryNode FindSubDirectory(DirectoryNode parentDirectory, string path) + { + for (var i = 0; i < parentDirectory.Directories.Count; i++) + { + // ParentDirectory.Path -> /Views/Home/ + // CurrentDirectory.Path -> /Views/Home/SubDir/ + // Path -> /Views/Home/SubDir/MorePath/File.cshtml + // Each invocation of FindSubDirectory returns the immediate subdirectory along the path to the file. + + var currentDirectory = parentDirectory.Directories[i]; + var directoryPath = currentDirectory.Path; + var startIndex = parentDirectory.Path.Length; + var directoryNameLength = directoryPath.Length - startIndex; + + if (string.Compare(path, startIndex, directoryPath, startIndex, directoryPath.Length - startIndex, StringComparison.OrdinalIgnoreCase) == 0) + { + return currentDirectory; + } + } + + return null; + } + } + + // Internal for testing + [DebuggerDisplay("{Path}")] + internal struct FileNode + { + public FileNode(string path, RazorProjectItem projectItem) + { + Path = path; + ProjectItem = projectItem; + } + + public string Path { get; } + + public RazorProjectItem ProjectItem { get; } + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/DefaultRazorCompiledItem.cs b/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/DefaultRazorCompiledItem.cs new file mode 100644 index 0000000000..b5390b7c87 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/DefaultRazorCompiledItem.cs @@ -0,0 +1,54 @@ +// 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.Collections.Generic; + +namespace Microsoft.AspNetCore.Razor.Hosting +{ + internal class DefaultRazorCompiledItem : RazorCompiledItem + { + private object[] _metadata; + + public DefaultRazorCompiledItem(Type type, string kind, string identifier) + { + if (type == null) + { + throw new ArgumentNullException(nameof(type)); + } + + if (kind == null) + { + throw new ArgumentNullException(nameof(kind)); + } + + if (identifier == null) + { + throw new ArgumentNullException(nameof(identifier)); + } + + Type = type; + Kind = kind; + Identifier = identifier; + } + + public override string Identifier { get; } + + public override string Kind { get; } + + public override IReadOnlyList Metadata + { + get + { + if (_metadata == null) + { + _metadata = Type.GetCustomAttributes(inherit: true); + } + + return _metadata; + } + } + + public override Type Type { get; } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/IRazorSourceChecksumMetadata.cs b/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/IRazorSourceChecksumMetadata.cs new file mode 100644 index 0000000000..dccdb2f871 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/IRazorSourceChecksumMetadata.cs @@ -0,0 +1,26 @@ +// 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.AspNetCore.Razor.Hosting +{ + /// + /// A metadata object containing the checksum of a source file that contributed to a compiled item. + /// + public interface IRazorSourceChecksumMetadata + { + /// + /// Gets the checksum as string of hex-encoded bytes. + /// + string Checksum { get; } + + /// + /// Gets the name of the algorithm used to create this checksum. + /// + string ChecksumAlgorithm { get; } + + /// + /// Gets the identifier of the source file associated with this checksum. + /// + string Identifier { get; } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorCompiledItem.cs b/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorCompiledItem.cs new file mode 100644 index 0000000000..8eff0f4ea2 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorCompiledItem.cs @@ -0,0 +1,40 @@ +// 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.Collections.Generic; + +namespace Microsoft.AspNetCore.Razor.Hosting +{ + /// + /// Identifies a compiled item that can be identified and loaded. + /// + public abstract class RazorCompiledItem + { + /// + /// Gets the identifier associated with the compiled item. The identifier is used programmatically to locate + /// a specific item of a specific kind and should be uniqure within the assembly. + /// + public abstract string Identifier { get; } + + /// + /// Gets the kind of compiled item. The kind is used programmatically to associate behaviors and semantics + /// with the item. + /// + public abstract string Kind { get; } + + /// + /// Gets a collection of arbitrary metadata associated with the item. + /// + /// + /// For items loaded with the default implementation of , the + /// metadata collection will return all attributes defined on the . + /// + public abstract IReadOnlyList Metadata { get; } + + /// + /// Gets the of the compiled item. + /// + public abstract Type Type { get; } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorCompiledItemAttribute.cs b/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorCompiledItemAttribute.cs new file mode 100644 index 0000000000..8e4c003f87 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorCompiledItemAttribute.cs @@ -0,0 +1,60 @@ +// 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; + +namespace Microsoft.AspNetCore.Razor.Hosting +{ + /// + /// Specifies that an assembly contains a compiled Razor asset. + /// + [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true, Inherited = false)] + public sealed class RazorCompiledItemAttribute : Attribute + { + /// + /// Creates a new . + /// + /// The of the compiled item. + /// + /// The kind of the compiled item. The kind is used programmatically to associate behaviors with the item. + /// + /// + /// The identifier associated with the item. The identifier is used programmatically to locate + /// a specific item of a specific kind, and should be unique within the assembly. + /// + public RazorCompiledItemAttribute(Type type, string kind, string identifier) + { + if (type == null) + { + throw new ArgumentNullException(nameof(type)); + } + + if (kind == null) + { + throw new ArgumentNullException(nameof(kind)); + } + + Type = type; + Kind = kind; + Identifier = identifier; + } + + /// + /// Gets the kind of compiled item. The kind is used programmatically to associate behaviors and semantics + /// with the item. + /// + public string Kind { get; } + + /// + /// Gets the identifier associated with the compiled item. The identifier is used programmatically to locate + /// a specific item of a specific kind and should be uniqure within the assembly. + /// + public string Identifier { get; } + + /// + /// Gets the of the compiled item. The type should be contained in the assembly associated + /// with this instance of . + /// + public Type Type { get; } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorCompiledItemExtensions.cs b/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorCompiledItemExtensions.cs new file mode 100644 index 0000000000..d6287e3253 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorCompiledItemExtensions.cs @@ -0,0 +1,30 @@ +// 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.Collections.Generic; +using System.Linq; + +namespace Microsoft.AspNetCore.Razor.Hosting +{ + /// + /// Extension methods for . + /// + public static class RazorCompiledItemExtensions + { + /// + /// Gets the list of associated with . + /// + /// The . + /// A list of . + public static IReadOnlyList GetChecksumMetadata(this RazorCompiledItem item) + { + if (item == null) + { + throw new ArgumentNullException(nameof(item)); + } + + return item.Metadata.OfType().ToArray(); + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorCompiledItemLoader.cs b/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorCompiledItemLoader.cs new file mode 100644 index 0000000000..9b3db2dbb3 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorCompiledItemLoader.cs @@ -0,0 +1,83 @@ +// 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.Collections.Generic; +using System.Reflection; + +namespace Microsoft.AspNetCore.Razor.Hosting +{ + /// + /// A loader implementation that can load objects from an + /// using reflection. + /// + /// + /// + /// Inherit from to customize the behavior when loading + /// objects from an . The default implementations of methods + /// defined by this class use reflection in a trivial way to load attributes from the assembly. + /// + /// + /// Inheriting from is useful when an implementation needs to consider + /// additional configuration or data outside of the being loaded. + /// + /// + /// Subclasses of can return subclasses of + /// with additional data members by overriding . + /// + /// + public class RazorCompiledItemLoader + { + /// + /// Loads a list of objects from the provided . + /// + /// The assembly to search. + /// A list of objects. + public virtual IReadOnlyList LoadItems(Assembly assembly) + { + if (assembly == null) + { + throw new ArgumentNullException(nameof(assembly)); + } + + var items = new List(); + foreach (var attribute in LoadAttributes(assembly)) + { + items.Add(CreateItem(attribute)); + } + + return items; + } + + /// + /// Creates a from a . + /// + /// The . + /// A created from . + protected virtual RazorCompiledItem CreateItem(RazorCompiledItemAttribute attribute) + { + if (attribute == null) + { + throw new ArgumentNullException(nameof(attribute)); + } + + return new DefaultRazorCompiledItem(attribute.Type, attribute.Kind, attribute.Identifier); + } + + /// + /// Retrieves the list of attributes defined for the provided + /// . + /// + /// The to search. + /// A list of attributes. + protected IEnumerable LoadAttributes(Assembly assembly) + { + if (assembly == null) + { + throw new ArgumentNullException(nameof(assembly)); + } + + return assembly.GetCustomAttributes(); + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorSourceChecksumAttribute.cs b/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorSourceChecksumAttribute.cs new file mode 100644 index 0000000000..d1da25b300 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorSourceChecksumAttribute.cs @@ -0,0 +1,67 @@ +// 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; + +namespace Microsoft.AspNetCore.Razor.Hosting +{ + /// + /// Specifies the checksum of a source file that contributed to a compiled item. + /// + /// + /// + /// These attributes are added by the Razor infrastructure when generating code to assist runtime + /// implementations to determine the integrity of compiled items. + /// + /// + /// Runtime implementations should access the checksum metadata for an item using + /// . + /// + /// + [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)] + public sealed class RazorSourceChecksumAttribute : Attribute, IRazorSourceChecksumMetadata + { + /// + /// Creates a new . + /// + /// The algorithm used to create this checksum. + /// The checksum as a string of hex-encoded bytes. + /// The identifier associated with this thumbprint. + public RazorSourceChecksumAttribute(string checksumAlgorithm, string checksum, string identifier) + { + if (checksumAlgorithm == null) + { + throw new ArgumentNullException(nameof(checksumAlgorithm)); + } + + if (checksum == null) + { + throw new ArgumentNullException(nameof(checksum)); + } + + if (identifier == null) + { + throw new ArgumentNullException(nameof(identifier)); + } + + ChecksumAlgorithm = checksumAlgorithm; + Checksum = checksum; + Identifier = identifier; + } + + /// + /// Gets the checksum as string of hex-encoded bytes. + /// + public string Checksum { get; } + + /// + /// Gets the name of the algorithm used to create this checksum. + /// + public string ChecksumAlgorithm { get; } + + /// + /// Gets the identifier of the source file associated with this checksum. + /// + public string Identifier { get; } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/Microsoft.AspNetCore.Razor.Runtime.csproj b/src/Microsoft.AspNetCore.Razor.Runtime/Microsoft.AspNetCore.Razor.Runtime.csproj index 962c97a367..b58a7f9c3f 100644 --- a/src/Microsoft.AspNetCore.Razor.Runtime/Microsoft.AspNetCore.Razor.Runtime.csproj +++ b/src/Microsoft.AspNetCore.Razor.Runtime/Microsoft.AspNetCore.Razor.Runtime.csproj @@ -1,15 +1,8 @@  - Runtime components for rendering Razor pages and implementing tag helpers. - $(Summary) - -Commonly used types: -Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeNameAttribute -Microsoft.AspNetCore.Razor.TagHelpers.HtmlTargetElementAttribute -Microsoft.AspNetCore.Razor.TagHelpers.ITagHelper + Runtime infrastructure for rendering Razor pages and tag helpers. netstandard2.0 - true $(PackageTags);taghelper;taghelpers @@ -20,7 +13,6 @@ Microsoft.AspNetCore.Razor.TagHelpers.ITagHelper - diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Razor.Runtime/Properties/AssemblyInfo.cs index fe4a34e5e5..ea941b3e5a 100644 --- a/src/Microsoft.AspNetCore.Razor.Runtime/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.Razor.Runtime/Properties/AssemblyInfo.cs @@ -2,5 +2,24 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Runtime.CompilerServices; +using Microsoft.AspNetCore.Razor.TagHelpers; [assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.Runtime.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] + +[assembly: TypeForwardedTo(typeof(DefaultTagHelperContent))] +[assembly: TypeForwardedTo(typeof(HtmlAttributeNameAttribute))] +[assembly: TypeForwardedTo(typeof(HtmlAttributeNotBoundAttribute))] +[assembly: TypeForwardedTo(typeof(HtmlTargetElementAttribute))] +[assembly: TypeForwardedTo(typeof(ITagHelper))] +[assembly: TypeForwardedTo(typeof(ITagHelperComponent))] +[assembly: TypeForwardedTo(typeof(NullHtmlEncoder))] +[assembly: TypeForwardedTo(typeof(OutputElementHintAttribute))] +[assembly: TypeForwardedTo(typeof(ReadOnlyTagHelperAttributeList))] +[assembly: TypeForwardedTo(typeof(RestrictChildrenAttribute))] +[assembly: TypeForwardedTo(typeof(TagHelper))] +[assembly: TypeForwardedTo(typeof(TagHelperAttribute))] +[assembly: TypeForwardedTo(typeof(TagHelperAttributeList))] +[assembly: TypeForwardedTo(typeof(TagHelperComponent))] +[assembly: TypeForwardedTo(typeof(TagHelperContent))] +[assembly: TypeForwardedTo(typeof(TagHelperContext))] +[assembly: TypeForwardedTo(typeof(TagHelperOutput))] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor/Microsoft.AspNetCore.Razor.csproj b/src/Microsoft.AspNetCore.Razor/Microsoft.AspNetCore.Razor.csproj index f6dee80752..29dfb82a7b 100644 --- a/src/Microsoft.AspNetCore.Razor/Microsoft.AspNetCore.Razor.csproj +++ b/src/Microsoft.AspNetCore.Razor/Microsoft.AspNetCore.Razor.csproj @@ -1,8 +1,23 @@  - Razor is a markup syntax for adding server-side logic to web pages. This package contains the Razor parser and code generation infrastructure. + Razor is a markup syntax for adding server-side logic to web pages. This package contains runtime components for rendering Razor pages and implementing tag helpers. + $(Summary) + +Commonly used types: +Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeNameAttribute +Microsoft.AspNetCore.Razor.TagHelpers.HtmlTargetElementAttribute +Microsoft.AspNetCore.Razor.TagHelpers.ITagHelper netstandard2.0 + $(PackageTags);taghelper;taghelpers + + + true + + + + + diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/DefaultTagHelperContent.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/DefaultTagHelperContent.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/DefaultTagHelperContent.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/DefaultTagHelperContent.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/HtmlAttributeNameAttribute.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/HtmlAttributeNameAttribute.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/HtmlAttributeNameAttribute.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/HtmlAttributeNameAttribute.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/HtmlAttributeNotBoundAttribute.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/HtmlAttributeNotBoundAttribute.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/HtmlAttributeNotBoundAttribute.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/HtmlAttributeNotBoundAttribute.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/HtmlTargetElementAttribute.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/HtmlTargetElementAttribute.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/HtmlTargetElementAttribute.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/HtmlTargetElementAttribute.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/ITagHelper.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/ITagHelper.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/ITagHelper.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/ITagHelper.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/ITagHelperComponent.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/ITagHelperComponent.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/ITagHelperComponent.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/ITagHelperComponent.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/NullHtmlEncoder.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/NullHtmlEncoder.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/NullHtmlEncoder.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/NullHtmlEncoder.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/OutputElementHintAttribute.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/OutputElementHintAttribute.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/OutputElementHintAttribute.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/OutputElementHintAttribute.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/ReadOnlyTagHelperAttributeList.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/ReadOnlyTagHelperAttributeList.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/ReadOnlyTagHelperAttributeList.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/ReadOnlyTagHelperAttributeList.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/RestrictChildrenAttribute.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/RestrictChildrenAttribute.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/RestrictChildrenAttribute.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/RestrictChildrenAttribute.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelper.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/TagHelper.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelper.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/TagHelper.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelperAttribute.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/TagHelperAttribute.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelperAttribute.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/TagHelperAttribute.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelperAttributeList.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/TagHelperAttributeList.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelperAttributeList.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/TagHelperAttributeList.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelperComponent.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/TagHelperComponent.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelperComponent.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/TagHelperComponent.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelperContent.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/TagHelperContent.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelperContent.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/TagHelperContent.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelperContext.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/TagHelperContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelperContext.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/TagHelperContext.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelperOutput.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/TagHelperOutput.cs similarity index 99% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelperOutput.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/TagHelperOutput.cs index 14de474670..51a7f8392b 100644 --- a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelperOutput.cs +++ b/src/Microsoft.AspNetCore.Razor/TagHelpers/TagHelperOutput.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Diagnostics; using System.IO; using System.Text.Encodings.Web; using System.Threading.Tasks; diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultErrorReporterFactory.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultErrorReporterFactory.cs index 102ef6551b..e9c987d108 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultErrorReporterFactory.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultErrorReporterFactory.cs @@ -8,7 +8,7 @@ using Microsoft.CodeAnalysis.Host.Mef; namespace Microsoft.CodeAnalysis.Razor { [Shared] - [ExportWorkspaceServiceFactory(typeof(ErrorReporter))] + [ExportWorkspaceServiceFactory(typeof(ErrorReporter), ServiceLayer.Default)] internal class DefaultErrorReporterFactory : IWorkspaceServiceFactory { public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultTagHelperFactsServiceInternal.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultTagHelperFactsServiceInternal.cs deleted file mode 100644 index 99cf4f6d12..0000000000 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultTagHelperFactsServiceInternal.cs +++ /dev/null @@ -1,163 +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; -using System.Collections.Generic; -using System.Linq; -using Microsoft.AspNetCore.Razor.Language; - -namespace Microsoft.CodeAnalysis.Razor -{ - internal class DefaultTagHelperFactsServiceInternal : TagHelperFactsServiceInternal - { - public override TagHelperBinding GetTagHelperBinding( - TagHelperDocumentContext documentContext, - string tagName, - IEnumerable> attributes, - string parentTag, - bool parentIsTagHelper) - { - if (documentContext == null) - { - throw new ArgumentNullException(nameof(documentContext)); - } - - if (tagName == null) - { - throw new ArgumentNullException(nameof(tagName)); - } - - if (attributes == null) - { - throw new ArgumentNullException(nameof(attributes)); - } - - var descriptors = documentContext.TagHelpers; - if (descriptors == null || descriptors.Count == 0) - { - return null; - } - - var prefix = documentContext.Prefix; - var tagHelperBinder = new TagHelperBinder(prefix, descriptors); - var binding = tagHelperBinder.GetBinding(tagName, attributes.ToList(), parentTag, parentIsTagHelper); - - return binding; - } - - public override IEnumerable GetBoundTagHelperAttributes( - TagHelperDocumentContext documentContext, - string attributeName, - TagHelperBinding binding) - { - if (documentContext == null) - { - throw new ArgumentNullException(nameof(documentContext)); - } - - if (attributeName == null) - { - throw new ArgumentNullException(nameof(attributeName)); - } - - if (binding == null) - { - throw new ArgumentNullException(nameof(binding)); - } - - var matchingBoundAttributes = new List(); - foreach (var descriptor in binding.Descriptors) - { - foreach (var boundAttributeDescriptor in descriptor.BoundAttributes) - { - if (TagHelperMatchingConventions.CanSatisfyBoundAttribute(attributeName, boundAttributeDescriptor)) - { - matchingBoundAttributes.Add(boundAttributeDescriptor); - - // Only one bound attribute can match an attribute - break; - } - } - } - - return matchingBoundAttributes; - } - - public override IReadOnlyList GetTagHelpersGivenTag( - TagHelperDocumentContext documentContext, - string tagName, - string parentTag) - { - if (documentContext == null) - { - throw new ArgumentNullException(nameof(documentContext)); - } - - if (tagName == null) - { - throw new ArgumentNullException(nameof(tagName)); - } - - var matchingDescriptors = new List(); - var descriptors = documentContext?.TagHelpers; - if (descriptors?.Count == 0) - { - return matchingDescriptors; - } - - var prefix = documentContext.Prefix ?? string.Empty; - if (!tagName.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) - { - // Can't possibly match TagHelpers, it doesn't start with the TagHelperPrefix. - return matchingDescriptors; - } - - var tagNameWithoutPrefix = tagName.Substring(prefix.Length); - for (var i = 0; i < descriptors.Count; i++) - { - var descriptor = descriptors[i]; - foreach (var rule in descriptor.TagMatchingRules) - { - if (TagHelperMatchingConventions.SatisfiesTagName(tagNameWithoutPrefix, rule) && - TagHelperMatchingConventions.SatisfiesParentTag(parentTag, rule)) - { - matchingDescriptors.Add(descriptor); - break; - } - } - } - - return matchingDescriptors; - } - - public override IReadOnlyList GetTagHelpersGivenParent(TagHelperDocumentContext documentContext, string parentTag) - { - if (documentContext == null) - { - throw new ArgumentNullException(nameof(documentContext)); - } - - var matchingDescriptors = new List(); - var descriptors = documentContext?.TagHelpers; - if (descriptors?.Count == 0) - { - return matchingDescriptors; - } - - for (var i = 0; i < descriptors.Count; i++) - { - var descriptor = descriptors[i]; - foreach (var rule in descriptor.TagMatchingRules) - { - if (TagHelperMatchingConventions.SatisfiesParentTag(parentTag, rule)) - { - matchingDescriptors.Add(descriptor); - break; - } - } - } - - return matchingDescriptors; - } - } -} diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultTagHelperFactsServiceInternalFactory.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultTagHelperFactsServiceInternalFactory.cs deleted file mode 100644 index 4e89fcdff1..0000000000 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultTagHelperFactsServiceInternalFactory.cs +++ /dev/null @@ -1,17 +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.CodeAnalysis.Host; -using Microsoft.CodeAnalysis.Host.Mef; - -namespace Microsoft.CodeAnalysis.Razor -{ - [ExportLanguageServiceFactory(typeof(TagHelperFactsServiceInternal), RazorLanguage.Name, ServiceLayer.Default)] - internal class DefaultTagHelperFactsServiceInternalFactory : ILanguageServiceFactory - { - public ILanguageService CreateLanguageService(HostLanguageServices languageServices) - { - return new DefaultTagHelperFactsServiceInternal(); - } - } -} \ No newline at end of file diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/Editor/DefaultEditorSettingsManagerInternal.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/Editor/DefaultEditorSettingsManagerInternal.cs deleted file mode 100644 index 092da5f62c..0000000000 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/Editor/DefaultEditorSettingsManagerInternal.cs +++ /dev/null @@ -1,54 +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; - -namespace Microsoft.CodeAnalysis.Razor.Editor -{ - internal class DefaultEditorSettingsManagerInternal : EditorSettingsManagerInternal - { - public override event EventHandler Changed; - - private readonly object SettingsAccessorLock = new object(); - private EditorSettings _settings; - - public DefaultEditorSettingsManagerInternal() - { - _settings = EditorSettings.Default; - } - - public override EditorSettings Current - { - get - { - lock (SettingsAccessorLock) - { - return _settings; - } - } - } - - public override void Update(EditorSettings updatedSettings) - { - if (updatedSettings == null) - { - throw new ArgumentNullException(nameof(updatedSettings)); - } - - lock (SettingsAccessorLock) - { - if (!_settings.Equals(updatedSettings)) - { - _settings = updatedSettings; - OnChanged(); - } - } - } - - private void OnChanged() - { - var args = new EditorSettingsChangedEventArgs(Current); - Changed?.Invoke(this, args); - } - } -} diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/Editor/DefaultEditorSettingsManagerInternalFactory.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/Editor/DefaultEditorSettingsManagerInternalFactory.cs deleted file mode 100644 index 84f49a95c8..0000000000 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/Editor/DefaultEditorSettingsManagerInternalFactory.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. - -using System; -using System.Composition; -using Microsoft.CodeAnalysis.Host; -using Microsoft.CodeAnalysis.Host.Mef; - -namespace Microsoft.CodeAnalysis.Razor.Editor -{ - [Shared] - [ExportLanguageServiceFactory(typeof(EditorSettingsManagerInternal), RazorLanguage.Name)] - internal class DefaultEditorSettingsManagerInternalFactory : ILanguageServiceFactory - { - public ILanguageService CreateLanguageService(HostLanguageServices languageServices) - { - if (languageServices == null) - { - throw new ArgumentNullException(nameof(languageServices)); - } - - return new DefaultEditorSettingsManagerInternal(); - } - } -} diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/Editor/EditorSettingsManagerInternal.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/Editor/WorkspaceEditorSettings.cs similarity index 74% rename from src/Microsoft.CodeAnalysis.Razor.Workspaces/Editor/EditorSettingsManagerInternal.cs rename to src/Microsoft.CodeAnalysis.Razor.Workspaces/Editor/WorkspaceEditorSettings.cs index 9dd5a4f5aa..6736dfc39d 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/Editor/EditorSettingsManagerInternal.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/Editor/WorkspaceEditorSettings.cs @@ -6,12 +6,10 @@ using Microsoft.CodeAnalysis.Host; namespace Microsoft.CodeAnalysis.Razor.Editor { - internal abstract class EditorSettingsManagerInternal : ILanguageService + internal abstract class WorkspaceEditorSettings : ILanguageService { public abstract event EventHandler Changed; public abstract EditorSettings Current { get; } - - public abstract void Update(EditorSettings updateSettings); } } diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ForegroundDispatcher.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ForegroundDispatcher.cs index 7f7dac2130..bf9b0f59a4 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ForegroundDispatcher.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ForegroundDispatcher.cs @@ -8,7 +8,7 @@ using Microsoft.CodeAnalysis.Host; namespace Microsoft.CodeAnalysis.Razor { - internal abstract class ForegroundDispatcher : IWorkspaceService + internal abstract class ForegroundDispatcher { public abstract bool IsForegroundThread { get; } diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshot.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshot.cs index ad43248fab..afbd0028f3 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshot.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshot.cs @@ -2,6 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.AspNetCore.Razor.Language; namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { @@ -92,7 +95,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem return new DefaultProjectSnapshot(update, this); } - public bool HasChangesComparedTo(ProjectSnapshot original) + public bool HasConfigurationChanged(ProjectSnapshot original) { if (original == null) { diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotManager.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotManager.cs index e8f9ff1de3..32c3ae4681 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotManager.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotManager.cs @@ -149,7 +149,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem // Now we need to know if the changes that we applied are significant. If that's the case then // we need to notify listeners. - if (snapshot.HasChangesComparedTo(original)) + if (snapshot.HasConfigurationChanged(original)) { NotifyListeners(new ProjectChangeEventArgs(snapshot, ProjectChangeKind.Changed)); } @@ -172,6 +172,25 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem } } + public override void ProjectBuildComplete(Project underlyingProject) + { + if (underlyingProject == null) + { + throw new ArgumentNullException(nameof(underlyingProject)); + } + + if (_projects.TryGetValue(underlyingProject.Id, out var original)) + { + // Doing an update to the project should keep computed values, but mark the project as dirty if the + // underlying project is newer. + var snapshot = original.WithProjectChange(underlyingProject); + _projects[underlyingProject.Id] = snapshot; + + // Notify the background worker so it can trigger tag helper discovery. + NotifyBackgroundWorker(underlyingProject); + } + } + public override void ProjectsCleared() { foreach (var kvp in _projects.ToArray()) @@ -186,12 +205,16 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem // virtual so it can be overridden in tests protected virtual void NotifyBackgroundWorker(Project project) { + _foregroundDispatcher.AssertForegroundThread(); + _workerQueue.Enqueue(project); } // virtual so it can be overridden in tests protected virtual void NotifyListeners(ProjectChangeEventArgs e) { + _foregroundDispatcher.AssertForegroundThread(); + var handler = Changed; if (handler != null) { diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotManagerFactory.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotManagerFactory.cs index 82d0bcdb53..d82d82cd7c 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotManagerFactory.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotManagerFactory.cs @@ -14,11 +14,24 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem internal class DefaultProjectSnapshotManagerFactory : ILanguageServiceFactory { private readonly IEnumerable _triggers; + private readonly ForegroundDispatcher _foregroundDispatcher; [ImportingConstructor] public DefaultProjectSnapshotManagerFactory( + ForegroundDispatcher foregroundDispatcher, [ImportMany] IEnumerable triggers) { + if (foregroundDispatcher == null) + { + throw new ArgumentNullException(nameof(foregroundDispatcher)); + } + + if (triggers == null) + { + throw new ArgumentNullException(nameof(triggers)); + } + + _foregroundDispatcher = foregroundDispatcher; _triggers = triggers; } @@ -30,7 +43,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem } return new DefaultProjectSnapshotManager( - languageServices.WorkspaceServices.GetRequiredService(), + _foregroundDispatcher, languageServices.WorkspaceServices.GetRequiredService(), languageServices.GetRequiredService(), _triggers, diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotWorker.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotWorker.cs index 78efdfbf04..8a40c50f40 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotWorker.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotWorker.cs @@ -40,7 +40,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem // Don't block the main thread if (_foregroundDispatcher.IsForegroundThread) { - return Task.Factory.StartNew(ProjectUpdatesCoreAsync, update, CancellationToken.None, TaskCreationOptions.None, _foregroundDispatcher.BackgroundScheduler); + return Task.Factory.StartNew(ProjectUpdatesCoreAsync, update, cancellationToken, TaskCreationOptions.None, _foregroundDispatcher.BackgroundScheduler); } return ProjectUpdatesCoreAsync(update); diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotWorkerFactory.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotWorkerFactory.cs index 40a5b3f5f4..321d7dfa7a 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotWorkerFactory.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotWorkerFactory.cs @@ -11,10 +11,23 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem [ExportLanguageServiceFactory(typeof(ProjectSnapshotWorker), RazorLanguage.Name)] internal class DefaultProjectSnapshotWorkerFactory : ILanguageServiceFactory { + private readonly ForegroundDispatcher _foregroundDispatcher; + + [ImportingConstructor] + public DefaultProjectSnapshotWorkerFactory(ForegroundDispatcher foregroundDispatcher) + { + if (foregroundDispatcher == null) + { + throw new System.ArgumentNullException(nameof(foregroundDispatcher)); + } + + _foregroundDispatcher = foregroundDispatcher; + } + public ILanguageService CreateLanguageService(HostLanguageServices languageServices) { return new DefaultProjectSnapshotWorker( - languageServices.WorkspaceServices.GetRequiredService(), + _foregroundDispatcher, languageServices.GetRequiredService()); } } diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshot.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshot.cs index 0a54f9b4f4..f28e477d5d 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshot.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshot.cs @@ -1,7 +1,8 @@ // 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.Collections.Generic; +using Microsoft.AspNetCore.Razor.Language; namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManager.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManager.cs index d5a4c7a9ea..b9e39e00b1 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManager.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManager.cs @@ -12,6 +12,5 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem public abstract event EventHandler Changed; public abstract IReadOnlyList Projects { get; } - } } diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManagerBase.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManagerBase.cs index 1e036b76f6..4dd392076b 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManagerBase.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManagerBase.cs @@ -17,6 +17,8 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem public abstract void ProjectRemoved(Project underlyingProject); + public abstract void ProjectBuildComplete(Project underlyingProject); + public abstract void ProjectsCleared(); public abstract void ReportError(Exception exception); diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotUpdateContext.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotUpdateContext.cs index bce7e39b3a..83357e9968 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotUpdateContext.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotUpdateContext.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.Collections.Generic; +using Microsoft.AspNetCore.Razor.Language; namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/Properties/AssemblyInfo.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/Properties/AssemblyInfo.cs index ea60d51dec..a73900fa42 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/Properties/AssemblyInfo.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/Properties/AssemblyInfo.cs @@ -8,6 +8,8 @@ using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("Microsoft.VisualStudio.Editor.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.VisualStudio.Editor.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.VisualStudio.Editor.Razor.Test.Common, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Mac.LanguageServices.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Mac.LanguageServices.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServices.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServices.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.VisualStudio.RazorExtension, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/RazorTemplateEngineFactoryService.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/RazorProjectEngineFactoryService.cs similarity index 61% rename from src/Microsoft.CodeAnalysis.Razor.Workspaces/RazorTemplateEngineFactoryService.cs rename to src/Microsoft.CodeAnalysis.Razor.Workspaces/RazorProjectEngineFactoryService.cs index 26ff5b803a..0388de4671 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/RazorTemplateEngineFactoryService.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/RazorProjectEngineFactoryService.cs @@ -7,8 +7,8 @@ using Microsoft.CodeAnalysis.Host; namespace Microsoft.CodeAnalysis.Razor { - internal abstract class RazorTemplateEngineFactoryService : ILanguageService + internal abstract class RazorProjectEngineFactoryService : ILanguageService { - public abstract RazorTemplateEngine Create(string projectPath, Action configure); + public abstract RazorProjectEngine Create(string projectPath, Action configure); } } \ No newline at end of file diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/TagHelperFactsServiceInternal.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/TagHelperFactsServiceInternal.cs deleted file mode 100644 index 78d26cfdbb..0000000000 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/TagHelperFactsServiceInternal.cs +++ /dev/null @@ -1,20 +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 Microsoft.AspNetCore.Razor.Language; -using Microsoft.CodeAnalysis.Host; - -namespace Microsoft.CodeAnalysis.Razor -{ - internal abstract class TagHelperFactsServiceInternal : ILanguageService - { - public abstract TagHelperBinding GetTagHelperBinding(TagHelperDocumentContext documentContext, string tagName, IEnumerable> attributes, string parentTag, bool parentIsTagHelper); - - public abstract IEnumerable GetBoundTagHelperAttributes(TagHelperDocumentContext documentContext, string attributeName, TagHelperBinding binding); - - public abstract IReadOnlyList GetTagHelpersGivenTag(TagHelperDocumentContext documentContext, string tagName, string parentTag); - - public abstract IReadOnlyList GetTagHelpersGivenParent(TagHelperDocumentContext documentContext, string parentTag); - } -} diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/TagHelperResolver.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/TagHelperResolver.cs index a16f46400b..182273abfd 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/TagHelperResolver.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/TagHelperResolver.cs @@ -9,14 +9,6 @@ namespace Microsoft.CodeAnalysis.Razor { internal abstract class TagHelperResolver : ILanguageService { - public abstract TagHelperResolutionResult GetTagHelpers(Compilation compilation); - - public virtual async Task GetTagHelpersAsync( - Project project, - CancellationToken cancellationToken = default(CancellationToken)) - { - var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false); - return GetTagHelpers(compilation); - } + public abstract Task GetTagHelpersAsync(Project project, CancellationToken cancellationToken); } -} +} \ No newline at end of file diff --git a/src/Microsoft.CodeAnalysis.Remote.Razor/DefaultTagHelperResolver.cs b/src/Microsoft.CodeAnalysis.Remote.Razor/DefaultTagHelperResolver.cs index 43b55a5b50..4aca5c8f7e 100644 --- a/src/Microsoft.CodeAnalysis.Remote.Razor/DefaultTagHelperResolver.cs +++ b/src/Microsoft.CodeAnalysis.Remote.Razor/DefaultTagHelperResolver.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.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc.Razor.Extensions; using Microsoft.AspNetCore.Razor.Language; using Microsoft.CodeAnalysis.Razor; @@ -17,7 +19,7 @@ namespace Microsoft.CodeAnalysis.Remote.Razor public bool DesignTime { get; } - public override TagHelperResolutionResult GetTagHelpers(Compilation compilation) + private TagHelperResolutionResult GetTagHelpers(Compilation compilation) { var descriptors = new List(); @@ -42,5 +44,11 @@ namespace Microsoft.CodeAnalysis.Remote.Razor return resolutionResult; } + + public override async Task GetTagHelpersAsync(Project project, CancellationToken cancellationToken) + { + var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false); + return GetTagHelpers(compilation); + } } } diff --git a/src/Microsoft.VisualStudio.Editor.Razor/BackgroundParser.cs b/src/Microsoft.VisualStudio.Editor.Razor/BackgroundParser.cs index 887a98dab0..a81681c872 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/BackgroundParser.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/BackgroundParser.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; +using System.Text; using System.Threading; using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Legacy; @@ -18,10 +19,10 @@ namespace Microsoft.VisualStudio.Editor.Razor private MainThreadState _main; private BackgroundThread _bg; - public BackgroundParser(RazorTemplateEngine templateEngine, string filePath) + public BackgroundParser(RazorProjectEngine projectEngine, string filePath, string projectDirectory) { _main = new MainThreadState(filePath); - _bg = new BackgroundThread(_main, templateEngine, filePath); + _bg = new BackgroundThread(_main, projectEngine, filePath, projectDirectory); _main.ResultsReady += (sender, args) => OnResultsReady(args); } @@ -233,22 +234,25 @@ namespace Microsoft.VisualStudio.Editor.Razor private class BackgroundThread : ThreadStateBase { + private readonly string _filePath; + private readonly string _relativeFilePath; + private readonly string _projectDirectory; private MainThreadState _main; private Thread _backgroundThread; private CancellationToken _shutdownToken; - private RazorTemplateEngine _templateEngine; - private string _filePath; + private RazorProjectEngine _projectEngine; private RazorSyntaxTree _currentSyntaxTree; private IList _previouslyDiscarded = new List(); - public BackgroundThread(MainThreadState main, RazorTemplateEngine templateEngine, string fileName) + public BackgroundThread(MainThreadState main, RazorProjectEngine projectEngine, string filePath, string projectDirectory) { // Run on MAIN thread! _main = main; _shutdownToken = _main.CancelToken; - _templateEngine = templateEngine; - _filePath = fileName; - + _projectEngine = projectEngine; + _filePath = filePath; + _relativeFilePath = GetNormalizedRelativeFilePath(filePath, projectDirectory); + _projectDirectory = projectDirectory; _backgroundThread = new Thread(WorkerLoop); SetThreadId(_backgroundThread.ManagedThreadId); } @@ -262,8 +266,6 @@ namespace Microsoft.VisualStudio.Editor.Razor // **** BACKGROUND THREAD **** private void WorkerLoop() { - var fileNameOnly = Path.GetFileName(_filePath); - try { EnsureOnThread(); @@ -347,14 +349,31 @@ namespace Microsoft.VisualStudio.Editor.Razor { EnsureOnThread(); - var sourceDocument = new TextSnapshotSourceDocument(snapshot, _filePath); - var imports = _templateEngine.GetImports(_filePath); + var projectItem = new TextSnapshotProjectItem(snapshot, _projectDirectory, _relativeFilePath, _filePath); + var codeDocument = _projectEngine.ProcessDesignTime(projectItem); - var codeDocument = RazorCodeDocument.Create(sourceDocument, imports); - - _templateEngine.GenerateCode(codeDocument); return codeDocument; } + + private string GetNormalizedRelativeFilePath(string filePath, string projectDirectory) + { + if (filePath.StartsWith(projectDirectory, StringComparison.OrdinalIgnoreCase)) + { + filePath = filePath.Substring(projectDirectory.Length); + } + + if (filePath.Length > 1) + { + filePath = filePath.Replace('\\', '/'); + + if (filePath[0] != '/') + { + filePath = "/" + filePath; + } + } + + return filePath; + } } private class WorkParcel @@ -383,4 +402,4 @@ namespace Microsoft.VisualStudio.Editor.Razor public ITextSnapshot Snapshot { get; set; } } } -} +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/BraceSmartIndenterFactory.cs b/src/Microsoft.VisualStudio.Editor.Razor/BraceSmartIndenterFactory.cs index 750c061b7b..bc477b4f28 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/BraceSmartIndenterFactory.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/BraceSmartIndenterFactory.cs @@ -1,10 +1,12 @@ // 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.CodeAnalysis.Host; + namespace Microsoft.VisualStudio.Editor.Razor { - internal abstract class BraceSmartIndenterFactory + internal abstract class BraceSmartIndenterFactory : ILanguageService { public abstract BraceSmartIndenter Create(VisualStudioDocumentTracker documentTracker); } -} +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultBraceSmartIndenterFactory.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultBraceSmartIndenterFactory.cs similarity index 70% rename from src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultBraceSmartIndenterFactory.cs rename to src/Microsoft.VisualStudio.Editor.Razor/DefaultBraceSmartIndenterFactory.cs index 9b2bcf0ad0..53f093412b 100644 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultBraceSmartIndenterFactory.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultBraceSmartIndenterFactory.cs @@ -2,38 +2,32 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.ComponentModel.Composition; -using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Razor; -using Microsoft.VisualStudio.Editor.Razor; using Microsoft.VisualStudio.Text.Operations; -namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor +namespace Microsoft.VisualStudio.Editor.Razor { - [System.Composition.Shared] - [Export(typeof(BraceSmartIndenterFactory))] internal class DefaultBraceSmartIndenterFactory : BraceSmartIndenterFactory { private readonly IEditorOperationsFactoryService _editorOperationsFactory; private readonly ForegroundDispatcher _dispatcher; - [ImportingConstructor] public DefaultBraceSmartIndenterFactory( - IEditorOperationsFactoryService editorOperationsFactory, - [Import(typeof(VisualStudioWorkspace))] Workspace workspace) + ForegroundDispatcher dispatcher, + IEditorOperationsFactoryService editorOperationsFactory) { + if (dispatcher == null) + { + throw new ArgumentNullException(nameof(dispatcher)); + } + if (editorOperationsFactory == null) { throw new ArgumentNullException(nameof(editorOperationsFactory)); } - if (workspace == null) - { - throw new ArgumentNullException(nameof(workspace)); - } - + _dispatcher = dispatcher; _editorOperationsFactory = editorOperationsFactory; - _dispatcher = workspace.Services.GetRequiredService(); } public override BraceSmartIndenter Create(VisualStudioDocumentTracker documentTracker) @@ -50,4 +44,4 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor return braceSmartIndenter; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultBraceSmartIndenterFactoryFactory.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultBraceSmartIndenterFactoryFactory.cs new file mode 100644 index 0000000000..0f96a5189b --- /dev/null +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultBraceSmartIndenterFactoryFactory.cs @@ -0,0 +1,47 @@ +// 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.Composition; +using Microsoft.CodeAnalysis.Host; +using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.CodeAnalysis.Razor; +using Microsoft.VisualStudio.Text.Operations; + +namespace Microsoft.VisualStudio.Editor.Razor +{ + [Shared] + [ExportLanguageServiceFactory(typeof(BraceSmartIndenterFactory), RazorLanguage.Name, ServiceLayer.Default)] + internal class DefaultBraceSmartIndenterFactoryFactory : ILanguageServiceFactory + { + private readonly ForegroundDispatcher _foregroundDispatcher; + private readonly IEditorOperationsFactoryService _editorOperationsFactory; + + [ImportingConstructor] + public DefaultBraceSmartIndenterFactoryFactory(ForegroundDispatcher foregroundDispatcher, IEditorOperationsFactoryService editorOperationsFactory) + { + if (foregroundDispatcher == null) + { + throw new ArgumentNullException(nameof(foregroundDispatcher)); + } + + if (editorOperationsFactory == null) + { + throw new ArgumentNullException(nameof(editorOperationsFactory)); + } + + _foregroundDispatcher = foregroundDispatcher; + _editorOperationsFactory = editorOperationsFactory; + } + + public ILanguageService CreateLanguageService(HostLanguageServices languageServices) + { + if (languageServices == null) + { + throw new ArgumentNullException(nameof(languageServices)); + } + + return new DefaultBraceSmartIndenterFactory(_foregroundDispatcher, _editorOperationsFactory); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultEditorSettingsManager.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultEditorSettingsManager.cs index 389aff0b77..952bc3be91 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/DefaultEditorSettingsManager.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultEditorSettingsManager.cs @@ -12,26 +12,55 @@ namespace Microsoft.VisualStudio.Editor.Razor [Export(typeof(EditorSettingsManager))] internal class DefaultEditorSettingsManager : EditorSettingsManager { - private readonly EditorSettingsManagerInternal _editorSettingsManager; + public override event EventHandler Changed; + + private readonly object SettingsAccessorLock = new object(); + private readonly ForegroundDispatcher _foregroundDispatcher; + private EditorSettings _settings; [ImportingConstructor] - public DefaultEditorSettingsManager(VisualStudioWorkspaceAccessor workspaceAccessor) + public DefaultEditorSettingsManager(ForegroundDispatcher foregroundDispatcher) { - var razorLanguageServices = workspaceAccessor.Workspace.Services.GetLanguageServices(RazorLanguage.Name); - _editorSettingsManager = razorLanguageServices.GetRequiredService(); + _foregroundDispatcher = foregroundDispatcher; + _settings = EditorSettings.Default; } - public override event EventHandler Changed + public override EditorSettings Current { - add => _editorSettingsManager.Changed += value; - remove => _editorSettingsManager.Changed -= value; + get + { + lock (SettingsAccessorLock) + { + return _settings; + } + } } - public override EditorSettings Current => _editorSettingsManager.Current; - - public override void Update(EditorSettings updateSettings) + public override void Update(EditorSettings updatedSettings) { - _editorSettingsManager.Update(updateSettings); + if (updatedSettings == null) + { + throw new ArgumentNullException(nameof(updatedSettings)); + } + + _foregroundDispatcher.AssertForegroundThread(); + + lock (SettingsAccessorLock) + { + if (!_settings.Equals(updatedSettings)) + { + _settings = updatedSettings; + OnChanged(); + } + } + } + + private void OnChanged() + { + _foregroundDispatcher.AssertForegroundThread(); + + var args = new EditorSettingsChangedEventArgs(Current); + Changed?.Invoke(this, args); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultTemplateEngineFactoryService.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultProjectEngineFactoryService.cs similarity index 76% rename from src/Microsoft.VisualStudio.Editor.Razor/DefaultTemplateEngineFactoryService.cs rename to src/Microsoft.VisualStudio.Editor.Razor/DefaultProjectEngineFactoryService.cs index ab5518bb46..f97abf0a3b 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/DefaultTemplateEngineFactoryService.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultProjectEngineFactoryService.cs @@ -12,7 +12,7 @@ using MvcLatest = Microsoft.AspNetCore.Mvc.Razor.Extensions; namespace Microsoft.VisualStudio.Editor.Razor { - internal class DefaultTemplateEngineFactoryService : RazorTemplateEngineFactoryService + internal class DefaultProjectEngineFactoryService : RazorProjectEngineFactoryService { private readonly static MvcExtensibilityConfiguration DefaultConfiguration = new MvcExtensibilityConfiguration( RazorLanguageVersion.Version_2_0, @@ -22,7 +22,7 @@ namespace Microsoft.VisualStudio.Editor.Razor private readonly ProjectSnapshotManager _projectManager; - public DefaultTemplateEngineFactoryService(ProjectSnapshotManager projectManager) + public DefaultProjectEngineFactoryService(ProjectSnapshotManager projectManager) { if (projectManager == null) { @@ -32,7 +32,7 @@ namespace Microsoft.VisualStudio.Editor.Razor _projectManager = projectManager; } - public override RazorTemplateEngine Create(string projectPath, Action configure) + public override RazorProjectEngine Create(string projectPath, Action configure) { if (projectPath == null) { @@ -43,12 +43,14 @@ namespace Microsoft.VisualStudio.Editor.Razor var project = FindProject(projectPath); var configuration = (project?.Configuration as MvcExtensibilityConfiguration) ?? DefaultConfiguration; var razorLanguageVersion = configuration.LanguageVersion; - var razorConfiguration = new RazorConfiguration(razorLanguageVersion, "unnamed", Array.Empty(), designTime: true); - RazorEngine engine; + var razorConfiguration = new RazorConfiguration(razorLanguageVersion, "unnamed", Array.Empty()); + var fileSystem = RazorProjectFileSystem.Create(projectPath); + + RazorProjectEngine projectEngine; if (razorLanguageVersion.Major == 1) { - engine = RazorEngine.CreateCore(razorConfiguration, b => + projectEngine = RazorProjectEngine.Create(razorConfiguration, fileSystem, b => { configure?.Invoke(b); @@ -59,24 +61,18 @@ namespace Microsoft.VisualStudio.Editor.Razor Mvc1_X.RazorExtensions.RegisterViewComponentTagHelpers(b); } }); - - var templateEngine = new Mvc1_X.MvcRazorTemplateEngine(engine, RazorProject.Create(projectPath)); - templateEngine.Options.ImportsFileName = "_ViewImports.cshtml"; - return templateEngine; } else { - engine = RazorEngine.CreateCore(razorConfiguration, b => + projectEngine = RazorProjectEngine.Create(razorConfiguration, fileSystem, b => { configure?.Invoke(b); MvcLatest.RazorExtensions.Register(b); }); - - var templateEngine = new MvcLatest.MvcRazorTemplateEngine(engine, RazorProject.Create(projectPath)); - templateEngine.Options.ImportsFileName = "_ViewImports.cshtml"; - return templateEngine; } + + return projectEngine; } private ProjectSnapshot FindProject(string directory) @@ -104,4 +100,4 @@ namespace Microsoft.VisualStudio.Editor.Razor return path.Replace('\\', '/').TrimEnd('/'); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultTemplateEngineFactoryServiceFactory.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultProjectEngineFactoryServiceFactory.cs similarity index 60% rename from src/Microsoft.VisualStudio.Editor.Razor/DefaultTemplateEngineFactoryServiceFactory.cs rename to src/Microsoft.VisualStudio.Editor.Razor/DefaultProjectEngineFactoryServiceFactory.cs index f95df76c08..babed97a5c 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/DefaultTemplateEngineFactoryServiceFactory.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultProjectEngineFactoryServiceFactory.cs @@ -8,12 +8,12 @@ using Microsoft.CodeAnalysis.Razor.ProjectSystem; namespace Microsoft.VisualStudio.Editor.Razor { - [ExportLanguageServiceFactory(typeof(RazorTemplateEngineFactoryService), RazorLanguage.Name, ServiceLayer.Default)] - internal class DefaultTemplateEngineFactoryServiceFactory : ILanguageServiceFactory + [ExportLanguageServiceFactory(typeof(RazorProjectEngineFactoryService), RazorLanguage.Name, ServiceLayer.Default)] + internal class DefaultProjectEngineFactoryServiceFactory : ILanguageServiceFactory { public ILanguageService CreateLanguageService(HostLanguageServices languageServices) { - return new DefaultTemplateEngineFactoryService(languageServices.GetRequiredService()); + return new DefaultProjectEngineFactoryService(languageServices.GetRequiredService()); } } } \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultTagHelperCompletionService.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultTagHelperCompletionService.cs index 0bb688e1b3..f365c47698 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/DefaultTagHelperCompletionService.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultTagHelperCompletionService.cs @@ -7,7 +7,6 @@ using System.ComponentModel.Composition; using System.Diagnostics; using System.Linq; using Microsoft.AspNetCore.Razor.Language; -using Microsoft.CodeAnalysis.Razor; namespace Microsoft.VisualStudio.Editor.Razor { @@ -15,34 +14,31 @@ namespace Microsoft.VisualStudio.Editor.Razor [Export(typeof(TagHelperCompletionService))] internal class DefaultTagHelperCompletionService : TagHelperCompletionService { - private readonly TagHelperFactsServiceInternal _tagHelperFactsService; + private readonly TagHelperFactsService _tagHelperFactsService; private static readonly HashSet _emptyHashSet = new HashSet(); [ImportingConstructor] - public DefaultTagHelperCompletionService(VisualStudioWorkspaceAccessor workspaceAccessor) + public DefaultTagHelperCompletionService(TagHelperFactsService tagHelperFactsService) { - var razorLanguageServices = workspaceAccessor.Workspace.Services.GetLanguageServices(RazorLanguage.Name); - _tagHelperFactsService = razorLanguageServices.GetRequiredService(); - } + if (tagHelperFactsService == null) + { + throw new ArgumentNullException(nameof(tagHelperFactsService)); + } - // Internal for testing - internal DefaultTagHelperCompletionService(TagHelperFactsServiceInternal tagHelperFactsService) - { _tagHelperFactsService = tagHelperFactsService; } - /* - * This API attempts to understand a users context as they're typing in a Razor file to provide TagHelper based attribute IntelliSense. - * - * Scenarios for TagHelper attribute IntelliSense follows: - * 1. TagHelperDescriptor's have matching required attribute names - * -> Provide IntelliSense for the required attributes of those descriptors to lead users towards a TagHelperified element. - * 2. TagHelperDescriptor entirely applies to current element. Tag name, attributes, everything is fulfilled. - * -> Provide IntelliSense for the bound attributes for the applied descriptors. - * - * Within each of the above scenarios if an attribute completion has a corresponding bound attribute we associate it with the corresponding - * BoundAttributeDescriptor. By doing this a user can see what C# type a TagHelper expects for the attribute. - */ + // This API attempts to understand a users context as they're typing in a Razor file to provide TagHelper based attribute IntelliSense. + // + // Scenarios for TagHelper attribute IntelliSense follows: + // 1. TagHelperDescriptor's have matching required attribute names + // -> Provide IntelliSense for the required attributes of those descriptors to lead users towards a TagHelperified element. + // 2. TagHelperDescriptor entirely applies to current element. Tag name, attributes, everything is fulfilled. + // -> Provide IntelliSense for the bound attributes for the applied descriptors. + // + // Within each of the above scenarios if an attribute completion has a corresponding bound attribute we associate it with the corresponding + // BoundAttributeDescriptor. By doing this a user can see what C# type a TagHelper expects for the attribute. + // public override AttributeCompletionResult GetAttributeCompletions(AttributeCompletionContext completionContext) { if (completionContext == null) @@ -212,7 +208,7 @@ namespace Microsoft.VisualStudio.Editor.Razor { foreach (var completionTagName in elementCompletions.Keys) { - if (elementCompletions[completionTagName].Count > 0 || + if (elementCompletions[completionTagName].Count > 0 || !string.IsNullOrEmpty(prefix) && completionTagName.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) { // The current completion either has other TagHelper's associated with it or is prefixed with a non-empty @@ -293,4 +289,4 @@ namespace Microsoft.VisualStudio.Editor.Razor } } } -} +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultTagHelperFactsService.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultTagHelperFactsService.cs index 2769d59657..8424353951 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/DefaultTagHelperFactsService.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultTagHelperFactsService.cs @@ -4,8 +4,8 @@ using System; using System.Collections.Generic; using System.ComponentModel.Composition; +using System.Linq; using Microsoft.AspNetCore.Razor.Language; -using Microsoft.CodeAnalysis.Razor; namespace Microsoft.VisualStudio.Editor.Razor { @@ -13,15 +13,6 @@ namespace Microsoft.VisualStudio.Editor.Razor [Export(typeof(TagHelperFactsService))] internal class DefaultTagHelperFactsService : TagHelperFactsService { - private readonly TagHelperFactsServiceInternal _tagHelperFactsService; - - [ImportingConstructor] - public DefaultTagHelperFactsService(VisualStudioWorkspaceAccessor workspaceAccessor) - { - var razorLanguageServices = workspaceAccessor.Workspace.Services.GetLanguageServices(RazorLanguage.Name); - _tagHelperFactsService = razorLanguageServices.GetRequiredService(); - } - public override TagHelperBinding GetTagHelperBinding( TagHelperDocumentContext documentContext, string tagName, @@ -29,7 +20,32 @@ namespace Microsoft.VisualStudio.Editor.Razor string parentTag, bool parentIsTagHelper) { - return _tagHelperFactsService.GetTagHelperBinding(documentContext, tagName, attributes, parentTag, parentIsTagHelper); + if (documentContext == null) + { + throw new ArgumentNullException(nameof(documentContext)); + } + + if (tagName == null) + { + throw new ArgumentNullException(nameof(tagName)); + } + + if (attributes == null) + { + throw new ArgumentNullException(nameof(attributes)); + } + + var descriptors = documentContext.TagHelpers; + if (descriptors == null || descriptors.Count == 0) + { + return null; + } + + var prefix = documentContext.Prefix; + var tagHelperBinder = new TagHelperBinder(prefix, descriptors); + var binding = tagHelperBinder.GetBinding(tagName, attributes.ToList(), parentTag, parentIsTagHelper); + + return binding; } public override IEnumerable GetBoundTagHelperAttributes( @@ -37,7 +53,37 @@ namespace Microsoft.VisualStudio.Editor.Razor string attributeName, TagHelperBinding binding) { - return _tagHelperFactsService.GetBoundTagHelperAttributes(documentContext, attributeName, binding); + if (documentContext == null) + { + throw new ArgumentNullException(nameof(documentContext)); + } + + if (attributeName == null) + { + throw new ArgumentNullException(nameof(attributeName)); + } + + if (binding == null) + { + throw new ArgumentNullException(nameof(binding)); + } + + var matchingBoundAttributes = new List(); + foreach (var descriptor in binding.Descriptors) + { + foreach (var boundAttributeDescriptor in descriptor.BoundAttributes) + { + if (TagHelperMatchingConventions.CanSatisfyBoundAttribute(attributeName, boundAttributeDescriptor)) + { + matchingBoundAttributes.Add(boundAttributeDescriptor); + + // Only one bound attribute can match an attribute + break; + } + } + } + + return matchingBoundAttributes; } public override IReadOnlyList GetTagHelpersGivenTag( @@ -45,12 +91,76 @@ namespace Microsoft.VisualStudio.Editor.Razor string tagName, string parentTag) { - return _tagHelperFactsService.GetTagHelpersGivenTag(documentContext, tagName, parentTag); + if (documentContext == null) + { + throw new ArgumentNullException(nameof(documentContext)); + } + + if (tagName == null) + { + throw new ArgumentNullException(nameof(tagName)); + } + + var matchingDescriptors = new List(); + var descriptors = documentContext?.TagHelpers; + if (descriptors?.Count == 0) + { + return matchingDescriptors; + } + + var prefix = documentContext.Prefix ?? string.Empty; + if (!tagName.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) + { + // Can't possibly match TagHelpers, it doesn't start with the TagHelperPrefix. + return matchingDescriptors; + } + + var tagNameWithoutPrefix = tagName.Substring(prefix.Length); + for (var i = 0; i < descriptors.Count; i++) + { + var descriptor = descriptors[i]; + foreach (var rule in descriptor.TagMatchingRules) + { + if (TagHelperMatchingConventions.SatisfiesTagName(tagNameWithoutPrefix, rule) && + TagHelperMatchingConventions.SatisfiesParentTag(parentTag, rule)) + { + matchingDescriptors.Add(descriptor); + break; + } + } + } + + return matchingDescriptors; } public override IReadOnlyList GetTagHelpersGivenParent(TagHelperDocumentContext documentContext, string parentTag) { - return _tagHelperFactsService.GetTagHelpersGivenParent(documentContext, parentTag); + if (documentContext == null) + { + throw new ArgumentNullException(nameof(documentContext)); + } + + var matchingDescriptors = new List(); + var descriptors = documentContext?.TagHelpers; + if (descriptors?.Count == 0) + { + return matchingDescriptors; + } + + for (var i = 0; i < descriptors.Count; i++) + { + var descriptor = descriptors[i]; + foreach (var rule in descriptor.TagMatchingRules) + { + if (TagHelperMatchingConventions.SatisfiesParentTag(parentTag, rule)) + { + matchingDescriptors.Add(descriptor); + break; + } + } + } + + return matchingDescriptors; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultTagHelperResolver.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultTagHelperResolver.cs new file mode 100644 index 0000000000..7547bde441 --- /dev/null +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultTagHelperResolver.cs @@ -0,0 +1,60 @@ +// 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.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc.Razor.Extensions; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Razor; + +namespace Microsoft.VisualStudio.Editor.Razor +{ + internal class DefaultTagHelperResolver : TagHelperResolver + { + // Hack for testability. The view component visitor will normally just no op if we're not referencing + // an appropriate version of MVC. + internal bool ForceEnableViewComponentDiscovery { get; set; } + + public override async Task GetTagHelpersAsync(Project project, CancellationToken cancellationToken) + { + if (project == null) + { + throw new ArgumentNullException(nameof(project)); + } + + var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false); + var result = GetTagHelpers(compilation); + return result; + } + + // Internal for testing + internal TagHelperResolutionResult GetTagHelpers(Compilation compilation) + { + var descriptors = new List(); + + var providers = new ITagHelperDescriptorProvider[] + { + new DefaultTagHelperDescriptorProvider() { DesignTime = true, }, + new ViewComponentTagHelperDescriptorProvider() { ForceEnabled = ForceEnableViewComponentDiscovery }, + }; + + var results = new List(); + var context = TagHelperDescriptorProviderContext.Create(results); + context.SetCompilation(compilation); + + for (var i = 0; i < providers.Length; i++) + { + var provider = providers[i]; + provider.Execute(context); + } + + var diagnostics = new List(); + var resolutionResult = new TagHelperResolutionResult(results, diagnostics); + + return resolutionResult; + } + } +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultTagHelperResolverFactory.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultTagHelperResolverFactory.cs similarity index 66% rename from src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultTagHelperResolverFactory.cs rename to src/Microsoft.VisualStudio.Editor.Razor/DefaultTagHelperResolverFactory.cs index f59d049bfa..50e2e96179 100644 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultTagHelperResolverFactory.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultTagHelperResolverFactory.cs @@ -1,22 +1,20 @@ // 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.ComponentModel.Composition; +using System.Composition; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Razor; -namespace Microsoft.VisualStudio.LanguageServices.Razor +namespace Microsoft.VisualStudio.Editor.Razor { + [Shared] [ExportLanguageServiceFactory(typeof(TagHelperResolver), RazorLanguage.Name, ServiceLayer.Default)] internal class DefaultTagHelperResolverFactory : ILanguageServiceFactory { - [Import] - public VisualStudioWorkspace Workspace { get; set; } - public ILanguageService CreateLanguageService(HostLanguageServices languageServices) { - return new DefaultTagHelperResolver(Workspace.Services.GetRequiredService(), Workspace); + return new DefaultTagHelperResolver(); } } } \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioDocumentTracker.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioDocumentTracker.cs similarity index 94% rename from src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioDocumentTracker.cs rename to src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioDocumentTracker.cs index 1cc76169aa..eb771205d1 100644 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioDocumentTracker.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioDocumentTracker.cs @@ -9,7 +9,6 @@ using Microsoft.CodeAnalysis.Razor; using Microsoft.CodeAnalysis.Razor.Editor; using Microsoft.CodeAnalysis.Razor.ProjectSystem; using Microsoft.VisualStudio.Editor.Razor; -using Microsoft.VisualStudio.Shell.Interop; using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text.Editor; @@ -19,7 +18,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor { private readonly string _filePath; private readonly ProjectSnapshotManager _projectManager; - private readonly EditorSettingsManagerInternal _editorSettingsManager; + private readonly EditorSettingsManager _editorSettingsManager; private readonly TextBufferProjectService _projectService; private readonly ITextBuffer _textBuffer; private readonly List _textViews; @@ -34,13 +33,13 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor string filePath, ProjectSnapshotManager projectManager, TextBufferProjectService projectService, - EditorSettingsManagerInternal editorSettingsManager, + EditorSettingsManager editorSettingsManager, Workspace workspace, ITextBuffer textBuffer) { if (string.IsNullOrEmpty(filePath)) { - throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(filePath)); + throw new ArgumentException(Microsoft.VisualStudio.Editor.Razor.Resources.ArgumentCannotBeNullOrEmpty, nameof(filePath)); } if (projectManager == null) @@ -154,7 +153,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor // unexpected /impossible states. // // We also want to successfully shut down if the buffer is something other than .cshtml. - IVsHierarchy hierarchy = null; + object hierarchy = null; string projectPath = null; var isSupportedProject = false; @@ -162,7 +161,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor // We expect the document to have a hierarchy even if it's not a real 'project'. // However the hierarchy can be null when the document is in the process of closing. - (hierarchy = _projectService.GetHierarchy(_textBuffer)) != null) + (hierarchy = _projectService.GetHostProject(_textBuffer)) != null) { projectPath = _projectService.GetProjectPath(hierarchy); isSupportedProject = _projectService.IsSupportedProject(hierarchy); @@ -226,4 +225,4 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor OnContextChanged(_project, ContextChangeKind.EditorSettingsChanged); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioDocumentTrackerFactory.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioDocumentTrackerFactory.cs similarity index 66% rename from src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioDocumentTrackerFactory.cs rename to src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioDocumentTrackerFactory.cs index 53c2c074a2..b6e847192b 100644 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioDocumentTrackerFactory.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioDocumentTrackerFactory.cs @@ -2,19 +2,16 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.ComponentModel.Composition; using System.Diagnostics; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Razor; using Microsoft.CodeAnalysis.Razor.Editor; using Microsoft.CodeAnalysis.Razor.ProjectSystem; -using Microsoft.VisualStudio.Editor.Razor; +using Microsoft.VisualStudio.LanguageServices.Razor.Editor; using Microsoft.VisualStudio.Text; -namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor +namespace Microsoft.VisualStudio.Editor.Razor { - [System.Composition.Shared] - [Export(typeof(VisualStudioDocumentTrackerFactory))] internal class DefaultVisualStudioDocumentTrackerFactory : VisualStudioDocumentTrackerFactory { private readonly TextBufferProjectService _projectService; @@ -22,14 +19,31 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor private readonly Workspace _workspace; private readonly ForegroundDispatcher _foregroundDispatcher; private readonly ProjectSnapshotManager _projectManager; - private readonly EditorSettingsManagerInternal _editorSettingsManager; + private readonly EditorSettingsManager _editorSettingsManager; - [ImportingConstructor] public DefaultVisualStudioDocumentTrackerFactory( + ForegroundDispatcher foregroundDispatcher, + ProjectSnapshotManager projectManager, + EditorSettingsManager editorSettingsManager, TextBufferProjectService projectService, ITextDocumentFactoryService textDocumentFactory, - [Import(typeof(VisualStudioWorkspace))] Workspace workspace) + Workspace workspace) { + if (foregroundDispatcher == null) + { + throw new ArgumentNullException(nameof(foregroundDispatcher)); + } + + if (projectManager == null) + { + throw new ArgumentNullException(nameof(projectManager)); + } + + if (editorSettingsManager == null) + { + throw new ArgumentNullException(nameof(editorSettingsManager)); + } + if (projectService == null) { throw new ArgumentNullException(nameof(projectService)); @@ -45,14 +59,12 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor throw new ArgumentNullException(nameof(workspace)); } + _foregroundDispatcher = foregroundDispatcher; + _projectManager = projectManager; + _editorSettingsManager = editorSettingsManager; _projectService = projectService; _textDocumentFactory = textDocumentFactory; _workspace = workspace; - - _foregroundDispatcher = workspace.Services.GetRequiredService(); - var razorLanguageServices = workspace.Services.GetLanguageServices(RazorLanguage.Name); - _projectManager = razorLanguageServices.GetRequiredService(); - _editorSettingsManager = razorLanguageServices.GetRequiredService(); } public override VisualStudioDocumentTracker Create(ITextBuffer textBuffer) @@ -69,9 +81,16 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor } var filePath = textDocument.FilePath; + var project = _projectService.GetHostProject(textBuffer); + if (project == null) + { + Debug.Fail("Text buffer should belong to a project."); + return null; + } + var tracker = new DefaultVisualStudioDocumentTracker(filePath, _projectManager, _projectService, _editorSettingsManager, _workspace, textBuffer); return tracker; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioDocumentTrackerFactoryFactory.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioDocumentTrackerFactoryFactory.cs new file mode 100644 index 0000000000..92adb1db84 --- /dev/null +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioDocumentTrackerFactoryFactory.cs @@ -0,0 +1,75 @@ +// 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.Composition; +using Microsoft.CodeAnalysis.Host; +using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.CodeAnalysis.Razor; +using Microsoft.CodeAnalysis.Razor.Editor; +using Microsoft.CodeAnalysis.Razor.ProjectSystem; +using Microsoft.VisualStudio.Text; + +namespace Microsoft.VisualStudio.Editor.Razor +{ + [Shared] + [ExportLanguageServiceFactory(typeof(VisualStudioDocumentTrackerFactory), RazorLanguage.Name, ServiceLayer.Default)] + internal class DefaultVisualStudioDocumentTrackerFactoryFactory : ILanguageServiceFactory + { + private readonly ForegroundDispatcher _foregroundDispatcher; + private readonly TextBufferProjectService _projectService; + private readonly EditorSettingsManager _editorSettingsManager; + private readonly ITextDocumentFactoryService _textDocumentFactory; + + [ImportingConstructor] + public DefaultVisualStudioDocumentTrackerFactoryFactory( + ForegroundDispatcher foregroundDispatcher, + TextBufferProjectService projectService, + EditorSettingsManager editorSettingsManager, + ITextDocumentFactoryService textDocumentFactory) + { + if (foregroundDispatcher == null) + { + throw new ArgumentNullException(nameof(foregroundDispatcher)); + } + + if (projectService == null) + { + throw new ArgumentNullException(nameof(projectService)); + } + + if (editorSettingsManager == null) + { + throw new ArgumentNullException(nameof(editorSettingsManager)); + } + + if (textDocumentFactory == null) + { + throw new ArgumentNullException(nameof(textDocumentFactory)); + } + + _foregroundDispatcher = foregroundDispatcher; + _projectService = projectService; + _editorSettingsManager = editorSettingsManager; + _textDocumentFactory = textDocumentFactory; + } + + public ILanguageService CreateLanguageService(HostLanguageServices languageServices) + { + if (languageServices == null) + { + throw new ArgumentNullException(nameof(languageServices)); + } + + var projectManager = languageServices.GetRequiredService(); + + return new DefaultVisualStudioDocumentTrackerFactory( + _foregroundDispatcher, + projectManager, + _editorSettingsManager, + _projectService, + _textDocumentFactory, + languageServices.WorkspaceServices.Workspace); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParser.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParser.cs index 99a7163ba8..7ace362811 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParser.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParser.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Threading; using System.Threading.Tasks; @@ -28,13 +29,14 @@ namespace Microsoft.VisualStudio.Editor.Razor internal ChangeReference _latestChangeReference; private readonly object IdleLock = new object(); - private readonly ICompletionBroker _completionBroker; + private readonly VisualStudioCompletionBroker _completionBroker; private readonly VisualStudioDocumentTracker _documentTracker; private readonly ForegroundDispatcher _dispatcher; - private readonly RazorTemplateEngineFactoryService _templateEngineFactory; + private readonly RazorProjectEngineFactoryService _projectEngineFactory; private readonly ErrorReporter _errorReporter; private RazorSyntaxTreePartialParser _partialParser; - private RazorTemplateEngine _templateEngine; + private RazorProjectEngine _projectEngine; + private DelegatingTemplateEngine _templateEngine; private RazorCodeDocument _codeDocument; private ITextSnapshot _snapshot; private bool _disposed; @@ -48,9 +50,9 @@ namespace Microsoft.VisualStudio.Editor.Razor public DefaultVisualStudioRazorParser( ForegroundDispatcher dispatcher, VisualStudioDocumentTracker documentTracker, - RazorTemplateEngineFactoryService templateEngineFactory, + RazorProjectEngineFactoryService projectEngineFactory, ErrorReporter errorReporter, - ICompletionBroker completionBroker) + VisualStudioCompletionBroker completionBroker) { if (dispatcher == null) { @@ -62,9 +64,9 @@ namespace Microsoft.VisualStudio.Editor.Razor throw new ArgumentNullException(nameof(documentTracker)); } - if (templateEngineFactory == null) + if (projectEngineFactory == null) { - throw new ArgumentNullException(nameof(templateEngineFactory)); + throw new ArgumentNullException(nameof(projectEngineFactory)); } if (errorReporter == null) @@ -78,7 +80,7 @@ namespace Microsoft.VisualStudio.Editor.Razor } _dispatcher = dispatcher; - _templateEngineFactory = templateEngineFactory; + _projectEngineFactory = projectEngineFactory; _errorReporter = errorReporter; _completionBroker = completionBroker; _documentTracker = documentTracker; @@ -171,8 +173,18 @@ namespace Microsoft.VisualStudio.Editor.Razor _dispatcher.AssertForegroundThread(); var projectDirectory = Path.GetDirectoryName(_documentTracker.ProjectPath); - _templateEngine = _templateEngineFactory.Create(projectDirectory, ConfigureTemplateEngine); - _parser = new BackgroundParser(TemplateEngine, FilePath); + _projectEngine = _projectEngineFactory.Create(projectDirectory, ConfigureProjectEngine); + + // Make sure any tests use the real thing or a good mock. These tests can cause failures + // that are hard to understand when this throws. + Debug.Assert(_projectEngine != null); + Debug.Assert(_projectEngine.Engine != null); + Debug.Assert(_projectEngine.FileSystem != null); + + // This is still exposed and used by WTE in 15.7 + _templateEngine = new DelegatingTemplateEngine(_projectEngine); + + _parser = new BackgroundParser(_projectEngine, FilePath, projectDirectory); _parser.ResultsReady += OnResultsReady; _parser.Start(); @@ -384,7 +396,7 @@ namespace Microsoft.VisualStudio.Editor.Razor DocumentStructureChanged?.Invoke(this, args); } - private void ConfigureTemplateEngine(IRazorEngineBuilder builder) + private void ConfigureProjectEngine(RazorProjectEngineBuilder builder) { builder.Features.Add(new VisualStudioParserOptionsFeature(_documentTracker.EditorSettings)); builder.Features.Add(new VisualStudioTagHelperFeature(TextBuffer)); diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParserFactory.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParserFactory.cs new file mode 100644 index 0000000000..5318ede596 --- /dev/null +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParserFactory.cs @@ -0,0 +1,66 @@ +// 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 Microsoft.CodeAnalysis.Razor; + +namespace Microsoft.VisualStudio.Editor.Razor +{ + internal class DefaultVisualStudioRazorParserFactory : VisualStudioRazorParserFactory + { + private readonly ForegroundDispatcher _dispatcher; + private readonly RazorProjectEngineFactoryService _projectEngineFactoryService; + private readonly VisualStudioCompletionBroker _completionBroker; + private readonly ErrorReporter _errorReporter; + + public DefaultVisualStudioRazorParserFactory( + ForegroundDispatcher dispatcher, + ErrorReporter errorReporter, + VisualStudioCompletionBroker completionBroker, + RazorProjectEngineFactoryService projectEngineFactoryService) + { + if (dispatcher == null) + { + throw new ArgumentNullException(nameof(dispatcher)); + } + + if (errorReporter == null) + { + throw new ArgumentNullException(nameof(errorReporter)); + } + + if (completionBroker == null) + { + throw new ArgumentNullException(nameof(completionBroker)); + } + + if (projectEngineFactoryService == null) + { + throw new ArgumentNullException(nameof(projectEngineFactoryService)); + } + + _dispatcher = dispatcher; + _errorReporter = errorReporter; + _completionBroker = completionBroker; + _projectEngineFactoryService = projectEngineFactoryService; + } + + public override VisualStudioRazorParser Create(VisualStudioDocumentTracker documentTracker) + { + if (documentTracker == null) + { + throw new ArgumentNullException(nameof(documentTracker)); + } + + _dispatcher.AssertForegroundThread(); + + var parser = new DefaultVisualStudioRazorParser( + _dispatcher, + documentTracker, + _projectEngineFactoryService, + _errorReporter, + _completionBroker); + return parser; + } + } +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParserFactoryFactory.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParserFactoryFactory.cs new file mode 100644 index 0000000000..38cfe5f189 --- /dev/null +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParserFactoryFactory.cs @@ -0,0 +1,47 @@ +// 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.Composition; +using Microsoft.CodeAnalysis.Host; +using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.CodeAnalysis.Razor; + +namespace Microsoft.VisualStudio.Editor.Razor +{ + [Shared] + [ExportLanguageServiceFactory(typeof(VisualStudioRazorParserFactory), RazorLanguage.Name, ServiceLayer.Default)] + internal class DefaultVisualStudioRazorParserFactoryFactory : ILanguageServiceFactory + { + private readonly ForegroundDispatcher _foregroundDispatcher; + + [ImportingConstructor] + public DefaultVisualStudioRazorParserFactoryFactory(ForegroundDispatcher foregroundDispatcher) + { + if (foregroundDispatcher == null) + { + throw new ArgumentNullException(nameof(foregroundDispatcher)); + } + + _foregroundDispatcher = foregroundDispatcher; + } + public ILanguageService CreateLanguageService(HostLanguageServices languageServices) + { + if (languageServices == null) + { + throw new ArgumentNullException(nameof(languageServices)); + } + + var workspaceServices = languageServices.WorkspaceServices; + var errorReporter = workspaceServices.GetRequiredService(); + var completionBroker = languageServices.GetRequiredService(); + var projectEngineFactoryService = languageServices.GetRequiredService(); + + return new DefaultVisualStudioRazorParserFactory( + _foregroundDispatcher, + errorReporter, + completionBroker, + projectEngineFactoryService); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DelegatingTemplateEngine.cs b/src/Microsoft.VisualStudio.Editor.Razor/DelegatingTemplateEngine.cs new file mode 100644 index 0000000000..912afc2502 --- /dev/null +++ b/src/Microsoft.VisualStudio.Editor.Razor/DelegatingTemplateEngine.cs @@ -0,0 +1,40 @@ +// 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.Collections.Generic; +using System.Linq; +using Microsoft.AspNetCore.Razor.Language; + +namespace Microsoft.VisualStudio.Editor.Razor +{ + internal class DelegatingTemplateEngine : RazorTemplateEngine + { + private readonly RazorProjectEngine _inner; + + public DelegatingTemplateEngine(RazorProjectEngine inner) + : base(inner.Engine, inner.FileSystem) + { + if (inner == null) + { + throw new ArgumentNullException(nameof(inner)); + } + + _inner = inner; + } + + public override IEnumerable GetImportItems(RazorProjectItem projectItem) + { + var feature = _inner.ProjectFeatures.OfType().FirstOrDefault(); + if (feature == null) + { + return Array.Empty(); + } + + var imports = feature.GetImports(projectItem); + var physicalImports = imports.Where(import => import.FilePath != null); + + return physicalImports; + } + } +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/TextBufferProjectService.cs b/src/Microsoft.VisualStudio.Editor.Razor/TextBufferProjectService.cs new file mode 100644 index 0000000000..b6add8abd2 --- /dev/null +++ b/src/Microsoft.VisualStudio.Editor.Razor/TextBufferProjectService.cs @@ -0,0 +1,18 @@ +// 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.VisualStudio.Text; + +namespace Microsoft.VisualStudio.Editor.Razor +{ + internal abstract class TextBufferProjectService + { + public abstract object GetHostProject(ITextBuffer textBuffer); + + public abstract bool IsSupportedProject(object project); + + public abstract string GetProjectPath(object project); + + public abstract string GetProjectName(object project); + } +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/TextSnapshotProjectItem.cs b/src/Microsoft.VisualStudio.Editor.Razor/TextSnapshotProjectItem.cs new file mode 100644 index 0000000000..7d120d5640 --- /dev/null +++ b/src/Microsoft.VisualStudio.Editor.Razor/TextSnapshotProjectItem.cs @@ -0,0 +1,65 @@ +// 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.IO; +using System.Text; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.VisualStudio.Text; + +namespace Microsoft.VisualStudio.Editor.Razor +{ + internal class TextSnapshotProjectItem : RazorProjectItem + { + private readonly ITextSnapshot _snapshot; + + public TextSnapshotProjectItem(ITextSnapshot snapshot, string projectDirectory, string relativeFilePath, string filePath) + { + if (snapshot == null) + { + throw new ArgumentNullException(nameof(snapshot)); + } + + if (string.IsNullOrEmpty(projectDirectory)) + { + throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(projectDirectory)); + } + + if (string.IsNullOrEmpty(relativeFilePath)) + { + throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(relativeFilePath)); + } + + if (string.IsNullOrEmpty(filePath)) + { + throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(filePath)); + } + + _snapshot = snapshot; + BasePath = projectDirectory; + FilePath = relativeFilePath; + PhysicalPath = filePath; + } + + public override string BasePath { get; } + + public override string FilePath { get; } + + public override string PhysicalPath { get; } + + public override bool Exists => true; + + public override Stream Read() + { + var charArray = _snapshot.ToCharArray(0, _snapshot.Length); + + // We can assume UTF8 because the call path that reads from RazorProjectItem => SourceDocument + // can't determine the encoding and always assumes Encoding.UTF8. This is something that we might + // want to revisit in the future. + var bytes = Encoding.UTF8.GetBytes(charArray); + var memoryStream = new MemoryStream(bytes); + return memoryStream; + } + } + +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioCompletionBroker.cs b/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioCompletionBroker.cs new file mode 100644 index 0000000000..f9946bb528 --- /dev/null +++ b/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioCompletionBroker.cs @@ -0,0 +1,13 @@ +// 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.CodeAnalysis.Host; +using Microsoft.VisualStudio.Text.Editor; + +namespace Microsoft.VisualStudio.Editor.Razor +{ + internal abstract class VisualStudioCompletionBroker : ILanguageService + { + public abstract bool IsCompletionActive(ITextView textView); + } +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioDocumentTrackerFactory.cs b/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioDocumentTrackerFactory.cs index 1576ac9074..39f89aafd1 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioDocumentTrackerFactory.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioDocumentTrackerFactory.cs @@ -1,12 +1,13 @@ // 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.CodeAnalysis.Host; using Microsoft.VisualStudio.Text; namespace Microsoft.VisualStudio.Editor.Razor { - internal abstract class VisualStudioDocumentTrackerFactory + internal abstract class VisualStudioDocumentTrackerFactory : ILanguageService { public abstract VisualStudioDocumentTracker Create(ITextBuffer textBuffer); } -} +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioRazorParserFactory.cs b/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioRazorParserFactory.cs index 580b33cc62..7d30a46027 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioRazorParserFactory.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioRazorParserFactory.cs @@ -1,9 +1,11 @@ // 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.CodeAnalysis.Host; + namespace Microsoft.VisualStudio.Editor.Razor { - internal abstract class VisualStudioRazorParserFactory + internal abstract class VisualStudioRazorParserFactory : ILanguageService { public abstract VisualStudioRazorParser Create(VisualStudioDocumentTracker documentTracker); } diff --git a/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioWorkspaceAccessor.cs b/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioWorkspaceAccessor.cs index 2e84e16ec8..a3394804a6 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioWorkspaceAccessor.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioWorkspaceAccessor.cs @@ -2,11 +2,12 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.CodeAnalysis; +using Microsoft.VisualStudio.Text; namespace Microsoft.VisualStudio.Editor.Razor { internal abstract class VisualStudioWorkspaceAccessor { - public abstract Workspace Workspace { get; } + public abstract bool TryGetWorkspace(ITextBuffer textBuffer, out Workspace workspace); } -} +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultTagHelperResolver.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultTagHelperResolver.cs deleted file mode 100644 index 31713fb3b2..0000000000 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultTagHelperResolver.cs +++ /dev/null @@ -1,123 +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; -using System.Collections.Generic; -using System.Composition; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc.Razor.Extensions; -using Microsoft.AspNetCore.Razor.Language; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Razor; -using Microsoft.VisualStudio.Shell; -using Microsoft.VisualStudio.Shell.Interop; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace Microsoft.VisualStudio.LanguageServices.Razor -{ - internal class DefaultTagHelperResolver : TagHelperResolver - { - private readonly ErrorReporter _errorReporter; - private readonly Workspace _workspace; - - public DefaultTagHelperResolver(ErrorReporter errorReporter, Workspace workspace) - { - _errorReporter = errorReporter; - _workspace = workspace; - } - - public async Task GetTagHelpersAsync(Project project) - { - if (project == null) - { - throw new ArgumentNullException(nameof(project)); - } - - try - { - TagHelperResolutionResult result; - - // We're being overly defensive here because the OOP host can return null for the client/session/operation - // when it's disconnected (user stops the process). - // - // This will change in the future to an easier to consume API but for VS RTM this is what we have. - var client = await RazorLanguageServiceClientFactory.CreateAsync(_workspace, CancellationToken.None); - if (client != null) - { - using (var session = await client.CreateSessionAsync(project.Solution)) - { - if (session != null) - { - var jsonObject = await session.InvokeAsync( - "GetTagHelpersAsync", - new object[] { project.Id.Id, "Foo", }, - CancellationToken.None).ConfigureAwait(false); - - result = GetTagHelperResolutionResult(jsonObject); - - if (result != null) - { - return result; - } - } - } - } - - // The OOP host is turned off, so let's do this in process. - var compilation = await project.GetCompilationAsync(CancellationToken.None).ConfigureAwait(false); - result = GetTagHelpers(compilation); - return result; - } - catch (Exception exception) - { - _errorReporter.ReportError(exception, project); - - throw new InvalidOperationException( - Resources.FormatUnexpectedException( - typeof(DefaultTagHelperResolver).FullName, - nameof(GetTagHelpersAsync)), - exception); - } - } - - public override TagHelperResolutionResult GetTagHelpers(Compilation compilation) - { - var descriptors = new List(); - - var providers = new ITagHelperDescriptorProvider[] - { - new DefaultTagHelperDescriptorProvider() { DesignTime = true, }, - new ViewComponentTagHelperDescriptorProvider(), - }; - - var results = new List(); - var context = TagHelperDescriptorProviderContext.Create(results); - context.SetCompilation(compilation); - - for (var i = 0; i < providers.Length; i++) - { - var provider = providers[i]; - provider.Execute(context); - } - - var diagnostics = new List(); - var resolutionResult = new TagHelperResolutionResult(results, diagnostics); - - return resolutionResult; - } - - private TagHelperResolutionResult GetTagHelperResolutionResult(JObject jsonObject) - { - var serializer = new JsonSerializer(); - serializer.Converters.Add(TagHelperDescriptorJsonConverter.Instance); - serializer.Converters.Add(RazorDiagnosticJsonConverter.Instance); - - using (var reader = jsonObject.CreateReader()) - { - return serializer.Deserialize(reader); - } - } - } -} diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultVisualStudioWorkspaceAccessor.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultVisualStudioWorkspaceAccessor.cs index 4749c44f5b..d3ef76b676 100644 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultVisualStudioWorkspaceAccessor.cs +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultVisualStudioWorkspaceAccessor.cs @@ -1,9 +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 System; using System.ComponentModel.Composition; +using System.Linq; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Text; using Microsoft.VisualStudio.Editor.Razor; +using Microsoft.VisualStudio.Text; +using Microsoft.VisualStudio.Text.Projection; namespace Microsoft.VisualStudio.LanguageServices.Razor { @@ -11,12 +16,103 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor [Export(typeof(VisualStudioWorkspaceAccessor))] internal class DefaultVisualStudioWorkspaceAccessor : VisualStudioWorkspaceAccessor { + private readonly IBufferGraphFactoryService _bufferGraphService; + private readonly TextBufferProjectService _projectService; + private readonly Workspace _defaultWorkspace; + [ImportingConstructor] - public DefaultVisualStudioWorkspaceAccessor([Import(typeof(VisualStudioWorkspace))] Workspace workspace) + public DefaultVisualStudioWorkspaceAccessor( + IBufferGraphFactoryService bufferGraphService, + TextBufferProjectService projectService, + [Import(typeof(VisualStudioWorkspace))] Workspace defaultWorkspace) { - Workspace = workspace; + if (bufferGraphService == null) + { + throw new ArgumentNullException(nameof(bufferGraphService)); + } + + if (projectService == null) + { + throw new ArgumentNullException(nameof(projectService)); + } + + if (defaultWorkspace == null) + { + throw new ArgumentNullException(nameof(defaultWorkspace)); + } + + _bufferGraphService = bufferGraphService; + _projectService = projectService; + _defaultWorkspace = defaultWorkspace; } - public override Workspace Workspace { get; } + public override bool TryGetWorkspace(ITextBuffer textBuffer, out Workspace workspace) + { + if (textBuffer == null) + { + throw new ArgumentNullException(nameof(textBuffer)); + } + + // We do a best effort approach in this method to get the workspace that belongs to the TextBuffer. + // The approaches we take to find the workspace are: + // + // 1. Look for a C# projection buffer associated with the Razor buffer. If we can find one we let + // Roslyn take control of finding the Workspace (projectionBuffer.GetWorkspace()). If not, + // fall back to determining if we can use the default workspace. + // 2. Look to see if this ITextBuffer is associated with a host project. If we find that our Razor + // buffer has a host project, we make the assumption that we should use the default VisualStudioWorkspace. + + if (TryGetWorkspaceFromProjectionBuffer(textBuffer, out workspace)) + { + return true; + } + + if (TryGetWorkspaceFromHostProject(textBuffer, out workspace)) + { + return true; + } + + workspace = null; + return false; + } + + // Internal virtual for testing + internal virtual bool TryGetWorkspaceFromProjectionBuffer(ITextBuffer textBuffer, out Workspace workspace) + { + var graph = _bufferGraphService.CreateBufferGraph(textBuffer); + var projectedCSharpBuffer = graph.GetTextBuffers(buffer => buffer.ContentType.IsOfType("CSharp")).FirstOrDefault(); + + if (projectedCSharpBuffer == null) + { + workspace = null; + return false; + } + + workspace = projectedCSharpBuffer.GetWorkspace(); + if (workspace == null) + { + // Couldn't resolve a workspace for the projected csharp buffer. + return false; + } + + return true; + } + + // Internal virtual for testing + internal virtual bool TryGetWorkspaceFromHostProject(ITextBuffer textBuffer, out Workspace workspace) + { + var project = _projectService.GetHostProject(textBuffer); + + if (project == null) + { + // Could not locate a project for the given text buffer. + workspace = null; + return false; + } + + // We have a host project, assume default workspace. + workspace = _defaultWorkspace; + return true; + } } -} +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultRazorEditorFactoryService.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultRazorEditorFactoryService.cs index 226f0af2da..5b868ee3ad 100644 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultRazorEditorFactoryService.cs +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultRazorEditorFactoryService.cs @@ -4,45 +4,27 @@ using System; using System.ComponentModel.Composition; using System.Diagnostics; -using Microsoft.VisualStudio.Editor.Razor; +using Microsoft.CodeAnalysis.Razor; using Microsoft.VisualStudio.Text; -namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor +namespace Microsoft.VisualStudio.Editor.Razor { [System.Composition.Shared] [Export(typeof(RazorEditorFactoryService))] internal class DefaultRazorEditorFactoryService : RazorEditorFactoryService { private static readonly object RazorTextBufferInitializationKey = new object(); - - private readonly VisualStudioDocumentTrackerFactory _documentTrackerFactory; - private readonly VisualStudioRazorParserFactory _parserFactory; - private readonly BraceSmartIndenterFactory _braceSmartIndenterFactory; + private readonly VisualStudioWorkspaceAccessor _workspaceAccessor; [ImportingConstructor] - public DefaultRazorEditorFactoryService( - VisualStudioDocumentTrackerFactory documentTrackerFactory, - VisualStudioRazorParserFactory parserFactory, - BraceSmartIndenterFactory braceSmartIndenterFactory) + public DefaultRazorEditorFactoryService(VisualStudioWorkspaceAccessor workspaceAccessor) { - if (documentTrackerFactory == null) + if (workspaceAccessor == null) { - throw new ArgumentNullException(nameof(documentTrackerFactory)); + throw new ArgumentNullException(nameof(workspaceAccessor)); } - if (parserFactory == null) - { - throw new ArgumentNullException(nameof(parserFactory)); - } - - if (braceSmartIndenterFactory == null) - { - throw new ArgumentNullException(nameof(braceSmartIndenterFactory)); - } - - _documentTrackerFactory = documentTrackerFactory; - _parserFactory = parserFactory; - _braceSmartIndenterFactory = braceSmartIndenterFactory; + _workspaceAccessor = workspaceAccessor; } public override bool TryGetDocumentTracker(ITextBuffer textBuffer, out VisualStudioDocumentTracker documentTracker) @@ -58,8 +40,13 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor return false; } - EnsureTextBufferInitialized(textBuffer); - + var textBufferInitialized = TryInitializeTextBuffer(textBuffer); + if (!textBufferInitialized) + { + documentTracker = null; + return false; + } + if (!textBuffer.Properties.TryGetProperty(typeof(VisualStudioDocumentTracker), out documentTracker)) { Debug.Fail("Document tracker should have been stored on the text buffer during initialization."); @@ -82,7 +69,12 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor return false; } - EnsureTextBufferInitialized(textBuffer); + var textBufferInitialized = TryInitializeTextBuffer(textBuffer); + if (!textBufferInitialized) + { + parser = null; + return false; + } if (!textBuffer.Properties.TryGetProperty(typeof(VisualStudioRazorParser), out parser)) { @@ -106,7 +98,12 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor return false; } - EnsureTextBufferInitialized(textBuffer); + var textBufferInitialized = TryInitializeTextBuffer(textBuffer); + if (!textBufferInitialized) + { + braceSmartIndenter = null; + return false; + } if (!textBuffer.Properties.TryGetProperty(typeof(BraceSmartIndenter), out braceSmartIndenter)) { @@ -118,24 +115,37 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor } // Internal for testing - internal void EnsureTextBufferInitialized(ITextBuffer textBuffer) + internal bool TryInitializeTextBuffer(ITextBuffer textBuffer) { if (textBuffer.Properties.ContainsProperty(RazorTextBufferInitializationKey)) { // Buffer already initialized. - return; + return true; } - var tracker = _documentTrackerFactory.Create(textBuffer); + if (!_workspaceAccessor.TryGetWorkspace(textBuffer, out var workspace)) + { + // Could not locate workspace for given text buffer. + return false; + } + + var razorLanguageServices = workspace.Services.GetLanguageServices(RazorLanguage.Name); + var documentTrackerFactory = razorLanguageServices.GetRequiredService(); + var parserFactory = razorLanguageServices.GetRequiredService(); + var braceSmartIndenterFactory = razorLanguageServices.GetRequiredService(); + + var tracker = documentTrackerFactory.Create(textBuffer); textBuffer.Properties[typeof(VisualStudioDocumentTracker)] = tracker; - var parser = _parserFactory.Create(tracker); + var parser = parserFactory.Create(tracker); textBuffer.Properties[typeof(VisualStudioRazorParser)] = parser; - var braceSmartIndenter = _braceSmartIndenterFactory.Create(tracker); + var braceSmartIndenter = braceSmartIndenterFactory.Create(tracker); textBuffer.Properties[typeof(BraceSmartIndenter)] = braceSmartIndenter; textBuffer.Properties.AddProperty(RazorTextBufferInitializationKey, RazorTextBufferInitializationKey); + + return true; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultTextBufferProjectService.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultTextBufferProjectService.cs index f81d6fa4d5..2b6e5a2aa6 100644 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultTextBufferProjectService.cs +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultTextBufferProjectService.cs @@ -3,7 +3,8 @@ using System; using System.ComponentModel.Composition; -using Microsoft.CodeAnalysis; +using System.Diagnostics; +using Microsoft.VisualStudio.Editor.Razor; using Microsoft.VisualStudio.Shell; using Microsoft.VisualStudio.Shell.Interop; using Microsoft.VisualStudio.Text; @@ -13,6 +14,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor /// /// Infrastructure methods to find project information from an . /// + [System.Composition.Shared] [Export(typeof(TextBufferProjectService))] internal class DefaultTextBufferProjectService : TextBufferProjectService { @@ -24,8 +26,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor [ImportingConstructor] public DefaultTextBufferProjectService( [Import(typeof(SVsServiceProvider))] IServiceProvider services, - ITextDocumentFactoryService documentFactory, - [Import(typeof(VisualStudioWorkspace))] Workspace workspace) + ITextDocumentFactoryService documentFactory) { if (services == null) { @@ -41,7 +42,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor _documentTable = new RunningDocumentTable(services); } - public override IVsHierarchy GetHierarchy(ITextBuffer textBuffer) + public override object GetHostProject(ITextBuffer textBuffer) { if (textBuffer == null) { @@ -63,24 +64,30 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor return hierarchy; } - public override string GetProjectPath(IVsHierarchy hierarchy) + public override string GetProjectPath(object project) { - if (hierarchy == null) + if (project == null) { - throw new ArgumentNullException(nameof(hierarchy)); + throw new ArgumentNullException(nameof(project)); } + var hierarchy = project as IVsHierarchy; + Debug.Assert(hierarchy != null); + ErrorHandler.ThrowOnFailure(((IVsProject)hierarchy).GetMkDocument((uint)VSConstants.VSITEMID.Root, out var path), VSConstants.E_NOTIMPL); return path; } - public override bool IsSupportedProject(IVsHierarchy hierarchy) + public override bool IsSupportedProject(object project) { - if (hierarchy == null) + if (project == null) { - throw new ArgumentNullException(nameof(hierarchy)); + throw new ArgumentNullException(nameof(project)); } + var hierarchy = project as IVsHierarchy; + Debug.Assert(hierarchy != null); + try { return hierarchy.IsCapabilityMatch(DotNetCoreCapability); @@ -96,5 +103,23 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor return false; } + + public override string GetProjectName(object project) + { + if (project == null) + { + throw new ArgumentNullException(nameof(project)); + } + + var hierarchy = project as IVsHierarchy; + Debug.Assert(hierarchy != null); + + if (ErrorHandler.Failed(hierarchy.GetProperty((uint)VSConstants.VSITEMID.Root, (int)__VSHPROPID.VSHPROPID_Name, out var name))) + { + return null; + } + + return (string)name; + } } -} +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioCompletionBroker.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioCompletionBroker.cs new file mode 100644 index 0000000000..52521d27c8 --- /dev/null +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioCompletionBroker.cs @@ -0,0 +1,36 @@ +// 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 Microsoft.VisualStudio.Editor.Razor; +using Microsoft.VisualStudio.Language.Intellisense; +using Microsoft.VisualStudio.Text.Editor; + +namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor +{ + internal class DefaultVisualStudioCompletionBroker : VisualStudioCompletionBroker + { + private readonly ICompletionBroker _completionBroker; + + public DefaultVisualStudioCompletionBroker(ICompletionBroker completionBroker) + { + if (completionBroker == null) + { + throw new ArgumentNullException(nameof(completionBroker)); + } + + _completionBroker = completionBroker; + } + + public override bool IsCompletionActive(ITextView textView) + { + if (textView == null) + { + throw new ArgumentNullException(nameof(textView)); + } + + var completionIsActive = _completionBroker.IsCompletionActive(textView); + return completionIsActive; + } + } +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioCompletionBrokerFactory.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioCompletionBrokerFactory.cs new file mode 100644 index 0000000000..5312946e7f --- /dev/null +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioCompletionBrokerFactory.cs @@ -0,0 +1,41 @@ +// 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.Composition; +using Microsoft.CodeAnalysis.Host; +using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.CodeAnalysis.Razor; +using Microsoft.VisualStudio.Editor.Razor; +using Microsoft.VisualStudio.Language.Intellisense; + +namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor +{ + [Shared] + [ExportLanguageServiceFactory(typeof(VisualStudioCompletionBroker), RazorLanguage.Name, ServiceLayer.Default)] + internal class DefaultVisualStudioCompletionBrokerFactory : ILanguageServiceFactory + { + private readonly ICompletionBroker _completionBroker; + + [ImportingConstructor] + public DefaultVisualStudioCompletionBrokerFactory(ICompletionBroker completionBroker) + { + if (completionBroker == null) + { + throw new ArgumentNullException(nameof(completionBroker)); + } + + _completionBroker = completionBroker; + } + + public ILanguageService CreateLanguageService(HostLanguageServices languageServices) + { + if (languageServices == null) + { + throw new ArgumentNullException(nameof(languageServices)); + } + + return new DefaultVisualStudioCompletionBroker(_completionBroker); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioRazorParserFactory.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioRazorParserFactory.cs deleted file mode 100644 index 3e881f05ad..0000000000 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioRazorParserFactory.cs +++ /dev/null @@ -1,64 +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; -using System.Collections.Generic; -using System.ComponentModel.Composition; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Razor; -using Microsoft.VisualStudio.Editor.Razor; -using Microsoft.VisualStudio.Language.Intellisense; -using TemplateEngineFactoryService = Microsoft.CodeAnalysis.Razor.RazorTemplateEngineFactoryService; - -namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor -{ - [System.Composition.Shared] - [Export(typeof(VisualStudioRazorParserFactory))] - internal class DefaultVisualStudioRazorParserFactory : VisualStudioRazorParserFactory - { - private readonly ForegroundDispatcher _dispatcher; - private readonly TemplateEngineFactoryService _templateEngineFactoryService; - private readonly ICompletionBroker _completionBroker; - private readonly ErrorReporter _errorReporter; - - [ImportingConstructor] - public DefaultVisualStudioRazorParserFactory( - ICompletionBroker completionBroker, - [Import(typeof(VisualStudioWorkspace))] Workspace workspace) - { - if (completionBroker == null) - { - throw new ArgumentNullException(nameof(completionBroker)); - } - - if (workspace == null) - { - throw new ArgumentNullException(nameof(workspace)); - } - - _completionBroker = completionBroker; - _dispatcher = workspace.Services.GetRequiredService(); - _errorReporter = workspace.Services.GetRequiredService(); - var razorLanguageServices = workspace.Services.GetLanguageServices(RazorLanguage.Name); - _templateEngineFactoryService = razorLanguageServices.GetRequiredService(); - } - - public override VisualStudioRazorParser Create(VisualStudioDocumentTracker documentTracker) - { - if (documentTracker == null) - { - throw new ArgumentNullException(nameof(documentTracker)); - } - - _dispatcher.AssertForegroundThread(); - - var parser = new DefaultVisualStudioRazorParser( - _dispatcher, - documentTracker, - _templateEngineFactoryService, - _errorReporter, - _completionBroker); - return parser; - } - } -} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/RazorTextViewConnectionListener.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/RazorTextViewConnectionListener.cs index 860a8680e1..ae63cc5dfc 100644 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/RazorTextViewConnectionListener.cs +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/RazorTextViewConnectionListener.cs @@ -28,34 +28,6 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor [ImportingConstructor] public RazorTextViewConnectionListener( - TextBufferProjectService projectService, - RazorEditorFactoryService editorFactoryService, - [Import(typeof(VisualStudioWorkspace))] Workspace workspace) - { - if (projectService == null) - { - throw new ArgumentNullException(nameof(projectService)); - } - - if (editorFactoryService == null) - { - throw new ArgumentNullException(nameof(editorFactoryService)); - } - - if (workspace == null) - { - throw new ArgumentNullException(nameof(workspace)); - } - - _projectService = projectService; - _editorFactoryService = editorFactoryService; - _workspace = workspace; - - _foregroundDispatcher = workspace.Services.GetRequiredService(); - } - - // This is only for testing. We want to avoid using the actual Roslyn GetService methods in unit tests. - internal RazorTextViewConnectionListener( ForegroundDispatcher foregroundDispatcher, TextBufferProjectService projectService, RazorEditorFactoryService editorFactoryService, @@ -85,6 +57,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor _projectService = projectService; _editorFactoryService = editorFactoryService; _workspace = workspace; + } public Workspace Workspace => _workspace; @@ -111,8 +84,8 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor continue; } - var hierarchy = _projectService.GetHierarchy(textBuffer); - if (!_projectService.IsSupportedProject(hierarchy)) + var hostProject = _projectService.GetHostProject(textBuffer); + if (!_projectService.IsSupportedProject(hostProject)) { return; } diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/TextBufferProjectService.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/TextBufferProjectService.cs deleted file mode 100644 index 89a5eb49cd..0000000000 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/TextBufferProjectService.cs +++ /dev/null @@ -1,17 +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.VisualStudio.Shell.Interop; -using Microsoft.VisualStudio.Text; - -namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor -{ - internal abstract class TextBufferProjectService - { - public abstract IVsHierarchy GetHierarchy(ITextBuffer textBuffer); - - public abstract bool IsSupportedProject(IVsHierarchy hierarchy); - - public abstract string GetProjectPath(IVsHierarchy hierarchy); - } -} diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/Legacy/LegacyTagHelperResolver.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/Legacy/LegacyTagHelperResolver.cs index ed6cc73313..54b67052e2 100644 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/Legacy/LegacyTagHelperResolver.cs +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/Legacy/LegacyTagHelperResolver.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.ComponentModel.Composition; +using System.Threading; +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Razor; @@ -12,13 +14,23 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor // use TagHelperResolver. // ---------------------------------------------------------------------------------------------------- [Export(typeof(ITagHelperResolver))] - internal class LegacyTagHelperResolver : DefaultTagHelperResolver, ITagHelperResolver + internal class LegacyTagHelperResolver : OOPTagHelperResolver, ITagHelperResolver { [ImportingConstructor] public LegacyTagHelperResolver( [Import(typeof(VisualStudioWorkspace))] Workspace workspace) - : base(workspace.Services.GetRequiredService(), workspace) + : base(workspace) { } + + public Task GetTagHelpersAsync(Project project) + { + if (project == null) + { + throw new System.ArgumentNullException(nameof(project)); + } + + return base.GetTagHelpersAsync(project, CancellationToken.None); + } } } \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/OOPTagHelperResolver.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/OOPTagHelperResolver.cs new file mode 100644 index 0000000000..f0e81aeece --- /dev/null +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/OOPTagHelperResolver.cs @@ -0,0 +1,91 @@ +// 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; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Razor; +using Microsoft.VisualStudio.Editor.Razor; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Microsoft.VisualStudio.LanguageServices.Razor +{ + internal class OOPTagHelperResolver : TagHelperResolver + { + private readonly DefaultTagHelperResolver _defaultResolver; + private readonly Workspace _workspace; + + public OOPTagHelperResolver(Workspace workspace) + { + if (workspace == null) + { + throw new ArgumentNullException(nameof(workspace)); + } + + _workspace = workspace; + _defaultResolver = new DefaultTagHelperResolver(); + } + + public override async Task GetTagHelpersAsync(Project project, CancellationToken cancellationToken) + { + if (project == null) + { + throw new ArgumentNullException(nameof(project)); + } + + try + { + TagHelperResolutionResult result = null; + + // We're being defensive here because the OOP host can return null for the client/session/operation + // when it's disconnected (user stops the process). + var client = await RazorLanguageServiceClientFactory.CreateAsync(_workspace, cancellationToken); + if (client != null) + { + using (var session = await client.CreateSessionAsync(project.Solution)) + { + if (session != null) + { + var jsonObject = await session.InvokeAsync( + "GetTagHelpersAsync", + new object[] { project.Id.Id, "Foo", }, + cancellationToken).ConfigureAwait(false); + + result = GetTagHelperResolutionResult(jsonObject); + } + } + } + + if (result == null) + { + // Was unable to get tag helpers OOP, fallback to default behavior. + result = await _defaultResolver.GetTagHelpersAsync(project, cancellationToken); + } + + return result; + } + catch (Exception exception) + { + throw new InvalidOperationException( + Resources.FormatUnexpectedException( + typeof(DefaultTagHelperResolver).FullName, + nameof(GetTagHelpersAsync)), + exception); + } + } + + private TagHelperResolutionResult GetTagHelperResolutionResult(JObject jsonObject) + { + var serializer = new JsonSerializer(); + serializer.Converters.Add(TagHelperDescriptorJsonConverter.Instance); + serializer.Converters.Add(RazorDiagnosticJsonConverter.Instance); + + using (var reader = jsonObject.CreateReader()) + { + return serializer.Deserialize(reader); + } + } + } +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/OOPTagHelperResolverFactory.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/OOPTagHelperResolverFactory.cs new file mode 100644 index 0000000000..d3265f7778 --- /dev/null +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/OOPTagHelperResolverFactory.cs @@ -0,0 +1,21 @@ +// 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.Composition; +using Microsoft.CodeAnalysis.Host; +using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.CodeAnalysis.Razor; + +namespace Microsoft.VisualStudio.LanguageServices.Razor +{ + [Shared] + [ExportLanguageServiceFactory(typeof(TagHelperResolver), RazorLanguage.Name, ServiceLayer.Host)] + internal class OOPTagHelperResolverFactory : ILanguageServiceFactory + { + public ILanguageService CreateLanguageService(HostLanguageServices languageServices) + { + var workspace = languageServices.WorkspaceServices.Workspace; + return new OOPTagHelperResolver(workspace); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/RazorDiagnosticJsonConverter.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/RazorDiagnosticJsonConverter.cs index d9d4d966e1..85d0a4096b 100644 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/RazorDiagnosticJsonConverter.cs +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/RazorDiagnosticJsonConverter.cs @@ -3,7 +3,6 @@ using System; using Microsoft.AspNetCore.Razor.Language; -using Microsoft.AspNetCore.Razor.Language.Legacy; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -13,7 +12,6 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor { public static readonly RazorDiagnosticJsonConverter Instance = new RazorDiagnosticJsonConverter(); private const string RazorDiagnosticMessageKey = "Message"; - private const string RazorDiagnosticTypeNameKey = "TypeName"; public override bool CanConvert(Type objectType) { @@ -35,26 +33,13 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor var length = span[nameof(SourceSpan.Length)].Value(); var filePath = span[nameof(SourceSpan.FilePath)].Value(); var message = diagnostic[RazorDiagnosticMessageKey].Value(); - var typeName = diagnostic[RazorDiagnosticTypeNameKey].Value(); + var id = diagnostic[nameof(RazorDiagnostic.Id)].Value(); + var severity = diagnostic[nameof(RazorDiagnostic.Severity)].Value(); - if (string.Equals(typeName, typeof(DefaultRazorDiagnostic).FullName, StringComparison.Ordinal)) - { - var id = diagnostic[nameof(RazorDiagnostic.Id)].Value(); - var severity = diagnostic[nameof(RazorDiagnostic.Severity)].Value(); + var descriptor = new RazorDiagnosticDescriptor(id, () => message, (RazorDiagnosticSeverity)severity); + var sourceSpan = new SourceSpan(filePath, absoluteIndex, lineIndex, characterIndex, length); - var descriptor = new RazorDiagnosticDescriptor(id, () => message, (RazorDiagnosticSeverity)severity); - var sourceSpan = new SourceSpan(filePath, absoluteIndex, lineIndex, characterIndex, length); - - return RazorDiagnostic.Create(descriptor, sourceSpan); - } - else if (string.Equals(typeName, typeof(LegacyRazorDiagnostic).FullName, StringComparison.Ordinal)) - { - var error = new RazorError(message, absoluteIndex, lineIndex, characterIndex, length); - - return RazorDiagnostic.Create(error); - } - - return null; + return RazorDiagnostic.Create(descriptor, sourceSpan); } public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) @@ -65,7 +50,6 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor WriteProperty(writer, nameof(RazorDiagnostic.Id), diagnostic.Id); WriteProperty(writer, nameof(RazorDiagnostic.Severity), (int)diagnostic.Severity); WriteProperty(writer, RazorDiagnosticMessageKey, diagnostic.GetMessage()); - WriteProperty(writer, RazorDiagnosticTypeNameKey, diagnostic.GetType().FullName); writer.WritePropertyName(nameof(RazorDiagnostic.Span)); serializer.Serialize(writer, diagnostic.Span); @@ -79,4 +63,4 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor writer.WriteValue(value); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/TextBufferProjectService.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/TextBufferProjectService.cs deleted file mode 100644 index 902b8b4a68..0000000000 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/TextBufferProjectService.cs +++ /dev/null @@ -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.VisualStudio.Shell.Interop; -using Microsoft.VisualStudio.Text; - -namespace Microsoft.VisualStudio.LanguageServices.Razor -{ - internal abstract class TextBufferProjectService - { - public abstract IVsHierarchy GetHierarchy(ITextBuffer textBuffer); - - public abstract bool IsSupportedProject(IVsHierarchy hierarchy); - } -} diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioForegroundDispatcher.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioForegroundDispatcher.cs index e0f8400e27..6b80023b68 100644 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioForegroundDispatcher.cs +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioForegroundDispatcher.cs @@ -1,16 +1,15 @@ // 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.Composition; +using System.ComponentModel.Composition; using System.Threading.Tasks; -using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Razor; using Microsoft.VisualStudio.Shell; namespace Microsoft.VisualStudio.LanguageServices.Razor { - [Shared] - [ExportWorkspaceService(typeof(ForegroundDispatcher), ServiceLayer.Host)] + [System.Composition.Shared] + [Export(typeof(ForegroundDispatcher))] internal class VisualStudioForegroundDispatcher : ForegroundDispatcher { public override TaskScheduler BackgroundScheduler { get; } = TaskScheduler.Default; diff --git a/src/RazorPageGenerator/Program.cs b/src/RazorPageGenerator/Program.cs index dd41d007c5..1aae7c86ef 100644 --- a/src/RazorPageGenerator/Program.cs +++ b/src/RazorPageGenerator/Program.cs @@ -31,8 +31,8 @@ Examples: var rootNamespace = args[0]; var targetProjectDirectory = args.Length > 1 ? args[1] : Directory.GetCurrentDirectory(); - var razorEngine = CreateRazorEngine(rootNamespace); - var results = MainCore(razorEngine, targetProjectDirectory); + var projectEngine = CreateProjectEngine(rootNamespace, targetProjectDirectory); + var results = MainCore(projectEngine, targetProjectDirectory); foreach (var result in results) { @@ -45,9 +45,10 @@ Examples: return 0; } - public static RazorEngine CreateRazorEngine(string rootNamespace, Action configure = null) + public static RazorProjectEngine CreateProjectEngine(string rootNamespace, string targetProjectDirectory, Action configure = null) { - var razorEngine = RazorEngine.Create(builder => + var fileSystem = RazorProjectFileSystem.Create(targetProjectDirectory); + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, fileSystem, builder => { builder .SetNamespace(rootNamespace) @@ -60,24 +61,21 @@ Examples: }); builder.Features.Add(new SuppressChecksumOptionsFeature()); + builder.Features.Add(new SuppressMetadataAttributesFeature()); + if (configure != null) { configure(builder); } + + builder.AddDefaultImports(DefaultImportItem.Instance); }); - return razorEngine; + return projectEngine; } - public static IList MainCore(RazorEngine razorEngine, string targetProjectDirectory) + public static IList MainCore(RazorProjectEngine projectEngine, string targetProjectDirectory) { var viewDirectories = Directory.EnumerateDirectories(targetProjectDirectory, "Views", SearchOption.AllDirectories); - var razorProject = RazorProject.Create(targetProjectDirectory); - var templateEngine = new RazorTemplateEngine(razorEngine, razorProject); - templateEngine.Options.DefaultImports = RazorSourceDocument.Create(@" -@using System -@using System.Threading.Tasks -", fileName: null); - var fileCount = 0; var results = new List(); @@ -86,7 +84,7 @@ Examples: Console.WriteLine(); Console.WriteLine(" Generating code files for views in {0}", viewDir); var viewDirPath = viewDir.Substring(targetProjectDirectory.Length).Replace('\\', '/'); - var cshtmlFiles = razorProject.EnumerateItems(viewDirPath); + var cshtmlFiles = projectEngine.FileSystem.EnumerateItems(viewDirPath); if (!cshtmlFiles.Any()) { @@ -97,7 +95,7 @@ Examples: foreach (var item in cshtmlFiles) { Console.WriteLine(" Generating code file for view {0}...", item.FileName); - results.Add(GenerateCodeFile(templateEngine, item)); + results.Add(GenerateCodeFile(projectEngine, item)); Console.WriteLine(" Done!"); fileCount++; } @@ -106,10 +104,11 @@ Examples: return results; } - private static RazorPageGeneratorResult GenerateCodeFile(RazorTemplateEngine templateEngine, RazorProjectItem projectItem) + private static RazorPageGeneratorResult GenerateCodeFile(RazorProjectEngine projectEngine, RazorProjectItem projectItem) { var projectItemWrapper = new FileSystemRazorProjectItemWrapper(projectItem); - var cSharpDocument = templateEngine.GenerateCode(projectItemWrapper); + var codeDocument = projectEngine.Process(projectItemWrapper); + var cSharpDocument = codeDocument.GetCSharpDocument(); if (cSharpDocument.Diagnostics.Any()) { var diagnostics = string.Join(Environment.NewLine, cSharpDocument.Diagnostics); @@ -139,6 +138,52 @@ Examples: } } + private class SuppressMetadataAttributesFeature : RazorEngineFeatureBase, IConfigureRazorCodeGenerationOptionsFeature + { + public int Order { get; set; } + + public void Configure(RazorCodeGenerationOptionsBuilder options) + { + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + options.SuppressMetadataAttributes = true; + } + } + + private class DefaultImportItem : RazorProjectItem + { + private readonly byte[] _defaultImportBytes; + + private DefaultImportItem() + { + var preamble = Encoding.UTF8.GetPreamble(); + var content = @" +@using System +@using System.Threading.Tasks +"; + var contentBytes = Encoding.UTF8.GetBytes(content); + + _defaultImportBytes = new byte[preamble.Length + contentBytes.Length]; + preamble.CopyTo(_defaultImportBytes, 0); + contentBytes.CopyTo(_defaultImportBytes, preamble.Length); + } + + public override string BasePath => null; + + public override string FilePath => null; + + public override string PhysicalPath => null; + + public override bool Exists => true; + + public static DefaultImportItem Instance { get; } = new DefaultImportItem(); + + public override Stream Read() => new MemoryStream(_defaultImportBytes); + } + private class FileSystemRazorProjectItemWrapper : RazorProjectItem { private readonly RazorProjectItem _source; diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/AssemblyAttributeInjectionPassTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/AssemblyAttributeInjectionPassTest.cs index 36e9adae36..a507103fb7 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/AssemblyAttributeInjectionPassTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/AssemblyAttributeInjectionPassTest.cs @@ -13,7 +13,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void Execute_NoOps_IfNamespaceNodeIsMissing() { // Arrange - var irDocument = new DocumentIntermediateNode(); + var irDocument = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var pass = new AssemblyAttributeInjectionPass { Engine = RazorEngine.Create(), @@ -30,7 +34,10 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void Execute_NoOps_IfNamespaceNodeHasEmptyContent() { // Arrange - var irDocument = new DocumentIntermediateNode(); + var irDocument = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; var builder = IntermediateNodeBuilder.Create(irDocument); var @namespace = new NamespaceDeclarationIntermediateNode() { Content = string.Empty }; @namespace.Annotations[CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace; @@ -53,7 +60,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void Execute_NoOps_IfClassNameNodeIsMissing() { // Arrange - var irDocument = new DocumentIntermediateNode(); + var irDocument = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(irDocument); var @namespace = new NamespaceDeclarationIntermediateNode() { Content = "SomeNamespace" }; builder.Push(@namespace); @@ -67,7 +78,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions pass.Execute(TestRazorCodeDocument.CreateEmpty(), irDocument); // Assert - Assert.Collection(irDocument.Children, + Assert.Collection( + irDocument.Children, node => Assert.Same(@namespace, node)); } @@ -75,7 +87,10 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void Execute_NoOps_IfClassNameIsEmpty() { // Arrange - var irDocument = new DocumentIntermediateNode(); + var irDocument = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; var builder = IntermediateNodeBuilder.Create(irDocument); var @namespace = new NamespaceDeclarationIntermediateNode { @@ -115,6 +130,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions var irDocument = new DocumentIntermediateNode { DocumentKind = "Default", + Options = RazorCodeGenerationOptions.CreateDefault(), }; var builder = IntermediateNodeBuilder.Create(irDocument); var @namespace = new NamespaceDeclarationIntermediateNode() { Content = "SomeNamespace" }; @@ -138,18 +154,19 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions pass.Execute(TestRazorCodeDocument.CreateEmpty(), irDocument); // Assert - Assert.Collection(irDocument.Children, + Assert.Collection( + irDocument.Children, node => Assert.Same(@namespace, node)); } [Fact] - public void Execute_AddsRazorViewAttribute_ToViews() + public void Execute_NoOps_ForDesignTime() { // Arrange - var expectedAttribute = "[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@\"/Views/Index.cshtml\", typeof(SomeNamespace.SomeName))]"; var irDocument = new DocumentIntermediateNode { DocumentKind = MvcViewDocumentClassifierPass.MvcViewDocumentKind, + Options = RazorCodeGenerationOptions.CreateDesignTimeDefault(), }; var builder = IntermediateNodeBuilder.Create(irDocument); var @namespace = new NamespaceDeclarationIntermediateNode @@ -175,8 +192,56 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions { Engine = RazorEngine.Create(), }; - var document = TestRazorCodeDocument.CreateEmpty(); - document.SetRelativePath("/Views/Index.cshtml"); + + var source = TestRazorSourceDocument.Create("test", new RazorSourceDocumentProperties(filePath: null, relativePath: "/Views/Index.cshtml")); + var document = RazorCodeDocument.Create(source); + + // Act + pass.Execute(document, irDocument); + + // Assert + Assert.Collection( + irDocument.Children, + node => Assert.Same(@namespace, node)); + } + + [Fact] + public void Execute_AddsRazorViewAttribute_ToViews() + { + // Arrange + var expectedAttribute = "[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@\"/Views/Index.cshtml\", typeof(SomeNamespace.SomeName))]"; + var irDocument = new DocumentIntermediateNode + { + DocumentKind = MvcViewDocumentClassifierPass.MvcViewDocumentKind, + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(irDocument); + var @namespace = new NamespaceDeclarationIntermediateNode + { + Content = "SomeNamespace", + Annotations = + { + [CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace + }, + }; + builder.Push(@namespace); + var @class = new ClassDeclarationIntermediateNode + { + ClassName = "SomeName", + Annotations = + { + [CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass, + }, + }; + builder.Add(@class); + + var pass = new AssemblyAttributeInjectionPass + { + Engine = RazorEngine.Create(), + }; + + var source = TestRazorSourceDocument.Create("test", new RazorSourceDocumentProperties(filePath: null, relativePath: "/Views/Index.cshtml")); + var document = RazorCodeDocument.Create(source); // Act pass.Execute(document, irDocument); @@ -197,10 +262,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void Execute_EscapesViewPathWhenAddingAttributeToViews() { // Arrange - var expectedAttribute = "[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@\"\\test\\\"\"Index.cshtml\", typeof(SomeNamespace.SomeName))]"; + var expectedAttribute = "[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@\"/test/\"\"Index.cshtml\", typeof(SomeNamespace.SomeName))]"; var irDocument = new DocumentIntermediateNode { DocumentKind = MvcViewDocumentClassifierPass.MvcViewDocumentKind, + Options = RazorCodeGenerationOptions.CreateDefault(), }; var builder = IntermediateNodeBuilder.Create(irDocument); var @namespace = new NamespaceDeclarationIntermediateNode @@ -226,8 +292,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions { Engine = RazorEngine.Create(), }; - var document = TestRazorCodeDocument.CreateEmpty(); - document.SetRelativePath("\\test\\\"Index.cshtml"); + + var source = TestRazorSourceDocument.Create("test", new RazorSourceDocumentProperties(filePath: null, relativePath: "\\test\\\"Index.cshtml")); + var document = RazorCodeDocument.Create(source); // Act pass.Execute(document, irDocument); @@ -252,6 +319,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions var irDocument = new DocumentIntermediateNode { DocumentKind = RazorPageDocumentClassifierPass.RazorPageDocumentKind, + Options = RazorCodeGenerationOptions.CreateDefault(), }; var builder = IntermediateNodeBuilder.Create(irDocument); var pageDirective = new DirectiveIntermediateNode @@ -283,8 +351,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions { Engine = RazorEngine.Create(), }; - var document = TestRazorCodeDocument.CreateEmpty(); - document.SetRelativePath("/Views/Index.cshtml"); + + var source = TestRazorSourceDocument.Create("test", new RazorSourceDocumentProperties(filePath: null, relativePath: "/Views/Index.cshtml")); + var document = RazorCodeDocument.Create(source); // Act pass.Execute(document, irDocument); @@ -306,10 +375,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void Execute_EscapesViewPathAndRouteWhenAddingAttributeToPage() { // Arrange - var expectedAttribute = "[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@\"\\test\\\"\"Index.cshtml\", typeof(SomeNamespace.SomeName))]"; + var expectedAttribute = "[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@\"/test/\"\"Index.cshtml\", typeof(SomeNamespace.SomeName))]"; var irDocument = new DocumentIntermediateNode { DocumentKind = MvcViewDocumentClassifierPass.MvcViewDocumentKind, + Options = RazorCodeGenerationOptions.CreateDefault(), }; var builder = IntermediateNodeBuilder.Create(irDocument); var @namespace = new NamespaceDeclarationIntermediateNode @@ -336,8 +406,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions { Engine = RazorEngine.Create(), }; - var document = TestRazorCodeDocument.CreateEmpty(); - document.SetRelativePath("\\test\\\"Index.cshtml"); + + var source = TestRazorSourceDocument.Create("test", new RazorSourceDocumentProperties(filePath: null, relativePath: "test\\\"Index.cshtml")); + var document = RazorCodeDocument.Create(source); // Act pass.Execute(document, irDocument); diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/InstrumentationPassTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/InstrumentationPassTest.cs index 0827042ac4..d59d1ad06b 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/InstrumentationPassTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/InstrumentationPassTest.cs @@ -10,11 +10,47 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions { public class InstrumentationPassTest { + [Fact] + public void InstrumentationPass_NoOps_ForDesignTime() + { + // Arrange + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDesignTimeDefault(), + }; + + var builder = IntermediateNodeBuilder.Create(document); + builder.Push(new HtmlContentIntermediateNode()); + builder.Add(new IntermediateToken() + { + Content = "Hi", + Kind = TokenKind.Html, + }); + builder.Pop(); + + var pass = new InstrumentationPass() + { + Engine = RazorEngine.CreateEmpty(b => { }), + }; + + // Act + pass.Execute(TestRazorCodeDocument.CreateEmpty(), document); + + // Assert + Children( + document, + n => IntermediateNodeAssert.Html("Hi", n)); + } + [Fact] public void InstrumentationPass_InstrumentsHtml() { // Arrange - var document = new DocumentIntermediateNode(); + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(document); builder.Push(new HtmlContentIntermediateNode() @@ -49,7 +85,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void InstrumentationPass_SkipsHtml_WithoutLocation() { // Arrange - var document = new DocumentIntermediateNode(); + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(document); builder.Push(new HtmlContentIntermediateNode()); builder.Add(new IntermediateToken() @@ -77,7 +117,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void InstrumentationPass_InstrumentsCSharpExpression() { // Arrange - var document = new DocumentIntermediateNode(); + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(document); builder.Push(new CSharpExpressionIntermediateNode() { @@ -109,7 +153,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void InstrumentationPass_SkipsCSharpExpression_WithoutLocation() { // Arrange - var document = new DocumentIntermediateNode(); + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(document); builder.Push(new CSharpExpressionIntermediateNode()); builder.Add(new IntermediateToken() @@ -136,7 +184,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void InstrumentationPass_SkipsCSharpExpression_InsideTagHelperAttribute() { // Arrange - var document = new DocumentIntermediateNode(); + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(document); builder.Push(new TagHelperIntermediateNode()); @@ -183,7 +235,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void InstrumentationPass_SkipsCSharpExpression_InsideTagHelperProperty() { // Arrange - var document = new DocumentIntermediateNode(); + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(document); builder.Push(new TagHelperIntermediateNode()); @@ -230,7 +286,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void InstrumentationPass_InstrumentsTagHelper() { // Arrange - var document = new DocumentIntermediateNode(); + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(document); builder.Add(new TagHelperIntermediateNode() { @@ -257,7 +317,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void InstrumentationPass_SkipsTagHelper_WithoutLocation() { // Arrange - var document = new DocumentIntermediateNode(); + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(document); builder.Push(new TagHelperIntermediateNode()); diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/ModelDirectiveTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/ModelDirectiveTest.cs index fcf8bc2422..f6466520af 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/ModelDirectiveTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/ModelDirectiveTest.cs @@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions "); var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: false) + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -88,7 +88,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions "); var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: false) + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -114,7 +114,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions "); var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: false) + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -139,7 +139,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions "); var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: false) + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -163,8 +163,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions @inherits BaseType "); - var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: true) + var engine = CreateDesignTimeEngine(); + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -193,8 +193,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions @model SomeType "); - var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: true) + var engine = CreateDesignTimeEngine(); + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -246,6 +246,18 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions }); } + private RazorEngine CreateDesignTimeEngine() + { + return RazorEngine.CreateDesignTime(b => + { + // Notice we're not registering the ModelDirective.Pass here so we can run it on demand. + b.AddDirective(ModelDirective.Directive); + + // There's some special interaction with the inherits directive + InheritsDirective.Register(b); + }); + } + private DocumentIntermediateNode CreateIRDocument(RazorEngine engine, RazorCodeDocument codeDocument) { for (var i = 0; i < engine.Phases.Count; i++) diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/MvcImportProjectFeatureTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/MvcImportProjectFeatureTest.cs new file mode 100644 index 0000000000..7e811ee261 --- /dev/null +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/MvcImportProjectFeatureTest.cs @@ -0,0 +1,76 @@ +// 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 Microsoft.AspNetCore.Razor.Language; +using Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions +{ + public class MvcImportProjectFeatureTest + { + [Fact] + public void AddDefaultDirectivesImport_AddsSingleDynamicImport() + { + // Arrange + var imports = new List(); + + // Act + MvcImportProjectFeature.AddDefaultDirectivesImport(imports); + + // Assert + var import = Assert.Single(imports); + Assert.Null(import.FilePath); + } + + [Fact] + public void AddHierarchicalImports_AddsViewImportSourceDocumentsOnDisk() + { + // Arrange + var imports = new List(); + var projectItem = new TestRazorProjectItem("/Contact/Index.cshtml"); + var testFileSystem = new TestRazorProjectFileSystem(new[] + { + new TestRazorProjectItem("/Index.cshtml"), + new TestRazorProjectItem("/_ViewImports.cshtml"), + new TestRazorProjectItem("/Contact/_ViewImports.cshtml"), + projectItem, + }); + var mvcImportFeature = new MvcImportProjectFeature() + { + ProjectEngine = Mock.Of(projectEngine => projectEngine.FileSystem == testFileSystem) + }; + + // Act + mvcImportFeature.AddHierarchicalImports(projectItem, imports); + + // Assert + Assert.Collection(imports, + import => Assert.Equal("/_ViewImports.cshtml", import.FilePath), + import => Assert.Equal("/Contact/_ViewImports.cshtml", import.FilePath)); + } + + [Fact] + public void AddHierarchicalImports_AddsViewImportSourceDocumentsNotOnDisk() + { + // Arrange + var imports = new List(); + var projectItem = new TestRazorProjectItem("/Pages/Contact/Index.cshtml"); + var testFileSystem = new TestRazorProjectFileSystem(new[] { projectItem }); + var mvcImportFeature = new MvcImportProjectFeature() + { + ProjectEngine = Mock.Of(projectEngine => projectEngine.FileSystem == testFileSystem) + }; + + // Act + mvcImportFeature.AddHierarchicalImports(projectItem, imports); + + // Assert + Assert.Collection(imports, + import => Assert.Equal("/_ViewImports.cshtml", import.FilePath), + import => Assert.Equal("/Pages/_ViewImports.cshtml", import.FilePath), + import => Assert.Equal("/Pages/Contact/_ViewImports.cshtml", import.FilePath)); + } + } +} diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/MvcRazorTemplateEngineTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/MvcRazorTemplateEngineTest.cs index 753ed80f00..58e440547e 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/MvcRazorTemplateEngineTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/MvcRazorTemplateEngineTest.cs @@ -2,10 +2,8 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using System.Linq; using Microsoft.AspNetCore.Razor.Language; -using Moq; using Xunit; namespace Microsoft.AspNetCore.Mvc.Razor.Extensions @@ -28,7 +26,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions }; var mvcRazorTemplateEngine = new MvcRazorTemplateEngine( RazorEngine.Create(), - new TestRazorProject()); + new TestRazorProjectFileSystem()); // Act var imports = mvcRazorTemplateEngine.Options.DefaultImports; @@ -54,7 +52,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions }; var mvcRazorTemplateEngine = new MvcRazorTemplateEngine( RazorEngine.Create(), - new TestRazorProject()); + new TestRazorProjectFileSystem()); // Act var imports = mvcRazorTemplateEngine.Options.DefaultImports; @@ -72,7 +70,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions // Arrange var mvcRazorTemplateEngine = new MvcRazorTemplateEngine( RazorEngine.Create(), - new TestRazorProject()); + new TestRazorProjectFileSystem()); // Act var imports = mvcRazorTemplateEngine.Options.DefaultImports; @@ -86,28 +84,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions Assert.Contains("@addTagHelper Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor", importContent); } - [Fact] - public void CreateCodeDocument_SetsRelativePathOnOutput() - { - // Arrange - var path = "/Views/Home/Index.cshtml"; - var item = new TestRazorProjectItem(path) - { - Content = "Hello world", - }; - var project = new TestRazorProject(new List() { item, }); - - var mvcRazorTemplateEngine = new MvcRazorTemplateEngine( - RazorEngine.Create(), - project); - - // Act - var codeDocument = mvcRazorTemplateEngine.CreateCodeDocument(path); - - // Assert - Assert.Equal(path, codeDocument.GetRelativePath()); - } - private string GetContent(RazorSourceDocument imports) { var contentChars = new char[imports.Length]; diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/MvcViewDocumentClassifierPassTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/MvcViewDocumentClassifierPassTest.cs index fbedc6f67f..f5d775f677 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/MvcViewDocumentClassifierPassTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/MvcViewDocumentClassifierPassTest.cs @@ -1,7 +1,6 @@ // 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.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Intermediate; using Xunit; @@ -14,7 +13,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void MvcViewDocumentClassifierPass_SetsDocumentKind() { // Arrange - var codeDocument = CreateDocument("some-content"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", "Test.cshtml")); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new MvcViewDocumentClassifierPass @@ -33,7 +33,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void MvcViewDocumentClassifierPass_NoOpsIfDocumentKindIsAlreadySet() { // Arrange - var codeDocument = CreateDocument("some-content"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", "Test.cshtml")); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); irDocument.DocumentKind = "some-value"; @@ -53,7 +54,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void MvcViewDocumentClassifierPass_SetsNamespace() { // Arrange - var codeDocument = CreateDocument("some-content"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", "Test.cshtml")); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new MvcViewDocumentClassifierPass @@ -74,14 +76,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void MvcViewDocumentClassifierPass_SetsClass() { // Arrange - var codeDocument = CreateDocument("some-content"); + var properties = new RazorSourceDocumentProperties(filePath: "ignored", relativePath: "Test.cshtml"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", properties)); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new MvcViewDocumentClassifierPass { Engine = engine }; - codeDocument.SetRelativePath("Test.cshtml"); // Act pass.Execute(codeDocument, irDocument); @@ -91,17 +94,18 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions // Assert Assert.Equal("global::Microsoft.AspNetCore.Mvc.Razor.RazorPage", visitor.Class.BaseType); Assert.Equal(new[] { "public" }, visitor.Class.Modifiers); - Assert.Equal("Test_cshtml", visitor.Class.ClassName); + Assert.Equal("Test", visitor.Class.ClassName); } [Theory] - [InlineData("/Views/Home/Index.cshtml", "_Views_Home_Index_cshtml")] - [InlineData("/Areas/MyArea/Views/Home/About.cshtml", "_Areas_MyArea_Views_Home_About_cshtml")] + [InlineData("/Views/Home/Index.cshtml", "_Views_Home_Index")] + [InlineData("/Areas/MyArea/Views/Home/About.cshtml", "_Areas_MyArea_Views_Home_About")] public void MvcViewDocumentClassifierPass_UsesRelativePathToGenerateTypeName(string relativePath, string expected) { // Arrange - var codeDocument = CreateDocument("some-content"); - codeDocument.SetRelativePath(relativePath); + var properties = new RazorSourceDocumentProperties(filePath: "ignored", relativePath: relativePath); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", properties)); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new MvcViewDocumentClassifierPass @@ -122,9 +126,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void MvcViewDocumentClassifierPass_UsesAbsolutePath_IfRelativePathIsNotSet() { // Arrange - var expected = "x___application_Views_Home_Index_cshtml"; - var path = @"x::\application\Views\Home\Index.cshtml"; - var codeDocument = CreateDocument("some-content", path); + var properties = new RazorSourceDocumentProperties(filePath: @"x::\application\Views\Home\Index.cshtml", relativePath: null); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", properties)); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new MvcViewDocumentClassifierPass @@ -138,16 +142,16 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions visitor.Visit(irDocument); // Assert - Assert.Equal(expected, visitor.Class.ClassName); + Assert.Equal("x___application_Views_Home_Index", visitor.Class.ClassName); } [Fact] public void MvcViewDocumentClassifierPass_SanitizesClassName() { // Arrange - var expected = "path_with_invalid_chars"; - var codeDocument = CreateDocument("some-content"); - codeDocument.SetRelativePath("path.with+invalid-chars"); + var properties = new RazorSourceDocumentProperties(filePath: @"x:\Test.cshtml", relativePath: "path.with+invalid-chars"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", properties)); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new MvcViewDocumentClassifierPass @@ -161,14 +165,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions visitor.Visit(irDocument); // Assert - Assert.Equal(expected, visitor.Class.ClassName); + Assert.Equal("path_with_invalid_chars", visitor.Class.ClassName); } [Fact] public void MvcViewDocumentClassifierPass_SetsUpExecuteAsyncMethod() { // Arrange - var codeDocument = CreateDocument("some-content"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", "Test.cshtml")); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new MvcViewDocumentClassifierPass @@ -187,14 +192,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions Assert.Equal(new[] { "public", "async", "override" }, visitor.Method.Modifiers); } - private static RazorCodeDocument CreateDocument(string content, string filePath = null) - { - filePath = filePath ?? Path.Combine(Directory.GetCurrentDirectory(), "Test.cshtml"); - - var source = RazorSourceDocument.Create(content, filePath); - return RazorCodeDocument.Create(source); - } - private static RazorEngine CreateEngine() => RazorEngine.Create(); private static DocumentIntermediateNode CreateIRDocument(RazorEngine engine, RazorCodeDocument codeDocument) diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/NamespaceDirectiveTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/NamespaceDirectiveTest.cs index fa806d0dc0..54f0feef51 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/NamespaceDirectiveTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/NamespaceDirectiveTest.cs @@ -10,7 +10,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public class NamespaceDirectiveTest { [Fact] - public void TryComputeNamespace_IncompleteDirective_UsesEmptyNamespace() + public void GetNamespace_IncompleteDirective_UsesEmptyNamespace() { // Arrange var source = "c:\\foo\\bar\\bleh.cshtml"; @@ -22,15 +22,14 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions }; // Act - var computed = NamespaceDirective.TryComputeNamespace(source, node, out var @namespace); + var @namespace = NamespaceDirective.GetNamespace(source, node); // Assert - Assert.False(computed); Assert.Equal(string.Empty, @namespace); } [Fact] - public void TryComputeNamespace_EmptyDirective_UsesEmptyNamespace() + public void GetNamespace_EmptyDirective_UsesEmptyNamespace() { // Arrange var source = "c:\\foo\\bar\\bleh.cshtml"; @@ -43,10 +42,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions node.Children.Add(new DirectiveTokenIntermediateNode() { Content = string.Empty }); // Act - var computed = NamespaceDirective.TryComputeNamespace(source, node, out var @namespace); + var @namespace = NamespaceDirective.GetNamespace(source, node); // Assert - Assert.False(computed); Assert.Equal(string.Empty, @namespace); } @@ -60,7 +58,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions [InlineData("/foo.cshtml", "/foo/bar.cshtml")] [InlineData("c:\\foo.cshtml", "d:\\foo\\bar.cshtml")] [InlineData("c:\\foo\\bar\\bleh.cshtml", "c:\\foo\\baz\\bleh.cshtml")] - public void TryComputeNamespace_ForNonRelatedFiles_UsesNamespaceVerbatim(string source, string imports) + public void GetNamespace_ForNonRelatedFiles_UsesNamespaceVerbatim(string source, string imports) { // Arrange var node = new DirectiveIntermediateNode() @@ -72,10 +70,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions node.Children.Add(new DirectiveTokenIntermediateNode() { Content = "Base" }); // Act - var computed = NamespaceDirective.TryComputeNamespace(source, node, out var @namespace); + var @namespace = NamespaceDirective.GetNamespace(source, node); // Assert - Assert.False(computed); Assert.Equal("Base", @namespace); } @@ -90,7 +87,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions [InlineData("c:\\foo\\bar\\baz.cshtml", "c:\\_ViewImports.cshtml", "Base.foo.bar")] [InlineData("c:\\foo\\bar\\baz.cshtml", "c:\\foo\\_ViewImports.cshtml", "Base.bar")] [InlineData("c:\\Foo\\bar\\baz.cshtml", "c:\\foo\\_ViewImports.cshtml", "Base.bar")] - public void TryComputeNamespace_ForRelatedFiles_ComputesNamespaceWithSuffix(string source, string imports, string expected) + public void GetNamespace_ForRelatedFiles_ComputesNamespaceWithSuffix(string source, string imports, string expected) { // Arrange var node = new DirectiveIntermediateNode() @@ -102,16 +99,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions node.Children.Add(new DirectiveTokenIntermediateNode() { Content = "Base" }); // Act - var computed = NamespaceDirective.TryComputeNamespace(source, node, out var @namespace); + var @namespace = NamespaceDirective.GetNamespace(source, node); // Assert - Assert.True(computed); Assert.Equal(expected, @namespace); } // This is the case where a _ViewImports sets the namespace. [Fact] - public void Pass_SetsNamespaceAndClassName_ComputedFromImports() + public void Pass_SetsNamespace_ComputedFromImports() { // Arrange var document = new DocumentIntermediateNode(); @@ -143,12 +139,12 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions // Assert Assert.Equal("WebApplication.Account.Manage", @namespace.Content); - Assert.Equal("AddUser_Page", @class.ClassName); + Assert.Equal("default", @class.ClassName); } // This is the case where the source file sets the namespace. [Fact] - public void Pass_SetsNamespaceAndClassName_ComputedFromSource() + public void Pass_SetsNamespace_ComputedFromSource() { // Arrange var document = new DocumentIntermediateNode(); @@ -190,13 +186,13 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions // Assert Assert.Equal("WebApplication.Account.Manage", @namespace.Content); - Assert.Equal("AddUser_Page", @class.ClassName); + Assert.Equal("default", @class.ClassName); } // Handles cases where invalid characters appears in FileNames. Note that we don't sanitize the part of // the namespace that you put in an import, just the file-based-suffix. Garbage in, garbage out. [Fact] - public void Pass_SetsNamespaceAndClassName_SanitizesClassAndNamespace() + public void Pass_SetsNamespace_SanitizesClassAndNamespace() { // Arrange var document = new DocumentIntermediateNode(); @@ -228,12 +224,12 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions // Assert Assert.Equal("WebApplication.Account.Manage_Info", @namespace.Content); - Assert.Equal("Add_User_Page", @class.ClassName); + Assert.Equal("default", @class.ClassName); } // This is the case where the source file sets the namespace. [Fact] - public void Pass_SetsNamespaceAndClassName_ComputedFromSource_ForView() + public void Pass_SetsNamespace_ComputedFromSource_ForView() { // Arrange var document = new DocumentIntermediateNode(); @@ -275,13 +271,13 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions // Assert Assert.Equal("WebApplication.Account.Manage", @namespace.Content); - Assert.Equal("AddUser_View", @class.ClassName); + Assert.Equal("default", @class.ClassName); } // This handles an error case where we can't determine the relationship between the // imports and the source. [Fact] - public void Pass_SetsNamespaceButNotClassName_VerbatimFromImports() + public void Pass_SetsNamespace_VerbatimFromImports() { // Arrange var document = new DocumentIntermediateNode(); diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/RazorPageDocumentClassifierPassTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/RazorPageDocumentClassifierPassTest.cs index bd7ecb95dd..6a21674f2e 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/RazorPageDocumentClassifierPassTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/RazorPageDocumentClassifierPassTest.cs @@ -1,7 +1,6 @@ // 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.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Intermediate; using Xunit; @@ -40,7 +39,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void RazorPageDocumentClassifierPass_SetsDocumentKind() { // Arrange - var codeDocument = CreateDocument("@page"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", "Test.cshtml")); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new RazorPageDocumentClassifierPass @@ -59,7 +59,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void RazorPageDocumentClassifierPass_NoOpsIfDocumentKindIsAlreadySet() { // Arrange - var codeDocument = CreateDocument("@page"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", "Test.cshtml")); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); irDocument.DocumentKind = "some-value"; @@ -79,7 +80,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void RazorPageDocumentClassifierPass_NoOpsIfPageDirectiveIsMalformed() { // Arrange - var codeDocument = CreateDocument("@page+1"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page+1", "Test.cshtml")); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); irDocument.DocumentKind = "some-value"; @@ -99,7 +101,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void RazorPageDocumentClassifierPass_SetsNamespace() { // Arrange - var codeDocument = CreateDocument("@page"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", "Test.cshtml")); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new RazorPageDocumentClassifierPass @@ -120,14 +123,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void RazorPageDocumentClassifierPass_SetsClass() { // Arrange - var codeDocument = CreateDocument("@page"); + var properties = new RazorSourceDocumentProperties(filePath: "ignored", relativePath: "Test.cshtml"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", properties)); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new RazorPageDocumentClassifierPass { Engine = engine }; - codeDocument.SetRelativePath("Test.cshtml"); // Act pass.Execute(codeDocument, irDocument); @@ -137,17 +141,18 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions // Assert Assert.Equal("global::Microsoft.AspNetCore.Mvc.RazorPages.Page", visitor.Class.BaseType); Assert.Equal(new[] { "public" }, visitor.Class.Modifiers); - Assert.Equal("Test_cshtml", visitor.Class.ClassName); + Assert.Equal("Test", visitor.Class.ClassName); } [Theory] - [InlineData("/Views/Home/Index.cshtml", "_Views_Home_Index_cshtml")] - [InlineData("/Areas/MyArea/Views/Home/About.cshtml", "_Areas_MyArea_Views_Home_About_cshtml")] + [InlineData("/Views/Home/Index.cshtml", "_Views_Home_Index")] + [InlineData("/Areas/MyArea/Views/Home/About.cshtml", "_Areas_MyArea_Views_Home_About")] public void RazorPageDocumentClassifierPass_UsesRelativePathToGenerateTypeName(string relativePath, string expected) { // Arrange - var codeDocument = CreateDocument("@page"); - codeDocument.SetRelativePath(relativePath); + var properties = new RazorSourceDocumentProperties(filePath: "ignored", relativePath: relativePath); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", properties)); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new RazorPageDocumentClassifierPass @@ -168,9 +173,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void RazorPageDocumentClassifierPass_UsesAbsolutePath_IfRelativePathIsNotSet() { // Arrange - var expected = "x___application_Views_Home_Index_cshtml"; - var path = @"x::\application\Views\Home\Index.cshtml"; - var codeDocument = CreateDocument("@page", path); + var properties = new RazorSourceDocumentProperties(filePath: @"x::\application\Views\Home\Index.cshtml", relativePath: null); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", properties)); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new RazorPageDocumentClassifierPass @@ -184,16 +189,16 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions visitor.Visit(irDocument); // Assert - Assert.Equal(expected, visitor.Class.ClassName); + Assert.Equal("x___application_Views_Home_Index", visitor.Class.ClassName); } [Fact] public void RazorPageDocumentClassifierPass_SanitizesClassName() { // Arrange - var expected = "path_with_invalid_chars"; - var codeDocument = CreateDocument("@page"); - codeDocument.SetRelativePath("path.with+invalid-chars"); + var properties = new RazorSourceDocumentProperties(filePath: @"x:\Test.cshtml", relativePath: "path.with+invalid-chars"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", properties)); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new RazorPageDocumentClassifierPass @@ -207,14 +212,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions visitor.Visit(irDocument); // Assert - Assert.Equal(expected, visitor.Class.ClassName); + Assert.Equal("path_with_invalid_chars", visitor.Class.ClassName); } [Fact] public void RazorPageDocumentClassifierPass_SetsUpExecuteAsyncMethod() { // Arrange - var codeDocument = CreateDocument("@page"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", "Test.cshtml")); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new RazorPageDocumentClassifierPass @@ -233,14 +239,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions Assert.Equal(new[] { "public", "async", "override" }, visitor.Method.Modifiers); } - private static RazorCodeDocument CreateDocument(string content, string filePath = null) - { - filePath = filePath ?? Path.Combine(Directory.GetCurrentDirectory(), "Test.cshtml"); - - var source = RazorSourceDocument.Create(content, filePath); - return RazorCodeDocument.Create(source); - } - private static RazorEngine CreateEngine() { return RazorEngine.Create(b => diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.codegen.cs index 3edf343f5e..d39b64c26d 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.ir.txt index b29d7ed8cd..4074239b9f 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.mappings.txt index e25ebcea7e..372b49cb6f 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.mappings.txt @@ -1,34 +1,34 @@ Source Location: (13:0,13 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml) |this.ToString()| -Generated Location: (1037:26,13 [15] ) +Generated Location: (1030:26,13 [15] ) |this.ToString()| Source Location: (54:2,5 [29] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml) |string.Format("{0}", "Hello")| -Generated Location: (1173:31,6 [29] ) +Generated Location: (1166:31,6 [29] ) |string.Format("{0}", "Hello")| Source Location: (95:4,2 [25] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml) | var cls = "foo"; | -Generated Location: (1319:36,2 [25] ) +Generated Location: (1312:36,2 [25] ) | var cls = "foo"; | Source Location: (134:7,11 [18] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml) |if(cls != null) { | -Generated Location: (1467:42,11 [18] ) +Generated Location: (1460:42,11 [18] ) |if(cls != null) { | Source Location: (153:7,30 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml) |cls| -Generated Location: (1629:47,30 [3] ) +Generated Location: (1622:47,30 [3] ) |cls| Source Location: (156:7,33 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml) | }| -Generated Location: (1780:52,33 [2] ) +Generated Location: (1773:52,33 [2] ) | }| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_Runtime.codegen.cs index 5a329752ee..bda5a6244e 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "4120ddad9d4353ed260e0585fe71080d78ff8ab3" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic_cshtml))] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic))] namespace AspNetCore { #line hidden @@ -12,7 +13,8 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"4120ddad9d4353ed260e0585fe71080d78ff8ab3", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_Runtime.ir.txt index c4bcd68fcd..9173f6251b 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic_cshtml))] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic))] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,7 +10,8 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync CSharpCode - IntermediateToken - - CSharp - BeginContext(0, 4, true); diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs index 3e79145caf..93b05b4ddd 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_cshtml : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives : global::Microsoft.AspNetCore.Mvc.RazorPages.Page { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { @@ -59,9 +59,9 @@ MyService __typeHelper = default(MyService); [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; } [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] - public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_cshtml Model => ViewData.Model; + public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives Model => ViewData.Model; } } #pragma warning restore 1591 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt index 2f95c8c58a..1cfef392ae 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt @@ -1,12 +1,12 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,1): Error RZ9999: The 'page' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,1): Error RZ9999: The 'page' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,7): Error RZ9999: The 'page' directive expects a string surrounded by double quotes. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,7): Error RZ9999: The 'model' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,1): Error RZ9999: The 'model' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,8): Error RZ9999: The 'model' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(10,8): Error RZ9999: The 'inject' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(11,9): Error RZ9999: The 'inject' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,26): Error RZ9999: The 'inject' directive expects an identifier. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(14,11): Error RZ9999: The 'namespace' directive expects a namespace name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,1): Error RZ9999: The 'namespace' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,12): Error RZ9999: The 'namespace' directive expects a namespace name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,1): Error RZ2001: The 'page' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,1): Error RZ2001: The 'page' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,7): Error RZ1016: The 'page' directive expects a string surrounded by double quotes. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,7): Error RZ1013: The 'model' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,1): Error RZ2001: The 'model' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,8): Error RZ1013: The 'model' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(10,8): Error RZ1013: The 'inject' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(11,9): Error RZ1013: The 'inject' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,26): Error RZ1015: The 'inject' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(14,11): Error RZ1014: The 'namespace' directive expects a namespace name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,1): Error RZ2001: The 'namespace' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,12): Error RZ1014: The 'namespace' directive expects a namespace name. diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt index e6cca7f462..2aeddc2fa2 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_cshtml - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html @@ -79,6 +79,6 @@ Document - Inject - Inject - CSharpCode - - IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; CSharpCode - - IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_cshtml Model => ViewData.Model; + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives Model => ViewData.Model; diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt index 77fa549e07..c13c9c3006 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt @@ -1,40 +1,40 @@ Source Location: (119:6,6 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) || -Generated Location: (678:18,0 [0] ) +Generated Location: (671:18,0 [0] ) || Source Location: (128:7,7 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) || -Generated Location: (731:21,0 [0] ) +Generated Location: (724:21,0 [0] ) || Source Location: (139:9,7 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) || -Generated Location: (784:24,0 [0] ) +Generated Location: (777:24,0 [0] ) || Source Location: (149:10,8 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) || -Generated Location: (837:27,0 [0] ) +Generated Location: (830:27,0 [0] ) || Source Location: (159:11,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) |MyService| -Generated Location: (890:30,0 [17] ) +Generated Location: (883:30,0 [17] ) |MyService| Source Location: (176:11,25 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) || -Generated Location: (1012:34,0 [0] ) +Generated Location: (1005:34,0 [0] ) || Source Location: (190:13,10 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) || -Generated Location: (1065:37,0 [0] ) +Generated Location: (1058:37,0 [0] ) || Source Location: (203:14,11 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) || -Generated Location: (1118:40,0 [0] ) +Generated Location: (1111:40,0 [0] ) || diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs index 7e8dc0ce87..908ae63c42 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "fec5cf763044f842fa2114e997bb07e0bf280cd6" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_cshtml), null)] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives), @"mvc.1.0.razor-page", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives), null)] namespace AspNetCore { #line hidden @@ -12,7 +13,8 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_cshtml : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"fec5cf763044f842fa2114e997bb07e0bf280cd6", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives : global::Microsoft.AspNetCore.Mvc.RazorPages.Page { #pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() @@ -55,9 +57,9 @@ namespace AspNetCore [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; } [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] - public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_cshtml Model => ViewData.Model; + public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives Model => ViewData.Model; } } #pragma warning restore 1591 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt index 2f95c8c58a..1cfef392ae 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt @@ -1,12 +1,12 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,1): Error RZ9999: The 'page' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,1): Error RZ9999: The 'page' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,7): Error RZ9999: The 'page' directive expects a string surrounded by double quotes. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,7): Error RZ9999: The 'model' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,1): Error RZ9999: The 'model' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,8): Error RZ9999: The 'model' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(10,8): Error RZ9999: The 'inject' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(11,9): Error RZ9999: The 'inject' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,26): Error RZ9999: The 'inject' directive expects an identifier. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(14,11): Error RZ9999: The 'namespace' directive expects a namespace name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,1): Error RZ9999: The 'namespace' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,12): Error RZ9999: The 'namespace' directive expects a namespace name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,1): Error RZ2001: The 'page' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,1): Error RZ2001: The 'page' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,7): Error RZ1016: The 'page' directive expects a string surrounded by double quotes. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,7): Error RZ1013: The 'model' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,1): Error RZ2001: The 'model' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,8): Error RZ1013: The 'model' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(10,8): Error RZ1013: The 'inject' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(11,9): Error RZ1013: The 'inject' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,26): Error RZ1015: The 'inject' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(14,11): Error RZ1014: The 'namespace' directive expects a namespace name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,1): Error RZ2001: The 'namespace' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,12): Error RZ1014: The 'namespace' directive expects a namespace name. diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt index cea68367fe..bd3bdd87e2 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_cshtml), null)] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives), null)] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,7 +10,8 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_cshtml - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync CSharpCode - IntermediateToken - - CSharp - BeginContext(83, 4, true); @@ -88,6 +90,6 @@ Document - Inject - Inject - CSharpCode - - IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; CSharpCode - - IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_cshtml Model => ViewData.Model; + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives Model => ViewData.Model; diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.codegen.cs index 0c96a6c7e0..6a16b10feb 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel_cshtml : MyBasePageForViews + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel : MyBasePageForViews { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.ir.txt index 73169535b3..3310acfa76 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel_cshtml - MyBasePageForViews - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel - MyBasePageForViews - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.mappings.txt index 4f38bd7343..9b7a5db61d 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.mappings.txt @@ -1,10 +1,10 @@ Source Location: (10:0,10 [26] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml) |MyBasePageForViews| -Generated Location: (654:18,0 [26] ) +Generated Location: (647:18,0 [26] ) |MyBasePageForViews| Source Location: (45:1,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml) |MyModel| -Generated Location: (794:22,0 [7] ) +Generated Location: (787:22,0 [7] ) |MyModel| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.codegen.cs index d8f59b684a..28a881a8ac 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "91cf923452a86b2906083cb0236d6d5b3bc528ef" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel_cshtml))] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel))] namespace AspNetCore { #line hidden @@ -12,7 +13,8 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel_cshtml : MyBasePageForViews + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"91cf923452a86b2906083cb0236d6d5b3bc528ef", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel : MyBasePageForViews { #pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.ir.txt index 4b994c2d50..2468ef4662 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel_cshtml))] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel))] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,7 +10,8 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel_cshtml - MyBasePageForViews - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel - MyBasePageForViews - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync Inject - Inject - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.codegen.cs index e3748d4f91..8d27d45236 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports_cshtml : MyPageModel + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports : MyPageModel { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.ir.txt index e6a7b3f4c0..a183f64bc5 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports_cshtml - MyPageModel - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports - MyPageModel - DesignTimeDirective - DirectiveToken - (10:0,10 [19] InheritsWithViewImports_Imports0.cshtml) - MyPageModel DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.mappings.txt index 4ae600111e..c120ec9937 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.mappings.txt @@ -1,5 +1,5 @@ Source Location: (14:1,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml) |MyModel| -Generated Location: (653:18,0 [7] ) +Generated Location: (646:18,0 [7] ) |MyModel| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.codegen.cs index 3684c48b5d..e9220f8dd9 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "052fe5ad02d36ebdf943dddd543cb26aaff62411" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports_cshtml), null)] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports), @"mvc.1.0.razor-page", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports), null)] namespace AspNetCore { #line hidden @@ -12,7 +13,9 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports_cshtml : MyPageModel + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"052fe5ad02d36ebdf943dddd543cb26aaff62411", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml")] + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"28770296d18b0505bb216c6143cc1ec6514adb7b", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Imports0.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports : MyPageModel { #pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.ir.txt index 548bb823f5..2704223a57 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports_cshtml), null)] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports), null)] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,7 +10,9 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports_cshtml - MyPageModel - + RazorSourceChecksumAttribute - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports - MyPageModel - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync Inject - Inject - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.codegen.cs index 10050cba80..e198bf38b2 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.ir.txt index 132fe4ed61..c1d70d5d89 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.mappings.txt index 64bb4804b3..0d58ddea20 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.mappings.txt @@ -1,25 +1,25 @@ Source Location: (7:0,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml) |MyModel| -Generated Location: (682:18,0 [7] ) +Generated Location: (675:18,0 [7] ) |MyModel| Source Location: (24:1,8 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml) |MyApp| -Generated Location: (784:22,0 [5] ) +Generated Location: (777:22,0 [5] ) |MyApp| Source Location: (30:1,14 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml) |MyPropertyName| -Generated Location: (904:26,22 [14] ) +Generated Location: (897:26,22 [14] ) |MyPropertyName| Source Location: (54:2,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml) |MyService| -Generated Location: (988:30,0 [17] ) +Generated Location: (981:30,0 [17] ) |MyService| Source Location: (72:2,26 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml) |Html| -Generated Location: (1132:34,22 [4] ) +Generated Location: (1125:34,22 [4] ) |Html| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.codegen.cs index 3201f448fd..94406cdd68 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "a039b7091118c718dc3023b6ac58d9645cb58e59" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel_cshtml))] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel))] namespace AspNetCore { #line hidden @@ -12,7 +13,8 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"a039b7091118c718dc3023b6ac58d9645cb58e59", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.ir.txt index edd53414fb..d018107ae2 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel_cshtml))] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel))] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,7 +10,8 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync Inject - Inject - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.codegen.cs index 2c3776aedd..7d588d5d12 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.ir.txt index f9bf4e3c8c..5c4540f366 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.mappings.txt index fb80df37b7..8e98145f2d 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.mappings.txt @@ -1,45 +1,45 @@ Source Location: (7:0,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |MyModel| -Generated Location: (686:18,0 [7] ) +Generated Location: (679:18,0 [7] ) |MyModel| Source Location: (24:1,8 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |MyApp| -Generated Location: (788:22,0 [5] ) +Generated Location: (781:22,0 [5] ) |MyApp| Source Location: (30:1,14 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |MyPropertyName| -Generated Location: (908:26,22 [14] ) +Generated Location: (901:26,22 [14] ) |MyPropertyName| Source Location: (58:2,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |MyService| -Generated Location: (992:30,0 [17] ) +Generated Location: (985:30,0 [17] ) |MyService| Source Location: (76:2,26 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |Html| -Generated Location: (1136:34,22 [4] ) +Generated Location: (1129:34,22 [4] ) |Html| Source Location: (93:3,8 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |MyApp| -Generated Location: (1210:38,0 [5] ) +Generated Location: (1203:38,0 [5] ) |MyApp| Source Location: (99:3,14 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |MyPropertyName2| -Generated Location: (1330:42,22 [15] ) +Generated Location: (1323:42,22 [15] ) |MyPropertyName2| Source Location: (129:4,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |MyService| -Generated Location: (1415:46,0 [17] ) +Generated Location: (1408:46,0 [17] ) |MyService| Source Location: (147:4,26 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |Html2| -Generated Location: (1559:50,22 [5] ) +Generated Location: (1552:50,22 [5] ) |Html2| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.codegen.cs index fd547570a8..816bd59508 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "5010aab35d235175dab517f8018e41aee9a2ac7f" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon_cshtml))] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon))] namespace AspNetCore { #line hidden @@ -12,7 +13,8 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"5010aab35d235175dab517f8018e41aee9a2ac7f", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.ir.txt index 6f1f2b25c2..898557c170 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon_cshtml))] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon))] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,7 +10,8 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync Inject - Inject - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.codegen.cs index b8e43e2f76..b6a4d2a93f 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.ir.txt index 73671c0430..0b8beeae9b 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.mappings.txt index ec01d63774..8bd4399f3f 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.mappings.txt @@ -1,10 +1,10 @@ Source Location: (8:0,8 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml) |MyApp| -Generated Location: (673:18,0 [5] ) +Generated Location: (666:18,0 [5] ) |MyApp| Source Location: (14:0,14 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml) |MyPropertyName| -Generated Location: (793:22,22 [14] ) +Generated Location: (786:22,22 [14] ) |MyPropertyName| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.codegen.cs index da4378a7d8..04f3cce3ae 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "c711078454f5b0e8d2cb77d9cb7fa88cca32b884" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject_cshtml))] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject))] namespace AspNetCore { #line hidden @@ -12,7 +13,8 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"c711078454f5b0e8d2cb77d9cb7fa88cca32b884", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.ir.txt index e51dcacfeb..e05f9d2df9 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject_cshtml))] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject))] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,7 +10,8 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync Inject - Inject - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.codegen.cs index d4bee96fbd..d99c176c52 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt index d076071130..90446dc58b 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml(1,12): Error RZ9999: The 'namespace' directive expects a namespace name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml(1,12): Error RZ1014: The 'namespace' directive expects a namespace name. diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.ir.txt index 5d1c4a4884..6f9220aab4 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.codegen.cs index b4c2cab291..c576cc0875 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "de132bd3e2a46a0d2ec953a168427c01e5829cde" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF_cshtml))] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF))] namespace AspNetCore { #line hidden @@ -12,7 +13,8 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"de132bd3e2a46a0d2ec953a168427c01e5829cde", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.diagnostics.txt index d076071130..90446dc58b 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml(1,12): Error RZ9999: The 'namespace' directive expects a namespace name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml(1,12): Error RZ1014: The 'namespace' directive expects a namespace name. diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.ir.txt index 33f1f5b60a..e99ab2d9c2 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF_cshtml))] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF))] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,7 +10,8 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync MalformedDirective - (0:0,0 [11] InvalidNamespaceAtEOF.cshtml) - namespace CSharpCode - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.codegen.cs index 44ef10a7fb..15befce0d0 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective_cshtml : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective : global::Microsoft.AspNetCore.Mvc.RazorPages.Page { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { @@ -34,9 +34,9 @@ namespace AspNetCore [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; } [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] - public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective_cshtml Model => ViewData.Model; + public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective Model => ViewData.Model; } } #pragma warning restore 1591 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.diagnostics.txt index 664a950710..637d1e902b 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml(1,7): Error RZ9999: The 'page' directive expects a string surrounded by double quotes. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml(1,7): Error RZ1016: The 'page' directive expects a string surrounded by double quotes. diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.ir.txt index 71a96d869b..c3fbc6082e 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective_cshtml - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html @@ -46,6 +46,6 @@ Document - Inject - Inject - CSharpCode - - IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; CSharpCode - - IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective_cshtml Model => ViewData.Model; + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective Model => ViewData.Model; diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.codegen.cs index 1ce4676fc9..c90d98ec8f 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "5a9ff8440150c6746e4a8ba63bc633ea84930405" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective_cshtml), null)] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective), @"mvc.1.0.razor-page", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective), null)] namespace AspNetCore { #line hidden @@ -12,7 +13,8 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective_cshtml : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"5a9ff8440150c6746e4a8ba63bc633ea84930405", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective : global::Microsoft.AspNetCore.Mvc.RazorPages.Page { #pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() @@ -31,9 +33,9 @@ namespace AspNetCore [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; } [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] - public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective_cshtml Model => ViewData.Model; + public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective Model => ViewData.Model; } } #pragma warning restore 1591 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.diagnostics.txt index 664a950710..637d1e902b 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml(1,7): Error RZ9999: The 'page' directive expects a string surrounded by double quotes. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml(1,7): Error RZ1016: The 'page' directive expects a string surrounded by double quotes. diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.ir.txt index 8acaa03a0d..0692442d42 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective_cshtml), null)] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective), null)] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,7 +10,8 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective_cshtml - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync MalformedDirective - (0:0,0 [6] MalformedPageDirective.cshtml) - page CSharpCode - @@ -31,6 +33,6 @@ Document - Inject - Inject - CSharpCode - - IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; CSharpCode - - IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective_cshtml Model => ViewData.Model; + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective Model => ViewData.Model; diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.codegen.cs index 8dc9887854..e669a23be0 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { private global::InputTestTagHelper __InputTestTagHelper; #pragma warning disable 219 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.ir.txt index 529d7a140b..37627e94ea 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DefaultTagHelperRuntime - FieldDeclaration - - private - global::InputTestTagHelper - __InputTestTagHelper DesignTimeDirective - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.mappings.txt index 0a0cb62f30..ced10bc85e 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.mappings.txt @@ -1,20 +1,20 @@ Source Location: (7:0,7 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml) |DateTime| -Generated Location: (758:19,0 [8] ) +Generated Location: (751:19,0 [8] ) |DateTime| Source Location: (33:2,14 [29] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml) |"InputTestTagHelper, AppCode"| -Generated Location: (899:23,37 [29] ) +Generated Location: (892:23,37 [29] ) |"InputTestTagHelper, AppCode"| Source Location: (83:4,17 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml) |Date| -Generated Location: (1547:36,102 [4] ) +Generated Location: (1540:36,102 [4] ) |Date| Source Location: (111:5,18 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml) |Model| -Generated Location: (1863:42,94 [5] ) +Generated Location: (1856:42,94 [5] ) |Model| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.codegen.cs index 2db976ac8c..238210a6a3 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "0906a816db301fe624bbe5a96c4b3013071ea492" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper_cshtml))] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper))] namespace AspNetCore { #line hidden @@ -12,7 +13,8 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"0906a816db301fe624bbe5a96c4b3013071ea492", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #line hidden #pragma warning disable 0169 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.ir.txt index c7a6817e41..1fb7820a75 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper_cshtml))] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper))] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,7 +10,8 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DefaultTagHelperRuntime - FieldDeclaration - - private - global::InputTestTagHelper - __InputTestTagHelper MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.codegen.cs index b12ca26651..923b853936 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.ir.txt index b346a02ef5..1ebdc00df2 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.mappings.txt index 226138531b..14e9047943 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.mappings.txt @@ -1,5 +1,5 @@ Source Location: (7:0,7 [30] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml) |System.Collections.IEnumerable| -Generated Location: (695:18,0 [30] ) +Generated Location: (688:18,0 [30] ) |System.Collections.IEnumerable| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.codegen.cs index 511ba16f5e..3c58601f0f 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "31c5b047a450ac9f6dc4116626667d26bfb657ba" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model_cshtml))] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model))] namespace AspNetCore { #line hidden @@ -12,7 +13,8 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"31c5b047a450ac9f6dc4116626667d26bfb657ba", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.ir.txt index 30bcc7afe1..2b7dcff085 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model_cshtml))] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model))] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,7 +10,8 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync Inject - Inject - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.codegen.cs index a766ae3900..dc5fcee8a2 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MultipleModels_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MultipleModels : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt index b051568470..2fe8233c66 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml(2,1): Error RZ9999: The 'model' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml(2,1): Error RZ2001: The 'model' directive may only occur once per document. diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.ir.txt index 7c125bef61..f63a69601b 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MultipleModels_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MultipleModels - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.mappings.txt index 65348abd7b..ff5971643c 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.mappings.txt @@ -1,10 +1,10 @@ Source Location: (7:0,7 [21] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml) |ThisShouldBeGenerated| -Generated Location: (695:18,0 [21] ) +Generated Location: (688:18,0 [21] ) |ThisShouldBeGenerated| Source Location: (37:1,7 [30] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml) |System.Collections.IEnumerable| -Generated Location: (825:22,0 [30] ) +Generated Location: (818:22,0 [30] ) |System.Collections.IEnumerable| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.codegen.cs index b584c46a88..cb05019c29 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace Test.Namespace using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class PageWithNamespace_Page : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace : global::Microsoft.AspNetCore.Mvc.RazorPages.Page { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { @@ -38,9 +38,9 @@ global::System.Object __typeHelper = nameof(Test.Namespace); [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; } [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] - public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; - public PageWithNamespace_Page Model => ViewData.Model; + public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace Model => ViewData.Model; } } #pragma warning restore 1591 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.ir.txt index 0dc65607e5..9238a0a419 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - PageWithNamespace_Page - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html @@ -42,6 +42,6 @@ Document - Inject - Inject - CSharpCode - - IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; CSharpCode - - IntermediateToken - - CSharp - public PageWithNamespace_Page Model => ViewData.Model; + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace Model => ViewData.Model; diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.mappings.txt index 341492ab00..23b745fa44 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.mappings.txt @@ -1,5 +1,5 @@ Source Location: (18:1,11 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml) |Test.Namespace| -Generated Location: (664:18,44 [14] ) +Generated Location: (716:18,44 [14] ) |Test.Namespace| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.codegen.cs index ed1a98a723..5c256902b6 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "b205857d3dad47cb3f0c1d7775ae251b306ab830" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(Test.Namespace.PageWithNamespace_Page), null)] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace), @"mvc.1.0.razor-page", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml", typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace), null)] namespace Test.Namespace { #line hidden @@ -12,7 +13,8 @@ namespace Test.Namespace using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class PageWithNamespace_Page : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"b205857d3dad47cb3f0c1d7775ae251b306ab830", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace : global::Microsoft.AspNetCore.Mvc.RazorPages.Page { #pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() @@ -31,9 +33,9 @@ namespace Test.Namespace [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; } [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] - public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; - public PageWithNamespace_Page Model => ViewData.Model; + public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace Model => ViewData.Model; } } #pragma warning restore 1591 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.ir.txt index 841a9e1040..53b89427ee 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(Test.Namespace.PageWithNamespace_Page), null)] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml", typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace), null)] NamespaceDeclaration - - Test.Namespace UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,7 +10,8 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - PageWithNamespace_Page - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync CSharpCode - IntermediateToken - - CSharp - BeginContext(34, 20, true); @@ -26,6 +28,6 @@ Document - Inject - Inject - CSharpCode - - IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; CSharpCode - - IntermediateToken - - CSharp - public PageWithNamespace_Page Model => ViewData.Model; + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace Model => ViewData.Model; diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.codegen.cs index 6cccda46f2..af9ff10e76 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.codegen.cs @@ -16,7 +16,7 @@ using Microsoft.AspNetCore.Mvc.RazorPages; #line default #line hidden - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel_cshtml : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel : global::Microsoft.AspNetCore.Mvc.RazorPages.Page { private global::DivTagHelper __DivTagHelper; #pragma warning disable 219 @@ -71,9 +71,9 @@ global::System.Object __typeHelper = "*, AppCode"; [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; } [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] - public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel_cshtml Model => ViewData.Model; + public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel Model => ViewData.Model; } } #pragma warning restore 1591 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.ir.txt index 8662b30f1e..913b80d2aa 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.ir.txt @@ -9,7 +9,7 @@ Document - UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures UsingDirective - (38:3,1 [41] RazorPagesWithoutModel.cshtml) - Microsoft.AspNetCore.Mvc.RazorPages - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel_cshtml - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - DefaultTagHelperRuntime - FieldDeclaration - - private - global::DivTagHelper - __DivTagHelper DesignTimeDirective - @@ -138,6 +138,6 @@ Document - Inject - Inject - CSharpCode - - IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; CSharpCode - - IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel_cshtml Model => ViewData.Model; + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel Model => ViewData.Model; diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.mappings.txt index 0f57e118d6..a4abcf411d 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.mappings.txt @@ -5,12 +5,12 @@ Generated Location: (487:14,0 [41] ) Source Location: (23:2,14 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml) |"*, AppCode"| -Generated Location: (944:24,37 [12] ) +Generated Location: (937:24,37 [12] ) |"*, AppCode"| Source Location: (566:24,47 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml) |Name| -Generated Location: (1507:37,47 [4] ) +Generated Location: (1500:37,47 [4] ) |Name| Source Location: (95:5,12 [283] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml) @@ -28,7 +28,7 @@ Source Location: (95:5,12 [283] TestFiles/IntegrationTests/CodeGenerationIntegra public string Name { get; set; } } | -Generated Location: (1988:48,12 [283] ) +Generated Location: (1981:48,12 [283] ) | public IActionResult OnPost(Customer customer) { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.codegen.cs index 565653d24d..aadcde70fd 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "c0587249e6e0b7ba4e1efc463f58577d5d0b6ae2" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel_cshtml), null)] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel), @"mvc.1.0.razor-page", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel), null)] namespace AspNetCore { #line hidden @@ -17,7 +18,8 @@ using Microsoft.AspNetCore.Mvc.RazorPages; #line default #line hidden - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel_cshtml : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"c0587249e6e0b7ba4e1efc463f58577d5d0b6ae2", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel : global::Microsoft.AspNetCore.Mvc.RazorPages.Page { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("text-danger"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("col-md-10"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); @@ -194,9 +196,9 @@ using Microsoft.AspNetCore.Mvc.RazorPages; [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; } [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] - public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel_cshtml Model => ViewData.Model; + public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel Model => ViewData.Model; } } #pragma warning restore 1591 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.ir.txt index 9b45194f6c..519006aec3 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel_cshtml), null)] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel), null)] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -10,7 +11,8 @@ Document - UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures UsingDirective - (38:3,1 [43] RazorPagesWithoutModel.cshtml) - Microsoft.AspNetCore.Mvc.RazorPages - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel_cshtml - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - class - text-danger - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - class - col-md-10 - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_2 - class - form-group - HtmlAttributeValueStyle.DoubleQuotes @@ -186,6 +188,6 @@ Document - Inject - Inject - CSharpCode - - IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; CSharpCode - - IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel_cshtml Model => ViewData.Model; + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel Model => ViewData.Model; diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.codegen.cs index 3fc1ec92eb..8731920f14 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.codegen.cs @@ -16,7 +16,7 @@ using Microsoft.AspNetCore.Mvc.RazorPages; #line default #line hidden - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages_cshtml : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages : global::Microsoft.AspNetCore.Mvc.RazorPages.Page { private global::DivTagHelper __DivTagHelper; #pragma warning disable 219 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.ir.txt index f1df7922a5..2266b746f6 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.ir.txt @@ -9,7 +9,7 @@ Document - UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures UsingDirective - (55:4,1 [41] RazorPages.cshtml) - Microsoft.AspNetCore.Mvc.RazorPages - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages_cshtml - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - DefaultTagHelperRuntime - FieldDeclaration - - private - global::DivTagHelper - __DivTagHelper DesignTimeDirective - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.mappings.txt index 88bdded9c2..02d6726a3a 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.mappings.txt @@ -5,17 +5,17 @@ Generated Location: (475:14,0 [41] ) Source Location: (16:2,7 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml) |NewModel| -Generated Location: (883:24,0 [8] ) +Generated Location: (876:24,0 [8] ) |NewModel| Source Location: (40:3,14 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml) |"*, AppCode"| -Generated Location: (1024:28,37 [12] ) +Generated Location: (1017:28,37 [12] ) |"*, AppCode"| Source Location: (661:28,47 [10] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml) |Model.Name| -Generated Location: (1575:41,47 [10] ) +Generated Location: (1568:41,47 [10] ) |Model.Name| Source Location: (112:6,12 [360] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml) @@ -36,7 +36,7 @@ Source Location: (112:6,12 [360] TestFiles/IntegrationTests/CodeGenerationIntegr public string Name { get; set; } } | -Generated Location: (2050:52,12 [360] ) +Generated Location: (2043:52,12 [360] ) | public class NewModel : PageModel { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.codegen.cs index d43bdad547..bda200e2ef 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "608b3f7b9b29c66ee25bde2d20324b4bef1aa070" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages_cshtml), null)] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages), @"mvc.1.0.razor-page", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages), null)] namespace AspNetCore { #line hidden @@ -17,7 +18,8 @@ using Microsoft.AspNetCore.Mvc.RazorPages; #line default #line hidden - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages_cshtml : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"608b3f7b9b29c66ee25bde2d20324b4bef1aa070", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages : global::Microsoft.AspNetCore.Mvc.RazorPages.Page { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("text-danger"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("col-md-10"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.ir.txt index fd1dc08a9a..cc1bc6f718 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages_cshtml), null)] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages), null)] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -10,7 +11,8 @@ Document - UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures UsingDirective - (55:4,1 [43] RazorPages.cshtml) - Microsoft.AspNetCore.Mvc.RazorPages - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages_cshtml - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - class - text-danger - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - class - col-md-10 - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_2 - class - form-group - HtmlAttributeValueStyle.DoubleQuotes diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs index fd3c971a71..604b3f412a 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { private global::InputTestTagHelper __InputTestTagHelper; #pragma warning disable 219 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt index 061c04e613..312d7bb7ae 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DefaultTagHelperRuntime - FieldDeclaration - - private - global::InputTestTagHelper - __InputTestTagHelper DesignTimeDirective - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt index 5e120c830d..4eb221e12b 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt @@ -1,29 +1,29 @@ Source Location: (7:0,7 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) |DateTime| -Generated Location: (742:19,0 [8] ) +Generated Location: (735:19,0 [8] ) |DateTime| Source Location: (33:2,14 [29] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) |"InputTestTagHelper, AppCode"| -Generated Location: (883:23,37 [29] ) +Generated Location: (876:23,37 [29] ) |"InputTestTagHelper, AppCode"| Source Location: (152:10,9 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) |Section1| -Generated Location: (997:27,22 [8] ) +Generated Location: (990:27,22 [8] ) |Section1| Source Location: (68:4,2 [46] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) | Layout = "_SectionTestLayout.cshtml"; | -Generated Location: (1432:39,2 [46] ) +Generated Location: (1425:39,2 [46] ) | Layout = "_SectionTestLayout.cshtml"; | Source Location: (222:12,21 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) |Date| -Generated Location: (1857:47,102 [4] ) +Generated Location: (1850:47,102 [4] ) |Date| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs index ba56f04308..1bf54c1495 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "dbec91fd88a09c6a2e35b5adedb3f8ab8e3ae486" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_cshtml))] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections))] namespace AspNetCore { #line hidden @@ -12,7 +13,8 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"dbec91fd88a09c6a2e35b5adedb3f8ab8e3ae486", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #line hidden #pragma warning disable 0169 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.ir.txt index 4a4f3ce128..8a5b810749 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_cshtml))] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections))] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,7 +10,8 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DefaultTagHelperRuntime - FieldDeclaration - - private - global::InputTestTagHelper - __InputTestTagHelper MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.codegen.cs index 3e793c429e..1cd38d3029 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.codegen.cs @@ -11,10 +11,10 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { private global::AllTagHelper __AllTagHelper; - private global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml.__Generated__TestViewComponentTagHelper __TestViewComponentTagHelper; + private global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper __TestViewComponentTagHelper; #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { ((System.Action)(() => { @@ -36,7 +36,7 @@ global::System.Object __typeHelper = "*, AppCode"; #line default #line hidden __AllTagHelper = CreateTagHelper(); - __TestViewComponentTagHelper = CreateTagHelper(); + __TestViewComponentTagHelper = CreateTagHelper(); #line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml" __o = foo; diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.ir.txt index a4644b8052..8e7497e7d6 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.ir.txt @@ -8,10 +8,10 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DefaultTagHelperRuntime - FieldDeclaration - - private - global::AllTagHelper - __AllTagHelper - FieldDeclaration - - private - global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml.__Generated__TestViewComponentTagHelper - __TestViewComponentTagHelper + FieldDeclaration - - private - global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper - __TestViewComponentTagHelper DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html @@ -43,7 +43,7 @@ Document - TagHelper - (61:5,0 [50] ViewComponentTagHelper.cshtml) - vc:test - TagMode.StartTagAndEndTag DefaultTagHelperBody - DefaultTagHelperCreate - - AllTagHelper - DefaultTagHelperCreate - - AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml.__Generated__TestViewComponentTagHelper + DefaultTagHelperCreate - - AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper DefaultTagHelperProperty - (82:5,21 [4] ViewComponentTagHelper.cshtml) - first-name - string TestViewComponentTagHelper.firstName - HtmlAttributeValueStyle.DoubleQuotes CSharpExpression - (83:5,22 [3] ViewComponentTagHelper.cshtml) IntermediateToken - (83:5,22 [3] ViewComponentTagHelper.cshtml) - CSharp - foo diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.mappings.txt index 9344e08ed2..dcc0a00913 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.mappings.txt @@ -1,19 +1,19 @@ Source Location: (14:0,14 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml) |"*, AppCode"| -Generated Location: (973:20,37 [12] ) +Generated Location: (959:20,37 [12] ) |"*, AppCode"| Source Location: (30:1,2 [26] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml) | var foo = "Hello"; | -Generated Location: (1419:32,2 [26] ) +Generated Location: (1405:32,2 [26] ) | var foo = "Hello"; | Source Location: (83:5,22 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml) |foo| -Generated Location: (1877:40,22 [3] ) +Generated Location: (1856:40,22 [3] ) |foo| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.codegen.cs index fae9d8f97e..912ddae15c 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "6a0ad3c59f3a87877c36928472f0508bd40cdd8c" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml))] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper))] namespace AspNetCore { #line hidden @@ -12,9 +13,10 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"6a0ad3c59f3a87877c36928472f0508bd40cdd8c", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { - private global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml.__Generated__TestViewComponentTagHelper __TestViewComponentTagHelper; + private global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper __TestViewComponentTagHelper; private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("bar", " World", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); #line hidden #pragma warning disable 0169 @@ -53,7 +55,7 @@ namespace AspNetCore ); __AllTagHelper = CreateTagHelper(); __tagHelperExecutionContext.Add(__AllTagHelper); - __TestViewComponentTagHelper = CreateTagHelper(); + __TestViewComponentTagHelper = CreateTagHelper(); __tagHelperExecutionContext.Add(__TestViewComponentTagHelper); BeginWriteTagHelperAttribute(); #line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml" diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.ir.txt index 1afbf3ebfd..4c215a09d3 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml))] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper))] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,8 +10,9 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - - FieldDeclaration - - private - global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml.__Generated__TestViewComponentTagHelper - __TestViewComponentTagHelper + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + FieldDeclaration - - private - global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper - __TestViewComponentTagHelper PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - bar - World - HtmlAttributeValueStyle.DoubleQuotes DefaultTagHelperRuntime - FieldDeclaration - - private - global::AllTagHelper - __AllTagHelper @@ -28,7 +30,7 @@ Document - TagHelper - (61:5,0 [50] ViewComponentTagHelper.cshtml) - vc:test - TagMode.StartTagAndEndTag DefaultTagHelperBody - DefaultTagHelperCreate - - AllTagHelper - DefaultTagHelperCreate - - AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml.__Generated__TestViewComponentTagHelper + DefaultTagHelperCreate - - AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper DefaultTagHelperProperty - (82:5,21 [4] ViewComponentTagHelper.cshtml) - first-name - string TestViewComponentTagHelper.firstName - HtmlAttributeValueStyle.DoubleQuotes CSharpExpression - (83:5,22 [3] ViewComponentTagHelper.cshtml) IntermediateToken - (83:5,22 [3] ViewComponentTagHelper.cshtml) - CSharp - foo diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.codegen.cs index 360ee6de22..208184dc25 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace Test.Namespace using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class ViewWithNamespace_View : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewWithNamespace : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.ir.txt index 817da953cc..42d53bcd1b 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - ViewWithNamespace_View - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewWithNamespace - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.mappings.txt index 18b68f476b..caae65f18f 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.mappings.txt @@ -1,5 +1,5 @@ Source Location: (11:0,11 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml) |Test.Namespace| -Generated Location: (673:18,44 [14] ) +Generated Location: (725:18,44 [14] ) |Test.Namespace| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_Runtime.codegen.cs index b1ffde19d1..aab5b52963 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "2893acf42354a0bc8b6a2698f5d2e4fab0e59dbe" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(Test.Namespace.ViewWithNamespace_View))] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewWithNamespace), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml", typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewWithNamespace))] namespace Test.Namespace { #line hidden @@ -12,7 +13,8 @@ namespace Test.Namespace using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class ViewWithNamespace_View : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"2893acf42354a0bc8b6a2698f5d2e4fab0e59dbe", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewWithNamespace : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_Runtime.ir.txt index fe9408759b..471464c580 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(Test.Namespace.ViewWithNamespace_View))] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml", typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewWithNamespace))] NamespaceDeclaration - - Test.Namespace UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,7 +10,8 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - ViewWithNamespace_View - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewWithNamespace - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync CSharpCode - IntermediateToken - - CSharp - BeginContext(27, 20, true); diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.codegen.cs index 2e09a42013..6bc3c83d01 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.ir.txt index af728a2813..b677049ce1 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.mappings.txt index 287d4e0c05..a418264123 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.mappings.txt @@ -1,10 +1,10 @@ Source Location: (8:0,8 [19] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml) |IHtmlHelper| -Generated Location: (679:18,0 [19] ) +Generated Location: (672:18,0 [19] ) |IHtmlHelper| Source Location: (28:0,28 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml) |Helper| -Generated Location: (827:22,22 [6] ) +Generated Location: (820:22,22 [6] ) |Helper| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.codegen.cs index 748d2c4dc3..f60ea39dac 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "e57bbc3e746e8b13b4c33d8df0e022bd397d8caa" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports_cshtml))] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports))] namespace AspNetCore { #line hidden @@ -12,7 +13,8 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"e57bbc3e746e8b13b4c33d8df0e022bd397d8caa", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.ir.txt index 700715b3e4..addc2754ec 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports_cshtml))] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports))] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,7 +10,8 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync Inject - Inject - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.codegen.cs index 632e83d73c..42761df919 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "723b7da149db577d0c49cff7c00f2d831e8916e7" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Razor.Template), @"default", @"/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.cshtml")] namespace Razor { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"723b7da149db577d0c49cff7c00f2d831e8916e7", @"/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.cshtml")] public class Template { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("value", "Hello", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.ir.txt index 69d1ee0c72..c4ba72abd9 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Razor + RazorSourceChecksumAttribute - ClassDeclaration - - public - Template - - PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - value - Hello - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - type - text - HtmlAttributeValueStyle.SingleQuotes diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/ViewComponentTagHelperPassTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/ViewComponentTagHelperPassTest.cs index ab70db8306..d6b2b398e5 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/ViewComponentTagHelperPassTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/ViewComponentTagHelperPassTest.cs @@ -79,7 +79,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions var irDocument = CreateIRDocument(engine, codeDocument); - var vcthFullName = "AspNetCore.test_cshtml.__Generated__TagCloudViewComponentTagHelper"; + var vcthFullName = "AspNetCore.test.__Generated__TagCloudViewComponentTagHelper"; // Act pass.Execute(codeDocument, irDocument); @@ -126,7 +126,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions var irDocument = CreateIRDocument(engine, codeDocument); - var vcthFullName = "AspNetCore.test_cshtml.__Generated__TagCloudViewComponentTagHelper"; + var vcthFullName = "AspNetCore.test.__Generated__TagCloudViewComponentTagHelper"; // Act pass.Execute(codeDocument, irDocument); @@ -179,7 +179,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions var irDocument = CreateIRDocument(engine, codeDocument); - var vcthFullName = "AspNetCore.test_cshtml.__Generated__TagCloudViewComponentTagHelper"; + var vcthFullName = "AspNetCore.test.__Generated__TagCloudViewComponentTagHelper"; // Act pass.Execute(codeDocument, irDocument); diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/ModelDirectiveTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/ModelDirectiveTest.cs index c366918999..c0319a9a0a 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/ModelDirectiveTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/ModelDirectiveTest.cs @@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X "); var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: false) + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -88,7 +88,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X "); var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: false) + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -114,7 +114,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X "); var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: false) + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -139,7 +139,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X "); var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: false) + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -163,8 +163,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X @inherits BaseType "); - var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: true) + var engine = CreateDesignTimeEngine(); + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -193,8 +193,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X @model SomeType "); - var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: true) + var engine = CreateDesignTimeEngine(); + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -246,6 +246,18 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X }); } + private RazorEngine CreateDesignTimeEngine() + { + return RazorEngine.CreateDesignTime(b => + { + // Notice we're not registering the ModelDirective.Pass here so we can run it on demand. + b.AddDirective(ModelDirective.Directive); + + // There's some special interaction with the inherits directive + InheritsDirective.Register(b); + }); + } + private DocumentIntermediateNode CreateIRDocument(RazorEngine engine, RazorCodeDocument codeDocument) { for (var i = 0; i < engine.Phases.Count; i++) diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/MvcImportProjectFeatureTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/MvcImportProjectFeatureTest.cs new file mode 100644 index 0000000000..e53046ed5a --- /dev/null +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/MvcImportProjectFeatureTest.cs @@ -0,0 +1,76 @@ +// 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 Microsoft.AspNetCore.Razor.Language; +using Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X +{ + public class MvcImportProjectFeatureTest + { + [Fact] + public void AddDefaultDirectivesImport_AddsSingleDynamicImport() + { + // Arrange + var imports = new List(); + + // Act + MvcImportProjectFeature.AddDefaultDirectivesImport(imports); + + // Assert + var import = Assert.Single(imports); + Assert.Null(import.FilePath); + } + + [Fact] + public void AddHierarchicalImports_AddsViewImportSourceDocumentsOnDisk() + { + // Arrange + var imports = new List(); + var projectItem = new TestRazorProjectItem("/Contact/Index.cshtml"); + var testFileSystem = new TestRazorProjectFileSystem(new[] + { + new TestRazorProjectItem("/Index.cshtml"), + new TestRazorProjectItem("/_ViewImports.cshtml"), + new TestRazorProjectItem("/Contact/_ViewImports.cshtml"), + projectItem, + }); + var mvcImportFeature = new MvcImportProjectFeature() + { + ProjectEngine = Mock.Of(projectEngine => projectEngine.FileSystem == testFileSystem) + }; + + // Act + mvcImportFeature.AddHierarchicalImports(projectItem, imports); + + // Assert + Assert.Collection(imports, + import => Assert.Equal("/_ViewImports.cshtml", import.FilePath), + import => Assert.Equal("/Contact/_ViewImports.cshtml", import.FilePath)); + } + + [Fact] + public void AddHierarchicalImports_AddsViewImportSourceDocumentsNotOnDisk() + { + // Arrange + var imports = new List(); + var projectItem = new TestRazorProjectItem("/Pages/Contact/Index.cshtml"); + var testFileSystem = new TestRazorProjectFileSystem(new[] { projectItem }); + var mvcImportFeature = new MvcImportProjectFeature() + { + ProjectEngine = Mock.Of(projectEngine => projectEngine.FileSystem == testFileSystem) + }; + + // Act + mvcImportFeature.AddHierarchicalImports(projectItem, imports); + + // Assert + Assert.Collection(imports, + import => Assert.Equal("/_ViewImports.cshtml", import.FilePath), + import => Assert.Equal("/Pages/_ViewImports.cshtml", import.FilePath), + import => Assert.Equal("/Pages/Contact/_ViewImports.cshtml", import.FilePath)); + } + } +} diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/MvcRazorTemplateEngineTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/MvcRazorTemplateEngineTest.cs index b4954469bc..c2378397a6 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/MvcRazorTemplateEngineTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/MvcRazorTemplateEngineTest.cs @@ -2,10 +2,8 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using System.Linq; using Microsoft.AspNetCore.Razor.Language; -using Moq; using Xunit; namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X @@ -28,7 +26,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X }; var mvcRazorTemplateEngine = new MvcRazorTemplateEngine( RazorEngine.Create(), - new TestRazorProject()); + new TestRazorProjectFileSystem()); // Act var imports = mvcRazorTemplateEngine.Options.DefaultImports; @@ -54,7 +52,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X }; var mvcRazorTemplateEngine = new MvcRazorTemplateEngine( RazorEngine.Create(), - new TestRazorProject()); + new TestRazorProjectFileSystem()); // Act var imports = mvcRazorTemplateEngine.Options.DefaultImports; @@ -72,7 +70,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X // Arrange var mvcRazorTemplateEngine = new MvcRazorTemplateEngine( RazorEngine.Create(), - new TestRazorProject()); + new TestRazorProjectFileSystem()); // Act var imports = mvcRazorTemplateEngine.Options.DefaultImports; @@ -84,28 +82,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X Assert.Contains("@addTagHelper Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor", importContent); } - [Fact] - public void CreateCodeDocument_SetsRelativePathOnOutput() - { - // Arrange - var path = "/Views/Home/Index.cshtml"; - var item = new TestRazorProjectItem(path) - { - Content = "Hello world", - }; - var project = new TestRazorProject(new List() { item, }); - - var mvcRazorTemplateEngine = new MvcRazorTemplateEngine( - RazorEngine.Create(), - project); - - // Act - var codeDocument = mvcRazorTemplateEngine.CreateCodeDocument(path); - - // Assert - Assert.Equal(path, codeDocument.GetRelativePath()); - } - private string GetContent(RazorSourceDocument imports) { var contentChars = new char[imports.Length]; diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/MvcViewDocumentClassifierPassTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/MvcViewDocumentClassifierPassTest.cs index d0b8361965..2000f66a53 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/MvcViewDocumentClassifierPassTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/MvcViewDocumentClassifierPassTest.cs @@ -1,7 +1,6 @@ // 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.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Intermediate; using Xunit; @@ -14,7 +13,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X public void MvcViewDocumentClassifierPass_SetsDocumentKind() { // Arrange - var codeDocument = CreateDocument("some-content"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", "Test.cshtml")); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new MvcViewDocumentClassifierPass @@ -33,7 +33,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X public void MvcViewDocumentClassifierPass_NoOpsIfDocumentKindIsAlreadySet() { // Arrange - var codeDocument = CreateDocument("some-content"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", "Test.cshtml")); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); irDocument.DocumentKind = "some-value"; @@ -53,7 +54,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X public void MvcViewDocumentClassifierPass_SetsNamespace() { // Arrange - var codeDocument = CreateDocument("some-content"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", "Test.cshtml")); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new MvcViewDocumentClassifierPass @@ -74,14 +76,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X public void MvcViewDocumentClassifierPass_SetsClass() { // Arrange - var codeDocument = CreateDocument("some-content"); + var properties = new RazorSourceDocumentProperties(filePath: "ignored", relativePath: "Test.cshtml"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", properties)); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new MvcViewDocumentClassifierPass { Engine = engine }; - codeDocument.SetRelativePath("Test.cshtml"); // Act pass.Execute(codeDocument, irDocument); @@ -91,17 +94,18 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X // Assert Assert.Equal("global::Microsoft.AspNetCore.Mvc.Razor.RazorPage", visitor.Class.BaseType); Assert.Equal(new[] { "public" }, visitor.Class.Modifiers); - Assert.Equal("Test_cshtml", visitor.Class.ClassName); + Assert.Equal("Test", visitor.Class.ClassName); } [Theory] - [InlineData("/Views/Home/Index.cshtml", "_Views_Home_Index_cshtml")] - [InlineData("/Areas/MyArea/Views/Home/About.cshtml", "_Areas_MyArea_Views_Home_About_cshtml")] + [InlineData("/Views/Home/Index.cshtml", "_Views_Home_Index")] + [InlineData("/Areas/MyArea/Views/Home/About.cshtml", "_Areas_MyArea_Views_Home_About")] public void MvcViewDocumentClassifierPass_UsesRelativePathToGenerateTypeName(string relativePath, string expected) { // Arrange - var codeDocument = CreateDocument("some-content"); - codeDocument.SetRelativePath(relativePath); + var properties = new RazorSourceDocumentProperties(filePath: "ignored", relativePath: relativePath); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", properties)); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new MvcViewDocumentClassifierPass @@ -122,9 +126,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X public void MvcViewDocumentClassifierPass_UsesAbsolutePath_IfRelativePathIsNotSet() { // Arrange - var expected = "x___application_Views_Home_Index_cshtml"; - var path = @"x::\application\Views\Home\Index.cshtml"; - var codeDocument = CreateDocument("some-content", path); + var properties = new RazorSourceDocumentProperties(filePath: @"x::\application\Views\Home\Index.cshtml", relativePath: null); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", properties)); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new MvcViewDocumentClassifierPass @@ -138,16 +142,16 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X visitor.Visit(irDocument); // Assert - Assert.Equal(expected, visitor.Class.ClassName); + Assert.Equal("x___application_Views_Home_Index", visitor.Class.ClassName); } [Fact] public void MvcViewDocumentClassifierPass_SanitizesClassName() { // Arrange - var expected = "path_with_invalid_chars"; - var codeDocument = CreateDocument("some-content"); - codeDocument.SetRelativePath("path.with+invalid-chars"); + var properties = new RazorSourceDocumentProperties(filePath: @"x:\Test.cshtml", relativePath: "path.with+invalid-chars"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", properties)); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new MvcViewDocumentClassifierPass @@ -161,14 +165,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X visitor.Visit(irDocument); // Assert - Assert.Equal(expected, visitor.Class.ClassName); + Assert.Equal("path_with_invalid_chars", visitor.Class.ClassName); } [Fact] public void MvcViewDocumentClassifierPass_SetsUpExecuteAsyncMethod() { // Arrange - var codeDocument = CreateDocument("some-content"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", "Test.cshtml")); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new MvcViewDocumentClassifierPass @@ -187,14 +192,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X Assert.Equal(new[] { "public", "async", "override" }, visitor.Method.Modifiers); } - private static RazorCodeDocument CreateDocument(string content, string filePath = null) - { - filePath = filePath ?? Path.Combine(Directory.GetCurrentDirectory(), "Test.cshtml"); - - var source = RazorSourceDocument.Create(content, filePath); - return RazorCodeDocument.Create(source); - } - private static RazorEngine CreateEngine() => RazorEngine.Create(); private static DocumentIntermediateNode CreateIRDocument(RazorEngine engine, RazorCodeDocument codeDocument) diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.codegen.cs index 3edf343f5e..d39b64c26d 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.ir.txt index ba42b7a0f4..24d84bf975 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.mappings.txt index e25ebcea7e..372b49cb6f 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.mappings.txt @@ -1,34 +1,34 @@ Source Location: (13:0,13 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml) |this.ToString()| -Generated Location: (1037:26,13 [15] ) +Generated Location: (1030:26,13 [15] ) |this.ToString()| Source Location: (54:2,5 [29] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml) |string.Format("{0}", "Hello")| -Generated Location: (1173:31,6 [29] ) +Generated Location: (1166:31,6 [29] ) |string.Format("{0}", "Hello")| Source Location: (95:4,2 [25] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml) | var cls = "foo"; | -Generated Location: (1319:36,2 [25] ) +Generated Location: (1312:36,2 [25] ) | var cls = "foo"; | Source Location: (134:7,11 [18] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml) |if(cls != null) { | -Generated Location: (1467:42,11 [18] ) +Generated Location: (1460:42,11 [18] ) |if(cls != null) { | Source Location: (153:7,30 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml) |cls| -Generated Location: (1629:47,30 [3] ) +Generated Location: (1622:47,30 [3] ) |cls| Source Location: (156:7,33 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml) | }| -Generated Location: (1780:52,33 [2] ) +Generated Location: (1773:52,33 [2] ) | }| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs index e213442d23..5975633478 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt index 72a8fa589b..3542c13c86 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt @@ -1,6 +1,6 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,7): Error RZ9999: The 'model' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,1): Error RZ9999: The 'model' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,8): Error RZ9999: The 'model' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(6,8): Error RZ9999: The 'inject' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,9): Error RZ9999: The 'inject' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,26): Error RZ9999: The 'inject' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,7): Error RZ1013: The 'model' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,1): Error RZ2001: The 'model' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,8): Error RZ1013: The 'model' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(6,8): Error RZ1013: The 'inject' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,9): Error RZ1013: The 'inject' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,26): Error RZ1015: The 'inject' directive expects an identifier. diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt index ef934781a0..3a6d24fc1e 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt index 27676d9e12..3b5068e43c 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt @@ -1,30 +1,30 @@ Source Location: (93:2,6 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) || -Generated Location: (687:18,0 [0] ) +Generated Location: (680:18,0 [0] ) || Source Location: (102:3,7 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) || -Generated Location: (740:21,0 [0] ) +Generated Location: (733:21,0 [0] ) || Source Location: (113:5,7 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) || -Generated Location: (793:24,0 [0] ) +Generated Location: (786:24,0 [0] ) || Source Location: (123:6,8 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) || -Generated Location: (846:27,0 [0] ) +Generated Location: (839:27,0 [0] ) || Source Location: (133:7,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) |MyService| -Generated Location: (899:30,0 [17] ) +Generated Location: (892:30,0 [17] ) |MyService| Source Location: (150:7,25 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) || -Generated Location: (1021:34,0 [0] ) +Generated Location: (1014:34,0 [0] ) || diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.codegen.cs index 0c96a6c7e0..6a16b10feb 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel_cshtml : MyBasePageForViews + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel : MyBasePageForViews { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.ir.txt index 1fba17672d..cc189604db 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel_cshtml - MyBasePageForViews - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel - MyBasePageForViews - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.mappings.txt index 4f38bd7343..9b7a5db61d 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.mappings.txt @@ -1,10 +1,10 @@ Source Location: (10:0,10 [26] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml) |MyBasePageForViews| -Generated Location: (654:18,0 [26] ) +Generated Location: (647:18,0 [26] ) |MyBasePageForViews| Source Location: (45:1,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml) |MyModel| -Generated Location: (794:22,0 [7] ) +Generated Location: (787:22,0 [7] ) |MyModel| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.codegen.cs index a4a69f2b7f..b77fc2e72c 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports_cshtml : MyBasePageForViews + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports : MyBasePageForViews { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.ir.txt index 2da50d158b..eb605730f1 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports_cshtml - MyBasePageForViews - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports - MyBasePageForViews - DesignTimeDirective - DirectiveToken - (10:0,10 [26] InheritsWithViewImports_Imports0.cshtml) - MyBasePageForViews DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.mappings.txt index bd614d72eb..8ae3008a95 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.mappings.txt @@ -1,5 +1,5 @@ Source Location: (7:0,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml) |MyModel| -Generated Location: (660:18,0 [7] ) +Generated Location: (653:18,0 [7] ) |MyModel| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.codegen.cs index 10050cba80..e198bf38b2 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.ir.txt index e1d660ce8d..8ff03ba4e9 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.mappings.txt index 64bb4804b3..0d58ddea20 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.mappings.txt @@ -1,25 +1,25 @@ Source Location: (7:0,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml) |MyModel| -Generated Location: (682:18,0 [7] ) +Generated Location: (675:18,0 [7] ) |MyModel| Source Location: (24:1,8 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml) |MyApp| -Generated Location: (784:22,0 [5] ) +Generated Location: (777:22,0 [5] ) |MyApp| Source Location: (30:1,14 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml) |MyPropertyName| -Generated Location: (904:26,22 [14] ) +Generated Location: (897:26,22 [14] ) |MyPropertyName| Source Location: (54:2,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml) |MyService| -Generated Location: (988:30,0 [17] ) +Generated Location: (981:30,0 [17] ) |MyService| Source Location: (72:2,26 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml) |Html| -Generated Location: (1132:34,22 [4] ) +Generated Location: (1125:34,22 [4] ) |Html| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.codegen.cs index 2c3776aedd..7d588d5d12 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.ir.txt index 4c0240ef2d..2b470e7180 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.mappings.txt index fb80df37b7..8e98145f2d 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.mappings.txt @@ -1,45 +1,45 @@ Source Location: (7:0,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |MyModel| -Generated Location: (686:18,0 [7] ) +Generated Location: (679:18,0 [7] ) |MyModel| Source Location: (24:1,8 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |MyApp| -Generated Location: (788:22,0 [5] ) +Generated Location: (781:22,0 [5] ) |MyApp| Source Location: (30:1,14 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |MyPropertyName| -Generated Location: (908:26,22 [14] ) +Generated Location: (901:26,22 [14] ) |MyPropertyName| Source Location: (58:2,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |MyService| -Generated Location: (992:30,0 [17] ) +Generated Location: (985:30,0 [17] ) |MyService| Source Location: (76:2,26 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |Html| -Generated Location: (1136:34,22 [4] ) +Generated Location: (1129:34,22 [4] ) |Html| Source Location: (93:3,8 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |MyApp| -Generated Location: (1210:38,0 [5] ) +Generated Location: (1203:38,0 [5] ) |MyApp| Source Location: (99:3,14 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |MyPropertyName2| -Generated Location: (1330:42,22 [15] ) +Generated Location: (1323:42,22 [15] ) |MyPropertyName2| Source Location: (129:4,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |MyService| -Generated Location: (1415:46,0 [17] ) +Generated Location: (1408:46,0 [17] ) |MyService| Source Location: (147:4,26 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |Html2| -Generated Location: (1559:50,22 [5] ) +Generated Location: (1552:50,22 [5] ) |Html2| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.codegen.cs index b8e43e2f76..b6a4d2a93f 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.ir.txt index e00df79298..2fed4fbe5a 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.mappings.txt index ec01d63774..8bd4399f3f 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.mappings.txt @@ -1,10 +1,10 @@ Source Location: (8:0,8 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml) |MyApp| -Generated Location: (673:18,0 [5] ) +Generated Location: (666:18,0 [5] ) |MyApp| Source Location: (14:0,14 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml) |MyPropertyName| -Generated Location: (793:22,22 [14] ) +Generated Location: (786:22,22 [14] ) |MyPropertyName| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.codegen.cs index d4bee96fbd..d99c176c52 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt index cfbf688e18..c3add1daa9 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml(1,2): Error RZ9999: "namespace" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml(1,2): Error RZ1007: "namespace" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.ir.txt index 59f3e7b070..f34fe8f4a0 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.codegen.cs index 8dc9887854..e669a23be0 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { private global::InputTestTagHelper __InputTestTagHelper; #pragma warning disable 219 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.ir.txt index c4bbcf7a73..1ecd121c63 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DefaultTagHelperRuntime - FieldDeclaration - - private - global::InputTestTagHelper - __InputTestTagHelper DesignTimeDirective - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.mappings.txt index 0a0cb62f30..ced10bc85e 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.mappings.txt @@ -1,20 +1,20 @@ Source Location: (7:0,7 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml) |DateTime| -Generated Location: (758:19,0 [8] ) +Generated Location: (751:19,0 [8] ) |DateTime| Source Location: (33:2,14 [29] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml) |"InputTestTagHelper, AppCode"| -Generated Location: (899:23,37 [29] ) +Generated Location: (892:23,37 [29] ) |"InputTestTagHelper, AppCode"| Source Location: (83:4,17 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml) |Date| -Generated Location: (1547:36,102 [4] ) +Generated Location: (1540:36,102 [4] ) |Date| Source Location: (111:5,18 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml) |Model| -Generated Location: (1863:42,94 [5] ) +Generated Location: (1856:42,94 [5] ) |Model| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.codegen.cs index b12ca26651..923b853936 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.ir.txt index 75faeeb1ca..c18b0cd554 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.mappings.txt index 226138531b..14e9047943 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.mappings.txt @@ -1,5 +1,5 @@ Source Location: (7:0,7 [30] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml) |System.Collections.IEnumerable| -Generated Location: (695:18,0 [30] ) +Generated Location: (688:18,0 [30] ) |System.Collections.IEnumerable| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.codegen.cs index a766ae3900..dc5fcee8a2 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MultipleModels_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MultipleModels : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt index b051568470..2fe8233c66 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml(2,1): Error RZ9999: The 'model' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml(2,1): Error RZ2001: The 'model' directive may only occur once per document. diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.ir.txt index d8bb1d6d9d..a1ef9941e3 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MultipleModels_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MultipleModels - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.mappings.txt index 65348abd7b..ff5971643c 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.mappings.txt @@ -1,10 +1,10 @@ Source Location: (7:0,7 [21] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml) |ThisShouldBeGenerated| -Generated Location: (695:18,0 [21] ) +Generated Location: (688:18,0 [21] ) |ThisShouldBeGenerated| Source Location: (37:1,7 [30] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml) |System.Collections.IEnumerable| -Generated Location: (825:22,0 [30] ) +Generated Location: (818:22,0 [30] ) |System.Collections.IEnumerable| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs index fd3c971a71..604b3f412a 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { private global::InputTestTagHelper __InputTestTagHelper; #pragma warning disable 219 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt index 7ab3c05edd..515e48bee6 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DefaultTagHelperRuntime - FieldDeclaration - - private - global::InputTestTagHelper - __InputTestTagHelper DesignTimeDirective - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt index 5e120c830d..4eb221e12b 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt @@ -1,29 +1,29 @@ Source Location: (7:0,7 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) |DateTime| -Generated Location: (742:19,0 [8] ) +Generated Location: (735:19,0 [8] ) |DateTime| Source Location: (33:2,14 [29] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) |"InputTestTagHelper, AppCode"| -Generated Location: (883:23,37 [29] ) +Generated Location: (876:23,37 [29] ) |"InputTestTagHelper, AppCode"| Source Location: (152:10,9 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) |Section1| -Generated Location: (997:27,22 [8] ) +Generated Location: (990:27,22 [8] ) |Section1| Source Location: (68:4,2 [46] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) | Layout = "_SectionTestLayout.cshtml"; | -Generated Location: (1432:39,2 [46] ) +Generated Location: (1425:39,2 [46] ) | Layout = "_SectionTestLayout.cshtml"; | Source Location: (222:12,21 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) |Date| -Generated Location: (1857:47,102 [4] ) +Generated Location: (1850:47,102 [4] ) |Date| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.codegen.cs index 3e793c429e..1cd38d3029 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.codegen.cs @@ -11,10 +11,10 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { private global::AllTagHelper __AllTagHelper; - private global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml.__Generated__TestViewComponentTagHelper __TestViewComponentTagHelper; + private global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper __TestViewComponentTagHelper; #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { ((System.Action)(() => { @@ -36,7 +36,7 @@ global::System.Object __typeHelper = "*, AppCode"; #line default #line hidden __AllTagHelper = CreateTagHelper(); - __TestViewComponentTagHelper = CreateTagHelper(); + __TestViewComponentTagHelper = CreateTagHelper(); #line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml" __o = foo; diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.ir.txt index c3f1fcf05d..328b11876d 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.ir.txt @@ -8,10 +8,10 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DefaultTagHelperRuntime - FieldDeclaration - - private - global::AllTagHelper - __AllTagHelper - FieldDeclaration - - private - global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml.__Generated__TestViewComponentTagHelper - __TestViewComponentTagHelper + FieldDeclaration - - private - global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper - __TestViewComponentTagHelper DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html @@ -41,7 +41,7 @@ Document - TagHelper - (61:5,0 [50] ViewComponentTagHelper.cshtml) - vc:test - TagMode.StartTagAndEndTag DefaultTagHelperBody - DefaultTagHelperCreate - - AllTagHelper - DefaultTagHelperCreate - - AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml.__Generated__TestViewComponentTagHelper + DefaultTagHelperCreate - - AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper DefaultTagHelperProperty - (82:5,21 [4] ViewComponentTagHelper.cshtml) - first-name - string TestViewComponentTagHelper.firstName - HtmlAttributeValueStyle.DoubleQuotes CSharpExpression - (83:5,22 [3] ViewComponentTagHelper.cshtml) IntermediateToken - (83:5,22 [3] ViewComponentTagHelper.cshtml) - CSharp - foo diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.mappings.txt index 9344e08ed2..dcc0a00913 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.mappings.txt @@ -1,19 +1,19 @@ Source Location: (14:0,14 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml) |"*, AppCode"| -Generated Location: (973:20,37 [12] ) +Generated Location: (959:20,37 [12] ) |"*, AppCode"| Source Location: (30:1,2 [26] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml) | var foo = "Hello"; | -Generated Location: (1419:32,2 [26] ) +Generated Location: (1405:32,2 [26] ) | var foo = "Hello"; | Source Location: (83:5,22 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml) |foo| -Generated Location: (1877:40,22 [3] ) +Generated Location: (1856:40,22 [3] ) |foo| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.codegen.cs index 2e09a42013..6bc3c83d01 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.ir.txt index d2def8694a..f75113d4b6 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.mappings.txt index 287d4e0c05..a418264123 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.mappings.txt @@ -1,10 +1,10 @@ Source Location: (8:0,8 [19] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml) |IHtmlHelper| -Generated Location: (679:18,0 [19] ) +Generated Location: (672:18,0 [19] ) |IHtmlHelper| Source Location: (28:0,28 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml) |Helper| -Generated Location: (827:22,22 [6] ) +Generated Location: (820:22,22 [6] ) |Helper| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/ViewComponentTagHelperPassTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/ViewComponentTagHelperPassTest.cs index 8200131bbf..8374009cc5 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/ViewComponentTagHelperPassTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/ViewComponentTagHelperPassTest.cs @@ -79,7 +79,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X var irDocument = CreateIRDocument(engine, codeDocument); - var vcthFullName = "AspNetCore.test_cshtml.__Generated__TagCloudViewComponentTagHelper"; + var vcthFullName = "AspNetCore.test.__Generated__TagCloudViewComponentTagHelper"; // Act pass.Execute(codeDocument, irDocument); @@ -126,7 +126,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X var irDocument = CreateIRDocument(engine, codeDocument); - var vcthFullName = "AspNetCore.test_cshtml.__Generated__TagCloudViewComponentTagHelper"; + var vcthFullName = "AspNetCore.test.__Generated__TagCloudViewComponentTagHelper"; // Act pass.Execute(codeDocument, irDocument); @@ -179,7 +179,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X var irDocument = CreateIRDocument(engine, codeDocument); - var vcthFullName = "AspNetCore.test_cshtml.__Generated__TagCloudViewComponentTagHelper"; + var vcthFullName = "AspNetCore.test.__Generated__TagCloudViewComponentTagHelper"; // Act pass.Execute(codeDocument, irDocument); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/DefaultDocumentWriterTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/DefaultDocumentWriterTest.cs index 74d48a1f8d..99678f74b6 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/DefaultDocumentWriterTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/DefaultDocumentWriterTest.cs @@ -1,16 +1,18 @@ // 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.Collections.Generic; using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Moq; using Xunit; namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration { public class DefaultDocumentWriterTest { - [Fact] - public void WriteDocument_Empty_WritesChecksumAndMarksAutoGenerated() + [Fact] // This test covers the whole process including actual hashing. + public void WriteDocument_EndToEnd_WritesChecksumAndMarksAutoGenerated() { // Arrange var document = new DocumentIntermediateNode(); @@ -36,6 +38,106 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration ignoreLineEndingDifferences: true); } + [Fact] + public void WriteDocument_SHA1_WritesChecksumAndMarksAutoGenerated() + { + // Arrange + var checksumBytes = new byte[] { (byte)'t', (byte)'e', (byte)'s', (byte)'t', }; + + var sourceDocument = Mock.Of(d => + d.FilePath == "test.cshtml" && + d.GetChecksum() == checksumBytes && + d.GetChecksumAlgorithm() == "SHA1"); + + var document = new DocumentIntermediateNode(); + + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var options = RazorCodeGenerationOptions.CreateDefault(); + + var target = CodeTarget.CreateDefault(codeDocument, options); + var writer = new DefaultDocumentWriter(target, options); + + // Act + var result = writer.WriteDocument(codeDocument, document); + + // Assert + var csharp = result.GeneratedCode; + Assert.Equal( +@"#pragma checksum ""test.cshtml"" ""{ff1816ec-aa5e-4d10-87f7-6f4963833460}"" ""74657374"" +// +#pragma warning disable 1591 +#pragma warning restore 1591 +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteDocument_SHA256_WritesChecksumAndMarksAutoGenerated() + { + // Arrange + var checksumBytes = new byte[] { (byte)'t', (byte)'e', (byte)'s', (byte)'t', }; + + var sourceDocument = Mock.Of(d => + d.FilePath == "test.cshtml" && + d.GetChecksum() == checksumBytes && + d.GetChecksumAlgorithm() == "SHA256"); + + var document = new DocumentIntermediateNode(); + + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var options = RazorCodeGenerationOptions.CreateDefault(); + + var target = CodeTarget.CreateDefault(codeDocument, options); + var writer = new DefaultDocumentWriter(target, options); + + // Act + var result = writer.WriteDocument(codeDocument, document); + + // Assert + var csharp = result.GeneratedCode; + Assert.Equal( +@"#pragma checksum ""test.cshtml"" ""{8829d00f-11b8-4213-878b-770e8597ac16}"" ""74657374"" +// +#pragma warning disable 1591 +#pragma warning restore 1591 +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteDocument_UnsupportedChecksumAlgorithm_Throws() + { + // Arrange + var checksumBytes = new byte[] { (byte)'t', (byte)'e', (byte)'s', (byte)'t', }; + + var sourceDocument = Mock.Of(d => + d.FilePath == "test.cshtml" && + d.GetChecksum() == checksumBytes && + d.GetChecksumAlgorithm() == "SHA3"); + + var document = new DocumentIntermediateNode(); + + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var options = RazorCodeGenerationOptions.CreateDefault(); + + var target = CodeTarget.CreateDefault(codeDocument, options); + var writer = new DefaultDocumentWriter(target, options); + + // Act & Assert + var exception = Assert.Throws(() => + { + var result = writer.WriteDocument(codeDocument, document); + }); + Assert.Equal( + "The hash algorithm 'SHA3' is not supported for checksum generation. Supported algorithms are: 'SHA1 SHA256'. " + + "Set 'RazorCodeGenerationOptions.SuppressChecksum' to 'True' to suppress automatic checksum generation.", + exception.Message); + } + + + [Fact] public void WriteDocument_Empty_SuppressChecksumTrue_DoesnotWriteChecksum() { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorIntermediateNodeLoweringPhaseTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorIntermediateNodeLoweringPhaseTest.cs index 1288b1b127..bb53e69947 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorIntermediateNodeLoweringPhaseTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorIntermediateNodeLoweringPhaseTest.cs @@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.Razor.Language b.AddDirective(directive); }); var options = RazorParserOptions.Create(builder => builder.Directives.Add(directive)); - var importSource = TestRazorSourceDocument.Create("@custom \"hello\"", fileName: "import.cshtml"); + var importSource = TestRazorSourceDocument.Create("@custom \"hello\"", filePath: "import.cshtml"); var codeDocument = TestRazorCodeDocument.Create("

NonDirective

"); codeDocument.SetSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source, options)); codeDocument.SetImportSyntaxTrees(new[] { RazorSyntaxTree.Parse(importSource, options) }); @@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore.Razor.Language b.AddDirective(directive); }); var options = RazorParserOptions.Create(builder => builder.Directives.Add(directive)); - var importSource = TestRazorSourceDocument.Create("@custom \"hello\"", fileName: "import.cshtml"); + var importSource = TestRazorSourceDocument.Create("@custom \"hello\"", filePath: "import.cshtml"); var codeDocument = TestRazorCodeDocument.Create("@custom \"world\""); codeDocument.SetSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source, options)); codeDocument.SetImportSyntaxTrees(new[] { RazorSyntaxTree.Parse(importSource, options) }); @@ -100,8 +100,8 @@ namespace Microsoft.AspNetCore.Razor.Language b.AddDirective(directive); }); var options = RazorParserOptions.Create(builder => builder.Directives.Add(directive)); - var importSource1 = TestRazorSourceDocument.Create("@custom \"hello\"", fileName: "import1.cshtml"); - var importSource2 = TestRazorSourceDocument.Create("@custom \"world\"", fileName: "import2.cshtml"); + var importSource1 = TestRazorSourceDocument.Create("@custom \"hello\"", filePath: "import1.cshtml"); + var importSource2 = TestRazorSourceDocument.Create("@custom \"world\"", filePath: "import2.cshtml"); var codeDocument = TestRazorCodeDocument.Create("

NonDirective

"); codeDocument.SetSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source, options)); codeDocument.SetImportSyntaxTrees(new[] { RazorSyntaxTree.Parse(importSource1, options), RazorSyntaxTree.Parse(importSource2, options) }); @@ -139,7 +139,7 @@ namespace Microsoft.AspNetCore.Razor.Language var importSource = TestRazorSourceDocument.Create( @"@code ""code block"" { } @razor ""razor block"" { }", - fileName: "testImports.cshtml"); + filePath: "testImports.cshtml"); var codeDocument = TestRazorCodeDocument.Create("

NonDirective

"); codeDocument.SetSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source, options)); codeDocument.SetImportSyntaxTrees(new[] { RazorSyntaxTree.Parse(importSource, options) }); @@ -166,7 +166,7 @@ namespace Microsoft.AspNetCore.Razor.Language b.AddDirective(directive); }); var options = RazorParserOptions.Create(builder => builder.Directives.Add(directive)); - var importSource = TestRazorSourceDocument.Create("@custom { }", fileName: "import.cshtml"); + var importSource = TestRazorSourceDocument.Create("@custom { }", filePath: "import.cshtml"); var codeDocument = TestRazorCodeDocument.Create("

NonDirective

"); codeDocument.SetSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source, options)); codeDocument.SetImportSyntaxTrees(new[] { RazorSyntaxTree.Parse(importSource, options) }); @@ -196,7 +196,7 @@ namespace Microsoft.AspNetCore.Razor.Language b.AddDirective(directive); }); var options = RazorParserOptions.Create(builder => builder.Directives.Add(directive)); - var importSource = TestRazorSourceDocument.Create("@custom { }", fileName: "import.cshtml"); + var importSource = TestRazorSourceDocument.Create("@custom { }", filePath: "import.cshtml"); var codeDocument = TestRazorCodeDocument.Create("

NonDirective

"); codeDocument.SetSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source, options)); codeDocument.SetImportSyntaxTrees(new[] { RazorSyntaxTree.Parse(importSource, options) }); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineBuilderTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineBuilderTest.cs new file mode 100644 index 0000000000..5323ba3ffa --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineBuilderTest.cs @@ -0,0 +1,65 @@ +// 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.Linq; +using Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DefaultRazorProjectEngineBuilderTest + { + [Fact] + public void Build_AddsFeaturesToRazorEngine() + { + // Arrange + var builder = new DefaultRazorProjectEngineBuilder(RazorConfiguration.Default, Mock.Of()); + builder.Features.Add(Mock.Of()); + builder.Features.Add(Mock.Of()); + builder.Features.Add(Mock.Of()); + + var features = builder.Features.ToArray(); + + // Act + var projectEngine = builder.Build(); + + // Assert + Assert.Collection(projectEngine.Engine.Features, + feature => Assert.Same(features[0], feature), + feature => Assert.Same(features[1], feature)); + } + + [Fact] + public void Build_AddsPhasesToRazorEngine() + { + // Arrange + var builder = new DefaultRazorProjectEngineBuilder(RazorConfiguration.Default, Mock.Of()); + builder.Phases.Add(Mock.Of()); + builder.Phases.Add(Mock.Of()); + + var phases = builder.Phases.ToArray(); + + // Act + var projectEngine = builder.Build(); + + // Assert + Assert.Collection(projectEngine.Engine.Phases, + phase => Assert.Same(phases[0], phase), + phase => Assert.Same(phases[1], phase)); + } + + [Fact] + public void Build_CreatesProjectEngineWithFileSystem() + { + // Arrange + var fileSystem = Mock.Of(); + var builder = new DefaultRazorProjectEngineBuilder(RazorConfiguration.Default, fileSystem); + + // Act + var projectEngine = builder.Build(); + + // Assert + Assert.Same(fileSystem, projectEngine.FileSystem); + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineIntegrationTest.cs new file mode 100644 index 0000000000..427b34c1b6 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineIntegrationTest.cs @@ -0,0 +1,95 @@ +// 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 Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DefaultRazorProjectEngineIntegrationTest + { + [Fact] + public void Process_SetsOptions_Runtime() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.Process(projectItem); + + // Assert + var parserOptions = codeDocument.GetParserOptions(); + Assert.False(parserOptions.DesignTime); + + var codeGenerationOptions = codeDocument.GetCodeGenerationOptions(); + Assert.False(codeGenerationOptions.DesignTime); + Assert.False(codeGenerationOptions.SuppressChecksum); + Assert.False(codeGenerationOptions.SuppressMetadataAttributes); + } + + [Fact] + public void ProcessDesignTime_SetsOptions_DesignTime() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.ProcessDesignTime(projectItem); + + // Assert + var parserOptions = codeDocument.GetParserOptions(); + Assert.True(parserOptions.DesignTime); + + var codeGenerationOptions = codeDocument.GetCodeGenerationOptions(); + Assert.True(codeGenerationOptions.DesignTime); + Assert.True(codeGenerationOptions.SuppressChecksum); + Assert.True(codeGenerationOptions.SuppressMetadataAttributes); + } + + [Fact] + public void Process_GetsImportsFromFeature() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + + var testImport = Mock.Of(i => i.Read() == new MemoryStream() && i.FilePath == "testvalue"); + var importFeature = new Mock(); + importFeature + .Setup(feature => feature.GetImports(It.IsAny())) + .Returns(new[] { testImport }); + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty, builder => + { + builder.SetImportFeature(importFeature.Object); + }); + + // Act + var codeDocument = projectEngine.Process(projectItem); + + // Assert + var import = Assert.Single(codeDocument.Imports); + Assert.Equal("testvalue", import.FilePath); + } + + [Fact] + public void Process_GeneratesCodeDocumentWithValidCSharpDocument() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.Process(projectItem); + + // Assert + var csharpDocument = codeDocument.GetCSharpDocument(); + Assert.NotNull(csharpDocument); + Assert.Empty(csharpDocument.Diagnostics); + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineTest.cs new file mode 100644 index 0000000000..171556ecf0 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineTest.cs @@ -0,0 +1,37 @@ +// 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 Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DefaultRazorProjectEngineTest + { + [Fact] + public void ConvertToSourceDocument_ConvertsNormalImports() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + + // Act + var sourceDocument = DefaultRazorProjectEngine.ConvertToSourceDocument(projectItem); + + // Assert + Assert.NotNull(sourceDocument); + } + + [Fact] + public void ConvertToSourceDocument_ConvertsMarkerImports() + { + // Arrange + var projectItem = Mock.Of(item => item.FilePath == "Index.cshtml" && item.Exists == false); + + // Act + var sourceDocument = DefaultRazorProjectEngine.ConvertToSourceDocument(projectItem); + + // Assert + Assert.NotNull(sourceDocument); + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectFileSystemTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectFileSystemTest.cs new file mode 100644 index 0000000000..af48d1e900 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectFileSystemTest.cs @@ -0,0 +1,263 @@ +// 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.Linq; +using Microsoft.AspNetCore.Testing; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DefaultRazorProjectFileSystemTest + { + private static string TestFolder { get; } = Path.Combine( + TestProject.GetProjectDirectory(typeof(DefaultRazorProjectFileSystemTest)), + "TestFiles", + "DefaultRazorProjectFileSystem"); + + [Theory] + [InlineData(null)] + [InlineData("")] + public void NormalizeAndEnsureValidPath_ThrowsIfPathIsNullOrEmpty(string path) + { + // Arrange + var fileSystem = new TestRazorProjectFileSystem("C:/some/test/path/root"); + + // Act and Assert + ExceptionAssert.ThrowsArgumentNullOrEmptyString(() => fileSystem.NormalizeAndEnsureValidPath(path), "path"); + } + + [Fact] + public void NormalizeAndEnsureValidPath_NormalizesToAbsolutePath() + { + // Arrange + var fileSystem = new TestRazorProjectFileSystem("C:/some/test/path/root"); + + // Act + var absolutePath = fileSystem.NormalizeAndEnsureValidPath("file.cshtml"); + + // Assert + Assert.Equal("C:/some/test/path/root/file.cshtml", absolutePath); + } + + [Fact] + public void NormalizeAndEnsureValidPath_NormalizesToAbsolutePathWithoutForwardSlash() + { + // Arrange + var fileSystem = new TestRazorProjectFileSystem("C:/some/test/path/root"); + + // Act + var absolutePath = fileSystem.NormalizeAndEnsureValidPath("/file.cshtml"); + + // Assert + Assert.Equal("C:/some/test/path/root/file.cshtml", absolutePath); + } + + [Fact] + public void NormalizeAndEnsureValidPath_NormalizesToForwardSlashes() + { + // Arrange + var fileSystem = new TestRazorProjectFileSystem(@"C:\some\test\path\root"); + + // Act + var absolutePath = fileSystem.NormalizeAndEnsureValidPath(@"something\file.cshtml"); + + // Assert + Assert.Equal("C:/some/test/path/root/something/file.cshtml", absolutePath); + } + + [Fact] + public void EnumerateItems_DiscoversAllCshtmlFiles() + { + // Arrange + var fileSystem = new DefaultRazorProjectFileSystem(TestFolder); + + // Act + var items = fileSystem.EnumerateItems("/"); + + // Assert + Assert.Collection( + items.OrderBy(f => f.FilePath), + item => + { + Assert.Equal("/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal("_ViewImports.cshtml", item.RelativePhysicalPath); + + }, + item => + { + Assert.Equal("/Home.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Home.cshtml"), item.PhysicalPath); + Assert.Equal("Home.cshtml", item.RelativePhysicalPath); + + }, + item => + { + Assert.Equal("/Views/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Views", "_ViewImports.cshtml"), item.RelativePhysicalPath); + + }, + item => + { + Assert.Equal("/Views/About/About.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "About", "About.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Views", "About", "About.cshtml"), item.RelativePhysicalPath); + }, + item => + { + Assert.Equal("/Views/Home/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "Home", "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Views", "Home", "_ViewImports.cshtml"), item.RelativePhysicalPath); + + }, + item => + { + Assert.Equal("/Views/Home/Index.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "Home", "Index.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Views", "Home", "Index.cshtml"), item.RelativePhysicalPath); + }); + } + + [Fact] + public void EnumerateItems_DiscoversAllCshtmlFiles_UnderSpecifiedBasePath() + { + // Arrange + var fileSystem = new DefaultRazorProjectFileSystem(TestFolder); + + // Act + var items = fileSystem.EnumerateItems("/Views"); + + // Assert + Assert.Collection( + items.OrderBy(f => f.FilePath), + item => + { + Assert.Equal("/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/Views", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("_ViewImports.cshtml"), item.RelativePhysicalPath); + }, + item => + { + Assert.Equal("/About/About.cshtml", item.FilePath); + Assert.Equal("/Views", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "About", "About.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("About", "About.cshtml"), item.RelativePhysicalPath); + }, + item => + { + Assert.Equal("/Home/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/Views", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "Home", "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Home", "_ViewImports.cshtml"), item.RelativePhysicalPath); + }, + item => + { + Assert.Equal("/Home/Index.cshtml", item.FilePath); + Assert.Equal("/Views", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "Home", "Index.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Home", "Index.cshtml"), item.RelativePhysicalPath); + }); + } + + [Fact] + public void EnumerateItems_ReturnsEmptySequence_WhenBasePathDoesNotExist() + { + // Arrange + var fileSystem = new DefaultRazorProjectFileSystem(TestFolder); + + // Act + var items = fileSystem.EnumerateItems("/Does-Not-Exist"); + + // Assert + Assert.Empty(items); + } + + [Fact] + public void FindHierarchicalItems_FindsItemsWithMatchingNames() + { + // Arrange + var fileSystem = new DefaultRazorProjectFileSystem(TestFolder); + + // Act + var items = fileSystem.FindHierarchicalItems("/Views/Home/Index.cshtml", "_ViewImports.cshtml"); + + // Assert + Assert.Collection( + items, + item => + { + Assert.Equal("/Views/Home/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "Home", "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Views", "Home", "_ViewImports.cshtml"), item.RelativePhysicalPath); + + }, + item => + { + Assert.Equal("/Views/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Views", "_ViewImports.cshtml"), item.RelativePhysicalPath); + + }, + item => + { + Assert.Equal("/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal("_ViewImports.cshtml", item.RelativePhysicalPath); + + }); + } + + [Fact] + public void GetItem_ReturnsFileFromDisk() + { + // Arrange + var filePath = "/Views/About/About.cshtml"; + var fileSystem = new DefaultRazorProjectFileSystem(TestFolder); + + // Act + var item = fileSystem.GetItem(filePath); + + // Assert + Assert.True(item.Exists); + Assert.Equal(filePath, item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "About", "About.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Views", "About", "About.cshtml"), item.RelativePhysicalPath); + } + + [Fact] + public void GetItem_ReturnsNotFoundResult() + { + // Arrange + var path = "/NotFound.cshtml"; + var fileSystem = new DefaultRazorProjectFileSystem(TestFolder); + + // Act + var item = fileSystem.GetItem(path); + + // Assert + Assert.False(item.Exists); + } + + private class TestRazorProjectFileSystem : DefaultRazorProjectFileSystem + { + public TestRazorProjectFileSystem(string root) : base(root) + { + } + + public new string NormalizeAndEnsureValidPath(string path) => base.NormalizeAndEnsureValidPath(path); + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/FileSystemRazorProjectItemTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectItemTest.cs similarity index 65% rename from test/Microsoft.AspNetCore.Razor.Language.Test/FileSystemRazorProjectItemTest.cs rename to test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectItemTest.cs index 638d898e0d..1fa4453bd3 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/FileSystemRazorProjectItemTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectItemTest.cs @@ -6,28 +6,29 @@ using Xunit; namespace Microsoft.AspNetCore.Razor.Language { - public class FileSystemRazorProjectItemTest + public class DefaultRazorProjectItemTest { private static string TestFolder { get; } = Path.Combine( - TestProject.GetProjectDirectory(typeof(FileSystemRazorProjectItemTest)), - "TestFiles", - "FileSystemRazorProject"); + TestProject.GetProjectDirectory(typeof(DefaultRazorProjectItemTest)), + "TestFiles", + "DefaultRazorProjectFileSystem"); [Fact] - public void FileSystemRazorProjectItem_SetsProperties() + public void DefaultRazorProjectItem_SetsProperties() { // Arrange var fileInfo = new FileInfo(Path.Combine(TestFolder, "Home.cshtml")); // Act - var projectItem = new FileSystemRazorProjectItem("/Views", "/Home.cshtml", fileInfo); + var projectItem = new DefaultRazorProjectItem("/", "/Home.cshtml", "Home.cshtml", fileInfo); // Assert Assert.Equal("/Home.cshtml", projectItem.FilePath); - Assert.Equal("/Views", projectItem.BasePath); + Assert.Equal("/", projectItem.BasePath); Assert.True(projectItem.Exists); Assert.Equal("Home.cshtml", projectItem.FileName); Assert.Equal(fileInfo.FullName, projectItem.PhysicalPath); + Assert.Equal("Home.cshtml", projectItem.RelativePhysicalPath); } [Fact] @@ -37,7 +38,7 @@ namespace Microsoft.AspNetCore.Razor.Language var fileInfo = new FileInfo(Path.Combine(TestFolder, "Views", "FileDoesNotExist.cshtml")); // Act - var projectItem = new FileSystemRazorProjectItem("/Views", "/FileDoesNotExist.cshtml", fileInfo); + var projectItem = new DefaultRazorProjectItem("/Views", "/FileDoesNotExist.cshtml", Path.Combine("Views", "FileDoesNotExist.cshtml"), fileInfo); // Assert Assert.False(projectItem.Exists); @@ -48,7 +49,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var fileInfo = new FileInfo(Path.Combine(TestFolder, "Home.cshtml")); - var projectItem = new FileSystemRazorProjectItem("/", "/Home.cshtml", fileInfo); + var projectItem = new DefaultRazorProjectItem("/", "/Home.cshtml", "Home.cshtml", fileInfo); // Act var stream = projectItem.Read(); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorTagHelperBinderPhaseTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorTagHelperBinderPhaseTest.cs index 968c12bde7..d4fd3c1910 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorTagHelperBinderPhaseTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorTagHelperBinderPhaseTest.cs @@ -27,22 +27,16 @@ namespace Microsoft.AspNetCore.Razor.Language }; var expectedDiagnostics = new[] { - RazorDiagnostic.Create( - new RazorError( - LegacyResources.ParseError_Unterminated_String_Literal, - new SourceLocation(14 + Environment.NewLine.Length, 1, 14), - length: 1)), - RazorDiagnostic.Create( - new RazorError( - Resources.FormatInvalidTagHelperLookupText("\""), - new SourceLocation(14 + Environment.NewLine.Length, 1, 14), - length: 1)) + RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( + new SourceSpan(new SourceLocation(14 + Environment.NewLine.Length, 1, 14), contentLength: 1)), + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(14 + Environment.NewLine.Length, 1, 14), contentLength: 1), "\"") }; var content = @" @addTagHelper """; - var sourceDocument = TestRazorSourceDocument.Create(content, fileName: null); + var sourceDocument = TestRazorSourceDocument.Create(content, filePath: null); var codeDocument = RazorCodeDocument.Create(sourceDocument); var originalTree = RazorSyntaxTree.Parse(sourceDocument); codeDocument.SetSyntaxTree(originalTree); @@ -72,22 +66,16 @@ namespace Microsoft.AspNetCore.Razor.Language }; var expectedDiagnostics = new[] { - RazorDiagnostic.Create( - new RazorError( - LegacyResources.ParseError_Unterminated_String_Literal, - new SourceLocation(17 + Environment.NewLine.Length, 1, 17), - length: 1)), - RazorDiagnostic.Create( - new RazorError( - Resources.FormatInvalidTagHelperLookupText("\""), - new SourceLocation(17 + Environment.NewLine.Length, 1, 17), - length: 1)) + RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( + new SourceSpan(new SourceLocation(17 + Environment.NewLine.Length, 1, 17), contentLength: 1)), + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(17 + Environment.NewLine.Length, 1, 17), contentLength: 1), "\"") }; var content = @" @removeTagHelper """; - var sourceDocument = TestRazorSourceDocument.Create(content, fileName: null); + var sourceDocument = TestRazorSourceDocument.Create(content, filePath: null); var codeDocument = RazorCodeDocument.Create(sourceDocument); var originalTree = RazorSyntaxTree.Parse(sourceDocument); codeDocument.SetSyntaxTree(originalTree); @@ -117,22 +105,16 @@ namespace Microsoft.AspNetCore.Razor.Language }; var expectedDiagnostics = new[] { - RazorDiagnostic.Create( - new RazorError( - LegacyResources.ParseError_Unterminated_String_Literal, - new SourceLocation(17 + Environment.NewLine.Length, 1, 17), - length: 1)), - RazorDiagnostic.Create( - new RazorError( - Resources.FormatInvalidTagHelperPrefixValue("tagHelperPrefix", "\"", "\""), - new SourceLocation(17 + Environment.NewLine.Length, 1, 17), - length: 1)) + RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( + new SourceSpan(new SourceLocation(17 + Environment.NewLine.Length, 1, 17), contentLength: 1)), + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperPrefixValue( + new SourceSpan(new SourceLocation(17 + Environment.NewLine.Length, 1, 17), contentLength: 1), "tagHelperPrefix", '\"', "\""), }; var content = @" @tagHelperPrefix """; - var sourceDocument = TestRazorSourceDocument.Create(content, fileName: null); + var sourceDocument = TestRazorSourceDocument.Create(content, filePath: null); var codeDocument = RazorCodeDocument.Create(sourceDocument); var originalTree = RazorSyntaxTree.Parse(sourceDocument); codeDocument.SetSyntaxTree(originalTree); @@ -431,17 +413,16 @@ namespace Microsoft.AspNetCore.Razor.Language @addTagHelper *, TestAssembly
"; - var sourceDocument = TestRazorSourceDocument.Create(content, fileName: null); + var sourceDocument = TestRazorSourceDocument.Create(content, filePath: null); var codeDocument = RazorCodeDocument.Create(sourceDocument); var originalTree = RazorSyntaxTree.Parse(sourceDocument); - var initialError = RazorDiagnostic.Create(new RazorError("Initial test error", SourceLocation.Zero, length: 1)); - var expectedRewritingError = RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatTagHelpersParseTreeRewriter_FoundMalformedTagHelper("form"), - new SourceLocation(Environment.NewLine.Length * 2 + 30, 2, 1), - length: 4)); + var initialError = RazorDiagnostic.Create( + new RazorDiagnosticDescriptor("RZ9999", () => "Initial test error", RazorDiagnosticSeverity.Error), + new SourceSpan(SourceLocation.Zero, contentLength: 1)); + var expectedRewritingError = RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(new SourceLocation(Environment.NewLine.Length * 2 + 30, 2, 1), contentLength: 4), "form"); var erroredOriginalTree = RazorSyntaxTree.Create(originalTree.Root, originalTree.Source, new[] { initialError }, originalTree.Options); codeDocument.SetSyntaxTree(erroredOriginalTree); @@ -559,7 +540,7 @@ namespace Microsoft.AspNetCore.Razor.Language string expectedPrefix) { // Arrange - var sourceDocument = TestRazorSourceDocument.Create(source, fileName: "TestFile"); + var sourceDocument = TestRazorSourceDocument.Create(source, filePath: "TestFile"); var parser = new RazorParser(); var syntaxTree = parser.Parse(sourceDocument); var visitor = new DefaultRazorTagHelperBinderPhase.DirectiveVisitor(tagHelpers: new List()); @@ -725,7 +706,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var expected = (TagHelperDescriptor[])expectedDescriptors; - var sourceDocument = TestRazorSourceDocument.Create(source, fileName: "TestFile"); + var sourceDocument = TestRazorSourceDocument.Create(source, filePath: "TestFile"); var parser = new RazorParser(); var syntaxTree = parser.Parse(sourceDocument); var visitor = new DefaultRazorTagHelperBinderPhase.DirectiveVisitor((TagHelperDescriptor[])tagHelpers); @@ -869,7 +850,7 @@ namespace Microsoft.AspNetCore.Razor.Language object tagHelpers) { // Arrange - var sourceDocument = TestRazorSourceDocument.Create(source, fileName: "TestFile"); + var sourceDocument = TestRazorSourceDocument.Create(source, filePath: "TestFile"); var parser = new RazorParser(); var syntaxTree = parser.Parse(sourceDocument); var visitor = new DefaultRazorTagHelperBinderPhase.DirectiveVisitor((TagHelperDescriptor[])tagHelpers); @@ -904,7 +885,7 @@ namespace Microsoft.AspNetCore.Razor.Language "; - var sourceDocument = TestRazorSourceDocument.Create(content, fileName: null); + var sourceDocument = TestRazorSourceDocument.Create(content, filePath: null); return sourceDocument; } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/DefaultMetadataIdentifierFeatureTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/DefaultMetadataIdentifierFeatureTest.cs new file mode 100644 index 0000000000..38ea7f32c3 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/DefaultMetadataIdentifierFeatureTest.cs @@ -0,0 +1,72 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Extensions +{ + public class DefaultMetadataIdentifierFeatureTest + { + [Fact] + public void GetIdentifier_ReturnsNull_ForNullRelativePath() + { + // Arrange + var sourceDocument = RazorSourceDocument.Create("content", new RazorSourceDocumentProperties("Test.cshtml", null)); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var feature = new DefaultMetadataIdentifierFeature() + { + Engine = RazorEngine.Create(), + }; + + // Act + var result = feature.GetIdentifier(codeDocument, sourceDocument); + + // Assert + Assert.Null(result); + } + + [Fact] + public void GetIdentifier_ReturnsNull_ForEmptyRelativePath() + { + // Arrange + var sourceDocument = RazorSourceDocument.Create("content", new RazorSourceDocumentProperties("Test.cshtml", string.Empty)); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var feature = new DefaultMetadataIdentifierFeature() + { + Engine = RazorEngine.Create(), + }; + + // Act + var result = feature.GetIdentifier(codeDocument, sourceDocument); + + // Assert + Assert.Null(result); + } + + [Theory] + [InlineData("Test.cshtml", "/Test.cshtml")] + [InlineData("/Test.cshtml", "/Test.cshtml")] + [InlineData("\\Test.cshtml", "/Test.cshtml")] + [InlineData("\\About\\Test.cshtml", "/About/Test.cshtml")] + [InlineData("\\About\\Test\\cshtml", "/About/Test/cshtml")] + public void GetIdentifier_SanitizesRelativePath(string relativePath, string expected) + { + // Arrange + var sourceDocument = RazorSourceDocument.Create("content", new RazorSourceDocumentProperties("Test.cshtml", relativePath)); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var feature = new DefaultMetadataIdentifierFeature() + { + Engine = RazorEngine.Create(), + }; + + // Act + var result = feature.GetIdentifier(codeDocument, sourceDocument); + + // Assert + Assert.Equal(expected, result); + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/DefaultTagHelperTargetExtensionTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/DefaultTagHelperTargetExtensionTest.cs index 79aba5837c..dcb8d6d6ff 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/DefaultTagHelperTargetExtensionTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/DefaultTagHelperTargetExtensionTest.cs @@ -68,7 +68,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions public void WriteTagHelperBody_DesignTime_WritesChildren() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -133,7 +133,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions public void WriteTagHelperCreate_DesignTime_RendersCorrectly_UsesSpecifiedTagHelperType() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -190,7 +190,7 @@ __tagHelperExecutionContext.Add(__TestNamespace_MyTagHelper); public void WriteTagHelperExecute_DesignTime_WritesNothing() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -243,7 +243,7 @@ __tagHelperExecutionContext = __tagHelperScopeManager.End(); public void WriteTagHelperHtmlAttribute_DesignTime_WritesNothing() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -359,11 +359,79 @@ EndAddHtmlAttributeValues(__tagHelperExecutionContext); ignoreLineEndingDifferences: true); } + [Fact] + public void RenderTagHelperAttributeInline_NonString_StatementInAttribute_Errors() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + var node = new DefaultTagHelperPropertyIntermediateNode() + { + BoundAttribute = IntPropertyTagHelper.BoundAttributes.Single(), + IsIndexerNameMatch = false, + }; + var expectedLocation = new SourceSpan(100, 10); + var expectedDiagnostic = RazorDiagnosticFactory.CreateTagHelper_CodeBlocksNotSupportedInAttributes(expectedLocation); + + // Act + extension.RenderTagHelperAttributeInline(context, node, new CSharpCodeIntermediateNode(), expectedLocation); + + // Assert + var diagnostic = Assert.Single(context.Diagnostics); + Assert.Equal(expectedDiagnostic, diagnostic); + } + + [Fact] + public void RenderTagHelperAttributeInline_NonStringIndexerMatch_TemplateInAttribute_Errors() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + var node = new DefaultTagHelperPropertyIntermediateNode() + { + BoundAttribute = IntIndexerTagHelper.BoundAttributes.Single(), + IsIndexerNameMatch = true, + }; + var expectedLocation = new SourceSpan(100, 10); + var expectedDiagnostic = RazorDiagnosticFactory.CreateTagHelper_InlineMarkupBlocksNotSupportedInAttributes(expectedLocation, "System.Int32"); + + // Act + extension.RenderTagHelperAttributeInline(context, node, new TemplateIntermediateNode(), expectedLocation); + + // Assert + var diagnostic = Assert.Single(context.Diagnostics); + Assert.Equal(expectedDiagnostic, diagnostic); + } + + [Fact] + public void RenderTagHelperAttributeInline_NonString_TemplateInAttribute_Errors() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + var node = new DefaultTagHelperPropertyIntermediateNode() + { + BoundAttribute = IntIndexerTagHelper.BoundAttributes.Single(), + IsIndexerNameMatch = false, + }; + var expectedLocation = new SourceSpan(100, 10); + var expectedDiagnostic = RazorDiagnosticFactory.CreateTagHelper_InlineMarkupBlocksNotSupportedInAttributes( + expectedLocation, + "System.Collections.Generic.Dictionary"); + + // Act + extension.RenderTagHelperAttributeInline(context, node, new TemplateIntermediateNode(), expectedLocation); + + // Assert + var diagnostic = Assert.Single(context.Diagnostics); + Assert.Equal(expectedDiagnostic, diagnostic); + } + [Fact] public void WriteTagHelperProperty_DesignTime_StringProperty_HtmlContent_RendersCorrectly() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -404,7 +472,7 @@ __InputTagHelper.StringProp = ""value""; public void WriteTagHelperProperty_DesignTime_StringProperty_NonHtmlContent_RendersCorrectly() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -445,7 +513,7 @@ __InputTagHelper.StringProp = string.Empty; public void WriteTagHelperProperty_DesignTime_NonStringProperty_RendersCorrectly() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -492,7 +560,7 @@ __InputTagHelper.IntProp = 32; public void WriteTagHelperProperty_DesignTime_NonStringProperty_SecondUseOfAttribute() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -534,7 +602,7 @@ __InputTagHelper.IntProp = 32; public void WriteTagHelperProperty_DesignTime_NonStringProperty_RendersCorrectly_WithoutLocation() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -574,7 +642,7 @@ __InputTagHelper.IntProp = 32; public void WriteTagHelperProperty_DesignTime_NonStringIndexer_RendersCorrectly() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -619,7 +687,7 @@ __InputTagHelper.IntIndexer[""bound""] = 32; public void WriteTagHelperProperty_DesignTime_NonStringIndexer_RendersCorrectly_WithoutLocation() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -996,7 +1064,7 @@ __tagHelperExecutionContext.AddTagHelperAttribute(""foo-bound"", __InputTagHelpe public void WriteTagHelperRuntime_DesignTime_WritesNothing() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var node = new DefaultTagHelperRuntimeIntermediateNode(); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/MetadataAttributePassTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/MetadataAttributePassTest.cs new file mode 100644 index 0000000000..05e54da54d --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/MetadataAttributePassTest.cs @@ -0,0 +1,362 @@ +// 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.Intermediate; +using Xunit; +using static Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNodeAssert; + +namespace Microsoft.AspNetCore.Razor.Language.Extensions +{ + public class MetadataAttributePassTest + { + [Fact] + public void Execute_NullCodeGenerationOptions_Noops() + { + // Arrange + var engine = CreateEngine(); + var pass = new MetadataAttributePass() + { + Engine = engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create(); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var irDocument = new DocumentIntermediateNode(); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + NoChildren(irDocument); + } + + [Fact] + public void Execute_SuppressMetadataAttributes_Noops() + { + // Arrange + var engine = CreateEngine(); + var pass = new MetadataAttributePass() + { + Engine = engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create(); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var irDocument = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.Create(o => + { + o.SuppressMetadataAttributes = true; + }), + }; + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + NoChildren(irDocument); + } + + [Fact] + public void Execute_NoNamespaceSet_Noops() + { + // Arrange + var engine = CreateEngine(); + var pass = new MetadataAttributePass() + { + Engine = engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create(); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var irDocument = new DocumentIntermediateNode() + { + DocumentKind = "test", + Options = RazorCodeGenerationOptions.Create((o) => { }), + }; + var builder = IntermediateNodeBuilder.Create(irDocument); + var @namespace = new NamespaceDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace, + }, + }; + builder.Push(@namespace); + var @class = new ClassDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass, + }, + ClassName = "Test", + }; + builder.Add(@class); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + SingleChild(irDocument); + } + + [Fact] + public void Execute_NoClassNameSet_Noops() + { + // Arrange + var engine = CreateEngine(); + var pass = new MetadataAttributePass() + { + Engine = engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create(); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var irDocument = new DocumentIntermediateNode() + { + DocumentKind = "test", + Options = RazorCodeGenerationOptions.Create((o) => { }), + }; + var builder = IntermediateNodeBuilder.Create(irDocument); + var @namespace = new NamespaceDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace, + }, + Content = "Some.Namespace" + }; + builder.Push(@namespace); + var @class = new ClassDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass, + }, + }; + builder.Add(@class); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + SingleChild(irDocument); + } + + [Fact] + public void Execute_NoDocumentKind_Noops() + { + // Arrange + var engine = CreateEngine(); + var pass = new MetadataAttributePass() + { + Engine = engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create(); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var irDocument = new DocumentIntermediateNode(); + var builder = IntermediateNodeBuilder.Create(irDocument); + var @namespace = new NamespaceDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace, + }, + Content = "Some.Namespace" + }; + builder.Push(@namespace); + var @class = new ClassDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass, + }, + ClassName = "Test", + }; + builder.Add(@class); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + SingleChild(irDocument); + } + + [Fact] + public void Execute_NoIdentifier_Noops() + { + // Arrange + var engine = CreateEngine(); + var pass = new MetadataAttributePass() + { + Engine = engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create("", new RazorSourceDocumentProperties(null, null)); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var irDocument = new DocumentIntermediateNode() + { + DocumentKind = "test", + Options = RazorCodeGenerationOptions.Create((o) => { }), + }; + var builder = IntermediateNodeBuilder.Create(irDocument); + var @namespace = new NamespaceDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace, + }, + Content = "Some.Namespace" + }; + builder.Push(@namespace); + var @class = new ClassDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass, + }, + ClassName = "Test", + }; + builder.Add(@class); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + SingleChild(irDocument); + } + + [Fact] + public void Execute_HasRequiredInfo_AddsItemAndSourceChecksum() + { + // Arrange + var engine = CreateEngine(); + var pass = new MetadataAttributePass() + { + Engine = engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create("", new RazorSourceDocumentProperties(null, "Foo\\Bar.cshtml")); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var irDocument = new DocumentIntermediateNode() + { + DocumentKind = "test", + Options = RazorCodeGenerationOptions.Create((o) => { }), + }; + var builder = IntermediateNodeBuilder.Create(irDocument); + var @namespace = new NamespaceDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace, + }, + Content = "Some.Namespace" + }; + builder.Push(@namespace); + var @class = new ClassDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass, + }, + ClassName = "Test", + }; + builder.Add(@class); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + Assert.Equal(2, irDocument.Children.Count); + + var item = Assert.IsType(irDocument.Children[0]); + Assert.Equal("/Foo/Bar.cshtml", item.Identifier); + Assert.Equal("test", item.Kind); + Assert.Equal("Some.Namespace.Test", item.TypeName); + + Assert.Equal(2, @namespace.Children.Count); + var checksum = Assert.IsType(@namespace.Children[0]); + Assert.NotNull(checksum.Checksum); // Not verifying the checksum here + Assert.Equal("SHA1", checksum.ChecksumAlgorithm); + Assert.Equal("/Foo/Bar.cshtml", checksum.Identifier); + } + + [Fact] + public void Execute_HasRequiredInfo_AndImport_AddsItemAndSourceChecksum() + { + // Arrange + var engine = CreateEngine(); + var pass = new MetadataAttributePass() + { + Engine = engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create("", new RazorSourceDocumentProperties(null, "Foo\\Bar.cshtml")); + var import = TestRazorSourceDocument.Create("@using System", new RazorSourceDocumentProperties(null, "Foo\\Import.cshtml")); + var codeDocument = RazorCodeDocument.Create(sourceDocument, new[] { import, }); + + var irDocument = new DocumentIntermediateNode() + { + DocumentKind = "test", + Options = RazorCodeGenerationOptions.Create((o) => { }), + }; + var builder = IntermediateNodeBuilder.Create(irDocument); + var @namespace = new NamespaceDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace, + }, + Content = "Some.Namespace" + }; + builder.Push(@namespace); + var @class = new ClassDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass, + }, + ClassName = "Test", + }; + builder.Add(@class); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + Assert.Equal(2, irDocument.Children.Count); + + var item = Assert.IsType(irDocument.Children[0]); + Assert.Equal("/Foo/Bar.cshtml", item.Identifier); + Assert.Equal("test", item.Kind); + Assert.Equal("Some.Namespace.Test", item.TypeName); + + Assert.Equal(3, @namespace.Children.Count); + var checksum = Assert.IsType(@namespace.Children[0]); + Assert.NotNull(checksum.Checksum); // Not verifying the checksum here + Assert.Equal("SHA1", checksum.ChecksumAlgorithm); + Assert.Equal("/Foo/Bar.cshtml", checksum.Identifier); + + checksum = Assert.IsType(@namespace.Children[1]); + Assert.NotNull(checksum.Checksum); // Not verifying the checksum here + Assert.Equal("SHA1", checksum.ChecksumAlgorithm); + Assert.Equal("/Foo/Import.cshtml", checksum.Identifier); + } + + private static RazorEngine CreateEngine() + { + return RazorEngine.Create(b => + { + b.Features.Add(new DefaultMetadataIdentifierFeature()); + }); + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/MetadataAttributeTargetExtensionTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/MetadataAttributeTargetExtensionTest.cs new file mode 100644 index 0000000000..9f8a280f73 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/MetadataAttributeTargetExtensionTest.cs @@ -0,0 +1,69 @@ +// 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.CodeGeneration; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Extensions +{ + public class MetadataAttributeTargetExtensionTest + { + [Fact] + public void WriteRazorCompiledItemAttribute_RendersCorrectly() + { + // Arrange + var extension = new MetadataAttributeTargetExtension() + { + CompiledItemAttributeName = "global::TestItem", + }; + var context = TestCodeRenderingContext.CreateRuntime(); + + var node = new RazorCompiledItemAttributeIntermediateNode() + { + TypeName = "Foo.Bar", + Kind = "test", + Identifier = "Foo/Bar", + }; + + // Act + extension.WriteRazorCompiledItemAttribute(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"[assembly: global::TestItem(typeof(Foo.Bar), @""test"", @""Foo/Bar"")] +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteRazorSourceChecksumAttribute_RendersCorrectly() + { + // Arrange + var extension = new MetadataAttributeTargetExtension() + { + SourceChecksumAttributeName = "global::TestChecksum", + }; + var context = TestCodeRenderingContext.CreateRuntime(); + + var node = new RazorSourceChecksumAttributeIntermediateNode() + { + ChecksumAlgorithm = "SHA1", + Checksum = new byte[] { (byte)'t', (byte)'e', (byte)'s', (byte)'t', }, + Identifier = "Foo/Bar", + }; + + // Act + extension.WriteRazorSourceChecksumAttribute(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"[global::TestChecksum(@""SHA1"", @""74657374"", @""Foo/Bar"")] +", + csharp, + ignoreLineEndingDifferences: true); + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/FileSystemRazorProjectTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/FileSystemRazorProjectTest.cs deleted file mode 100644 index 98a22f4fc5..0000000000 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/FileSystemRazorProjectTest.cs +++ /dev/null @@ -1,171 +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.Linq; -using Microsoft.AspNetCore.Testing; -using Xunit; - -namespace Microsoft.AspNetCore.Razor.Language -{ - public class FileSystemRazorProjectTest - { - private static string TestFolder { get; } = Path.Combine( - TestProject.GetProjectDirectory(typeof(FileSystemRazorProjectTest)), - "TestFiles", - "FileSystemRazorProject"); - - [Theory] - [InlineData(null)] - [InlineData("")] - public void NormalizeAndEnsureValidPath_ThrowsIfPathIsNullOrEmpty(string path) - { - // Arrange - var project = new TestFileSystemRazorProject("C:/some/test/path/root"); - - // Act and Assert - ExceptionAssert.ThrowsArgumentNullOrEmptyString(() => project.NormalizeAndEnsureValidPath(path), "path"); - } - - [Fact] - public void NormalizeAndEnsureValidPath_NormalizesToAbsolutePath() - { - // Arrange - var project = new TestFileSystemRazorProject("C:/some/test/path/root"); - - // Act - var absolutePath = project.NormalizeAndEnsureValidPath("file.cshtml"); - - // Assert - Assert.Equal("C:/some/test/path/root/file.cshtml", absolutePath); - } - - [Fact] - public void NormalizeAndEnsureValidPath_NormalizesToAbsolutePathWithoutForwardSlash() - { - // Arrange - var project = new TestFileSystemRazorProject("C:/some/test/path/root"); - - // Act - var absolutePath = project.NormalizeAndEnsureValidPath("/file.cshtml"); - - // Assert - Assert.Equal("C:/some/test/path/root/file.cshtml", absolutePath); - } - - [Fact] - public void NormalizeAndEnsureValidPath_NormalizesToForwardSlashes() - { - // Arrange - var project = new TestFileSystemRazorProject(@"C:\some\test\path\root"); - - // Act - var absolutePath = project.NormalizeAndEnsureValidPath(@"something\file.cshtml"); - - // Assert - Assert.Equal("C:/some/test/path/root/something/file.cshtml", absolutePath); - } - - [Fact] - public void EnumerateItems_DiscoversAllCshtmlFiles() - { - // Arrange - var fileSystemProject = new FileSystemRazorProject(TestFolder); - - // Act - var files = fileSystemProject.EnumerateItems("/"); - - // Assert - Assert.Collection(files.OrderBy(f => f.FilePath), - file => - { - Assert.Equal("/Home.cshtml", file.FilePath); - Assert.Equal("/", file.BasePath); - }, - file => - { - Assert.Equal("/Views/About/About.cshtml", file.FilePath); - Assert.Equal("/", file.BasePath); - }, - file => - { - Assert.Equal("/Views/Home/Index.cshtml", file.FilePath); - Assert.Equal("/", file.BasePath); - }); - } - - [Fact] - public void EnumerateItems_DiscoversAllCshtmlFiles_UnderSpecifiedBasePath() - { - // Arrange - var fileSystemProject = new FileSystemRazorProject(TestFolder); - - // Act - var files = fileSystemProject.EnumerateItems("/Views"); - - // Assert - Assert.Collection(files.OrderBy(f => f.FilePath), - file => - { - Assert.Equal("/About/About.cshtml", file.FilePath); - Assert.Equal("/Views", file.BasePath); - }, - file => - { - Assert.Equal("/Home/Index.cshtml", file.FilePath); - Assert.Equal("/Views", file.BasePath); - }); - } - - [Fact] - public void EnumerateItems_ReturnsEmptySequence_WhenBasePathDoesNotExist() - { - // Arrange - var fileSystemProject = new FileSystemRazorProject(TestFolder); - - // Act - var files = fileSystemProject.EnumerateItems("/Does-Not-Exist"); - - // Assert - Assert.Empty(files); - } - - [Fact] - public void GetItem_ReturnsFileFromDisk() - { - // Arrange - var path = "/Views/About/About.cshtml"; - var fileSystemProject = new FileSystemRazorProject(TestFolder); - - // Act - var file = fileSystemProject.GetItem(path); - - // Assert - Assert.True(file.Exists); - Assert.Equal(path, file.FilePath); - } - - [Fact] - public void GetItem_ReturnsNotFoundResult() - { - // Arrange - var path = "/NotFound.cshtml"; - var fileSystemProject = new FileSystemRazorProject(TestFolder); - - // Act - var file = fileSystemProject.GetItem(path); - - // Assert - Assert.False(file.Exists); - } - - private class TestFileSystemRazorProject : FileSystemRazorProject - { - public TestFileSystemRazorProject(string root) : base(root) - { - } - - public new string NormalizeAndEnsureValidPath(string path) => base.NormalizeAndEnsureValidPath(path); - } - } -} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/BasicIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/BasicIntegrationTest.cs index cac3abd762..56c22c8105 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/BasicIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/BasicIntegrationTest.cs @@ -78,12 +78,11 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests // Arrange var engine = RazorEngine.Create(); - var document = RazorCodeDocument.Create(TestRazorSourceDocument.Create("@!!!", fileName: "test.cshtml")); + var document = RazorCodeDocument.Create(TestRazorSourceDocument.Create("@!!!", filePath: "test.cshtml")); - var expected = RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("!"), - new SourceLocation("test.cshtml", 1, 0, 1), - length: 1)); + var expected = RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( + new SourceSpan(new SourceLocation("test.cshtml", 1, 0, 1), contentLength: 1), + "!"); // Act engine.Process(document); @@ -100,12 +99,10 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests // Arrange var engine = RazorEngine.CreateDesignTime(); - var document = RazorCodeDocument.Create(TestRazorSourceDocument.Create("@{", fileName: "test.cshtml")); + var document = RazorCodeDocument.Create(TestRazorSourceDocument.Create("@{", filePath: "test.cshtml")); - var expected = RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(LegacyResources.BlockName_Code, "}", "{"), - new SourceLocation("test.cshtml", 1, 0, 1), - length: 1)); + var expected = RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation("test.cshtml", 1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"); // Act engine.Process(document); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/CodeGenerationIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/CodeGenerationIntegrationTest.cs index f8de2ce59c..673f6ac7fa 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/CodeGenerationIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/CodeGenerationIntegrationTest.cs @@ -885,7 +885,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests // Arrange var engine = RazorEngine.CreateDesignTime(builder => { - builder.Features.Add(new ApiSetsIRTestAdapter()); + builder.ConfigureDocumentClassifier(); // Some of these tests use templates builder.AddTargetExtension(new TemplateTargetExtension()); @@ -911,7 +911,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests // Arrange var engine = RazorEngine.Create(builder => { - builder.Features.Add(new ApiSetsIRTestAdapter()); + builder.ConfigureDocumentClassifier(); // Some of these tests use templates builder.AddTargetExtension(new TemplateTargetExtension()); @@ -936,7 +936,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests // Arrange var engine = RazorEngine.Create(builder => { - builder.Features.Add(new ApiSetsIRTestAdapter()); + builder.ConfigureDocumentClassifier(); builder.AddTagHelpers(descriptors); // Some of these tests use templates @@ -962,7 +962,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests // Arrange var engine = RazorEngine.CreateDesignTime(builder => { - builder.Features.Add(new ApiSetsIRTestAdapter()); + builder.ConfigureDocumentClassifier(); builder.AddTagHelpers(descriptors); // Some of these tests use templates diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ExtensibleDirectiveTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ExtensibleDirectiveTest.cs index 3428fadde8..1074b1052a 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ExtensibleDirectiveTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ExtensibleDirectiveTest.cs @@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests // Arrange var engine = RazorEngine.CreateDesignTime(builder => { - builder.Features.Add(new ApiSetsIRTestAdapter()); + builder.ConfigureDocumentClassifier(); builder.AddDirective(DirectiveDescriptor.CreateDirective("custom", DirectiveKind.SingleLine, b => b.AddNamespaceToken())); }); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/RazorTemplateEngineIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/RazorTemplateEngineIntegrationTest.cs index b5cd18e7ff..ad26823b85 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/RazorTemplateEngineIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/RazorTemplateEngineIntegrationTest.cs @@ -12,39 +12,35 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests public void GenerateCodeWithDefaults() { // Arrange - var filePath = Path.Combine(TestProjectRoot, $"{FileName}.cshtml"); - var content = File.ReadAllText(filePath); - var projectItem = new TestRazorProjectItem($"{FileName}.cshtml", "") + var fileSystem = new DefaultRazorProjectFileSystem(TestProjectRoot); + var razorEngine = RazorEngine.Create(engine => { - Content = content, - }; - var project = new TestRazorProject(new[]{ projectItem }); - var razorEngine = RazorEngine.Create(); - var templateEngine = new RazorTemplateEngine(razorEngine, project); + engine.Features.Add(new SuppressChecksumOptionsFeature()); + }); + var templateEngine = new RazorTemplateEngine(razorEngine, fileSystem); // Act - var resultcSharpDocument = templateEngine.GenerateCode(projectItem.FilePath); + var cSharpDocument = templateEngine.GenerateCode($"{FileName}.cshtml"); // Assert - AssertCSharpDocumentMatchesBaseline(resultcSharpDocument); + AssertCSharpDocumentMatchesBaseline(cSharpDocument); } [Fact] public void GenerateCodeWithBaseType() { // Arrange - var filePath = Path.Combine(TestProjectRoot, $"{FileName}.cshtml"); - var content = File.ReadAllText(filePath); - var projectItem = new TestRazorProjectItem($"{FileName}.cshtml", "") + var fileSystem = new DefaultRazorProjectFileSystem(TestProjectRoot); + var razorEngine = RazorEngine.Create(engine => { - Content = content, - }; - var project = new TestRazorProject(new[] { projectItem }); - var razorEngine = RazorEngine.Create(engine => engine.SetBaseType("MyBaseType")); - var templateEngine = new RazorTemplateEngine(razorEngine, project); + engine.Features.Add(new SuppressChecksumOptionsFeature()); + + engine.SetBaseType("MyBaseType"); + }); + var templateEngine = new RazorTemplateEngine(razorEngine, fileSystem); // Act - var cSharpDocument = templateEngine.GenerateCode(projectItem.FilePath); + var cSharpDocument = templateEngine.GenerateCode($"{FileName}.cshtml"); // Assert AssertCSharpDocumentMatchesBaseline(cSharpDocument); @@ -54,15 +50,11 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests public void GenerateCodeWithConfigureClass() { // Arrange - var filePath = Path.Combine(TestProjectRoot, $"{FileName}.cshtml"); - var content = File.ReadAllText(filePath); - var projectItem = new TestRazorProjectItem($"{FileName}.cshtml", "") - { - Content = content, - }; - var project = new TestRazorProject(new[] { projectItem }); + var fileSystem = new DefaultRazorProjectFileSystem(TestProjectRoot); var razorEngine = RazorEngine.Create(engine => { + engine.Features.Add(new SuppressChecksumOptionsFeature()); + engine.ConfigureClass((document, @class) => { @class.ClassName = "MyClass"; @@ -78,10 +70,10 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests @class.BaseType = "CustomBaseType"; }); }); - var templateEngine = new RazorTemplateEngine(razorEngine, project); + var templateEngine = new RazorTemplateEngine(razorEngine, fileSystem); // Act - var cSharpDocument = templateEngine.GenerateCode(projectItem.FilePath); + var cSharpDocument = templateEngine.GenerateCode($"{FileName}.cshtml"); // Assert AssertCSharpDocumentMatchesBaseline(cSharpDocument); @@ -91,21 +83,17 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests public void GenerateCodeWithSetNamespace() { // Arrange - var filePath = Path.Combine(TestProjectRoot, $"{FileName}.cshtml"); - var content = File.ReadAllText(filePath); - var projectItem = new TestRazorProjectItem($"{FileName}.cshtml", "") - { - Content = content, - }; - var project = new TestRazorProject(new[] { projectItem }); + var fileSystem = new DefaultRazorProjectFileSystem(TestProjectRoot); var razorEngine = RazorEngine.Create(engine => { + engine.Features.Add(new SuppressChecksumOptionsFeature()); + engine.SetNamespace("MyApp.Razor.Views"); }); - var templateEngine = new RazorTemplateEngine(razorEngine, project); + var templateEngine = new RazorTemplateEngine(razorEngine, fileSystem); // Act - var cSharpDocument = templateEngine.GenerateCode(projectItem.FilePath); + var cSharpDocument = templateEngine.GenerateCode($"{FileName}.cshtml"); // Assert AssertCSharpDocumentMatchesBaseline(cSharpDocument); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/LargeTextSourceDocumentTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/LargeTextSourceDocumentTest.cs index bf61974524..fb47799b23 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/LargeTextSourceDocumentTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/LargeTextSourceDocumentTest.cs @@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Test var contentString = "Hello World"; var stream = TestRazorSourceDocument.CreateStreamContent(contentString); var reader = new StreamReader(stream, detectEncodingFromByteOrderMarks: true); - var document = new LargeTextSourceDocument(reader, 5, Encoding.UTF8, "file.cshtml"); + var document = new LargeTextSourceDocument(reader, 5, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var firstChecksum = document.GetChecksum(); @@ -33,7 +33,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Test var contentString = "Hello World"; var stream = TestRazorSourceDocument.CreateStreamContent(contentString); var reader = new StreamReader(stream, detectEncodingFromByteOrderMarks: true); - var document = new LargeTextSourceDocument(reader, 5, Encoding.UTF8, "file.cshtml"); + var document = new LargeTextSourceDocument(reader, 5, Encoding.UTF8, RazorSourceDocumentProperties.Default); var expectedChecksum = new byte[] { 10, 77, 85, 168, 215, 120, 229, 2, 47, 171, 112, 25, 119, 197, 216, 64, 187, 196, 134, 208 }; // Act @@ -50,7 +50,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Test var contentString = "Hello World"; var stream = TestRazorSourceDocument.CreateStreamContent(contentString, Encoding.UTF32); var reader = new StreamReader(stream, detectEncodingFromByteOrderMarks: true); - var document = new LargeTextSourceDocument(reader, 5, Encoding.UTF32, "file.cshtml"); + var document = new LargeTextSourceDocument(reader, 5, Encoding.UTF32, RazorSourceDocumentProperties.Default); var expectedChecksum = new byte[] { 108, 172, 130, 171, 42, 19, 155, 176, 211, 80, 224, 121, 169, 133, 25, 134, 48, 228, 199, 141 }; // Act @@ -81,7 +81,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Test var stream = TestRazorSourceDocument.CreateStreamContent(new string(content)); var reader = new StreamReader(stream, true); - var document = new LargeTextSourceDocument(reader, ChunkTestLength, Encoding.UTF8, "file.cshtml"); + var document = new LargeTextSourceDocument(reader, ChunkTestLength, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var output = new char[contentLength]; @@ -106,12 +106,28 @@ namespace Microsoft.AspNetCore.Razor.Language.Test var reader = new StreamReader(stream, true); // Act - var document = new LargeTextSourceDocument(reader, ChunkTestLength, Encoding.UTF8, filePath); + var document = new LargeTextSourceDocument(reader, ChunkTestLength, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: filePath, relativePath: null)); // Assert Assert.Equal(filePath, document.FilePath); } + [Theory] + [InlineData("test.cshtml")] + [InlineData(null)] + public void RelativePath(string relativePath) + { + // Arrange + var stream = TestRazorSourceDocument.CreateStreamContent("abc"); + var reader = new StreamReader(stream, true); + + // Act + var document = new LargeTextSourceDocument(reader, ChunkTestLength, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: null, relativePath: relativePath)); + + // Assert + Assert.Equal(relativePath, document.RelativePath); + } + [Fact] public void Lines() { @@ -120,7 +136,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Test var reader = new StreamReader(stream, true); // Act - var document = new LargeTextSourceDocument(reader, ChunkTestLength, Encoding.UTF8, "file.cshtml"); + var document = new LargeTextSourceDocument(reader, ChunkTestLength, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Assert Assert.Equal(3, document.Lines.Count); @@ -142,7 +158,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Test var stream = TestRazorSourceDocument.CreateStreamContent("abcdefghijklmnopqrstuvwxyz"); var reader = new StreamReader(stream, true); - var document = new LargeTextSourceDocument(reader, ChunkTestLength, Encoding.UTF8, "file.cshtml"); + var document = new LargeTextSourceDocument(reader, ChunkTestLength, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var destination = new char[1000]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/BlockTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/BlockTest.cs index dc57fb1147..4b4f984ce6 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/BlockTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/BlockTest.cs @@ -44,6 +44,26 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Assert.Equal(2, parentBlock.Length); } + [Fact] + public void Clone_ClonesBlock() + { + // Arrange + var blockBuilder = new BlockBuilder() + { + ChunkGenerator = new DynamicAttributeBlockChunkGenerator(new LocationTagged("class=\"", SourceLocation.Zero), 0, 0, 0), + Type = BlockKindInternal.Expression, + }; + blockBuilder.Children.Add(new SpanBuilder(new SourceLocation(1, 2, 3)).Build()); + var block = blockBuilder.Build(); + + // Act + var copy = (Block)block.Clone(); + + // Assert + ParserTestBase.EvaluateParseTree(copy, block); + Assert.NotSame(block, copy); + } + [Fact] public void ConstructorWithBlockBuilderSetsParent() { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpAutoCompleteTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpAutoCompleteTest.cs index 9f0e9f1fba..13633efdd1 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpAutoCompleteTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpAutoCompleteTest.cs @@ -16,11 +16,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(FunctionsDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(FunctionsDirective.Directive.Directive, "}", "{"), - new SourceLocation(10, 0, 10), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(10, 0, 10), contentLength: 1), FunctionsDirective.Directive.Directive, "}", "{")); // Act & Assert ParseBlockTest( @@ -38,11 +35,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("section", "}", "{"), - new SourceLocation(16, 0, 16), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(16, 0, 16), contentLength: 1), "section", "}", "{")); // Act & Assert ParseBlockTest( @@ -71,11 +65,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AsStatement() .With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = "}" }) ), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF( - LegacyResources.BlockName_Code, "}", "{"), - new SourceLocation(1, 0, 1), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{")); } [Fact] @@ -84,11 +75,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(FunctionsDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("functions", "}", "{"), - new SourceLocation(10, 0, 10), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(10, 0, 10), contentLength: 1), "functions", "}", "{")); // Act & Assert ParseBlockTest( @@ -107,11 +95,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("section", "}", "{"), - new SourceLocation(16, 0, 16), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(16, 0, 16), contentLength: 1), "section", "}", "{")); // Act & Assert ParseBlockTest( @@ -152,11 +137,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Span(SpanKindInternal.Code, new CSharpSymbol(string.Empty, CSharpSymbolType.Unknown)) .With(new StatementChunkGenerator()) ), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF( - LegacyResources.BlockName_Code, "}", "{"), - new SourceLocation(1, 0, 1), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{")); } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpBlockTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpBlockTest.cs index 5972dabb25..fa22393a46 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpBlockTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpBlockTest.cs @@ -148,10 +148,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy ImplicitExpressionTest( "Html.En(code()", "Html.En(code()", AcceptedCharactersInternal.Any, - new RazorError( - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"), - new SourceLocation(8, 0, 8), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(8, 0, 8), contentLength: 1), "(", ")")); } [Fact] @@ -499,10 +497,8 @@ while(true);", BlockKindInternal.Statement, SpanKindInternal.Code, acceptedChara document, BlockKindInternal.Statement, SpanKindInternal.Code, - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("foreach", '}', '{'), - SourceLocation.Zero, - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), "foreach", "}", "{")); } [Fact] @@ -514,14 +510,10 @@ while(true);", BlockKindInternal.Statement, SpanKindInternal.Code, acceptedChara document, BlockKindInternal.Statement, SpanKindInternal.Code, - new RazorError( - LegacyResources.ParseError_BlockComment_Not_Terminated, - new SourceLocation(24, 0, 24), - length: 1), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("foreach", '}', '{'), - SourceLocation.Zero, - length: 1)); + RazorDiagnosticFactory.CreateParsing_BlockCommentNotTerminated( + new SourceSpan(new SourceLocation(24, 0, 24), contentLength: 1)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), "foreach", "}", "{")); } [Fact] @@ -533,10 +525,8 @@ while(true);", BlockKindInternal.Statement, SpanKindInternal.Code, acceptedChara document, BlockKindInternal.Statement, SpanKindInternal.Code, - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("foreach", '}', '{'), - SourceLocation.Zero, - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), "foreach", "}", "{")); } [Fact] @@ -1151,16 +1141,12 @@ catch(bar) { baz(); }", BlockKindInternal.Statement, SpanKindInternal.Code); Factory.Markup("@").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 12, 0, 12), new LocationTagged("@", 12, 0, 12))).Accepts(AcceptedCharactersInternal.None), Factory.Markup("@").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None)))), Factory.EmptyHtml())); - var expectedErrors = new RazorError[] + var expectedErrors = new RazorDiagnostic[] { - new RazorError( - @"End of file or an unexpected character was reached before the ""span"" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing (""
"") or have matching end tags (""

Hello

""). If you intended to display a ""<"" character, use the ""<"" HTML entity.", - new SourceLocation(2, 0, 2), - length: 4), - new RazorError( - @"The code block is missing a closing ""}"" character. Make sure you have a matching ""}"" character for all the ""{"" characters within this block, and that none of the ""}"" characters are being interpreted as markup.", - SourceLocation.Zero, - length: 1), + RazorDiagnosticFactory.CreateParsing_UnfinishedTag( + new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 4), "span"), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), Resources.BlockName_Code, "}", "{"), }; // Act & Assert @@ -1194,16 +1180,13 @@ catch(bar) { baz(); }", BlockKindInternal.Statement, SpanKindInternal.Code); Factory.Markup(" />").Accepts(AcceptedCharactersInternal.None))), Factory.EmptyCSharp().AsStatement(), Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)); - var expectedErrors = new RazorError[] + var expectedErrors = new RazorDiagnostic[] { - new RazorError( - @"A space or line break was encountered after the ""@"" character. Only valid identifiers, keywords, comments, ""("" and ""{"" are valid at the start of a code block and they must occur immediately following ""@"" with no space in between.", - new SourceLocation(13, 0, 13), - length: 1), - new RazorError( - @"""' />}"" is not valid at the start of a code block. Only identifiers, keywords, comments, ""("" and ""{"" are valid.", - new SourceLocation(15, 0, 15), - length: 5), + RazorDiagnosticFactory.CreateParsing_UnexpectedWhiteSpaceAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(13, 0, 13), contentLength: 1)), + RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(15, 0, 15), contentLength: 5), + "' />}"), }; // Act & Assert @@ -1251,22 +1234,13 @@ catch(bar) { baz(); }", BlockKindInternal.Statement, SpanKindInternal.Code); ParseBlockTest(prefix + markup + suffix, expected); } - private void NamespaceImportTest(string content, string expectedNS, AcceptedCharactersInternal acceptedCharacters = AcceptedCharactersInternal.None, string errorMessage = null, SourceLocation? location = null) + private void NamespaceImportTest(string content, string expectedNS, AcceptedCharactersInternal acceptedCharacters = AcceptedCharactersInternal.None, SourceLocation? location = null) { - var errors = new RazorError[0]; - if (!string.IsNullOrEmpty(errorMessage) && location.HasValue) - { - errors = new RazorError[] - { - new RazorError(errorMessage, location.Value, length: 1) - }; - } ParseBlockTest(content, new DirectiveBlock( Factory.Code(content) .AsNamespaceImport(expectedNS) - .Accepts(acceptedCharacters)), - errors); + .Accepts(acceptedCharacters))); } private static StatementBlock CreateStatementBlock(MarkupBlock block) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpDirectivesTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpDirectivesTest.cs index 29cdff255b..98cda93282 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpDirectivesTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpDirectivesTest.cs @@ -60,10 +60,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - Resources.FormatDuplicateDirective("custom"), - 42 + Environment.NewLine.Length, 1, 0, 7))); + RazorDiagnosticFactory.CreateParsing_DuplicateDirective( + new SourceSpan(new SourceLocation(42 + Environment.NewLine.Length, 1, 0), 7), "custom")); // Act & Assert ParseDocumentTest( @@ -202,10 +200,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddStringToken().AddStringToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - Resources.FormatDirectiveTokensMustBeSeparatedByWhitespace("custom"), - 17, 0, 17, 9))); + RazorDiagnosticFactory.CreateParsing_DirectiveTokensMustBeSeparatedByWhitespace( + new SourceSpan(new SourceLocation(17, 0, 17), 9), "custom")); // Act & Assert ParseCodeBlockTest( @@ -228,10 +224,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddNamespaceToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsNamespace("custom"), - 8, 0, 8, 7))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsNamespace( + new SourceSpan(new SourceLocation(8, 0, 8), 7), "custom")); // Act & Assert ParseCodeBlockTest( @@ -253,10 +247,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddNamespaceToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsNamespace("custom"), - 8, 0, 8, 7))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsNamespace( + new SourceSpan(new SourceLocation(8, 0, 8), 7), "custom")); // Act & Assert ParseCodeBlockTest( @@ -277,10 +269,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddNamespaceToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsNamespace("custom"), - 8, 0, 8, 7))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsNamespace( + new SourceSpan(new SourceLocation(8, 0, 8), 7), "custom")); // Act & Assert ParseCodeBlockTest( @@ -302,10 +292,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddNamespaceToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsNamespace("custom"), - 8, 0, 8, 7))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsNamespace( + new SourceSpan(new SourceLocation(8, 0, 8), 7), "custom")); // Act & Assert ParseCodeBlockTest( @@ -386,7 +374,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy "*, Foo", "*", "Foo", - new RazorError(Resources.FormatDirectiveMustAppearAtStartOfLine("addTagHelper"), new SourceLocation(4, 0, 4), 12))), + RazorDiagnosticFactory.CreateParsing_DirectiveMustAppearAtStartOfLine( + new SourceSpan(new SourceLocation(4, 0, 4), 12), "addTagHelper"))), Factory.Code(Environment.NewLine).AsStatement(), Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None))); } @@ -401,11 +390,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddTypeToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - Resources.FormatDirectiveMustAppearAtStartOfLine("custom"), - new SourceLocation(4, 0, 4), - 6))); + RazorDiagnosticFactory.CreateParsing_DirectiveMustAppearAtStartOfLine( + new SourceSpan(new SourceLocation(4, 0, 4), contentLength: 6), "custom")); // Act & Assert ParseCodeBlockTest( @@ -541,11 +527,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddStringToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsQuotedStringLiteral("custom"), - new SourceLocation(8, 0, 8), - length: 7))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsQuotedStringLiteral( + new SourceSpan(new SourceLocation(8, 0, 8), contentLength: 7), "custom")); // Act & Assert ParseCodeBlockTest( @@ -567,11 +550,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddStringToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsQuotedStringLiteral("custom"), - new SourceLocation(8, 0, 8), - length: 1))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsQuotedStringLiteral( + new SourceSpan(new SourceLocation(8, 0, 8), contentLength: 1), "custom")); // Act & Assert ParseCodeBlockTest( @@ -593,11 +573,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddStringToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsQuotedStringLiteral("custom"), - new SourceLocation(8, 0, 8), - length: 9))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsQuotedStringLiteral( + new SourceSpan(new SourceLocation(8, 0, 8), contentLength: 9), "custom")); // Act & Assert ParseCodeBlockTest( @@ -619,11 +596,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddStringToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsQuotedStringLiteral("custom"), - new SourceLocation(8, 0, 8), - length: 7))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsQuotedStringLiteral( + new SourceSpan(new SourceLocation(8, 0, 8), contentLength: 7), "custom")); // Act & Assert ParseCodeBlockTest( @@ -761,11 +735,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddMemberToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsIdentifier("custom"), - new SourceLocation(8, 0, 8), - length: 1))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsIdentifier( + new SourceSpan(new SourceLocation(8, 0, 8), contentLength: 1), "custom")); // Act & Assert ParseCodeBlockTest( @@ -887,11 +858,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddStringToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatUnexpectedDirectiveLiteral("custom", "line break"), - new SourceLocation(16, 0, 16), - length: 7))); + RazorDiagnosticFactory.CreateParsing_UnexpectedDirectiveLiteral( + new SourceSpan(new SourceLocation(16, 0, 16), contentLength: 7), "custom", "line break")); // Act & Assert ParseCodeBlockTest( @@ -916,11 +884,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddStringToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatUnexpectedDirectiveLiteral("custom", "{"), - new SourceLocation(16, 0, 16), - length: 5))); + RazorDiagnosticFactory.CreateParsing_UnexpectedDirectiveLiteral( + new SourceSpan(new SourceLocation(16, 0, 16), contentLength: 5), "custom", "{")); // Act & Assert ParseCodeBlockTest( @@ -945,11 +910,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddStringToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatUnexpectedEOFAfterDirective("custom", "{"), - new SourceLocation(15, 0, 15), - length: 1))); + RazorDiagnosticFactory.CreateParsing_UnexpectedEOFAfterDirective( + new SourceSpan(new SourceLocation(15, 0, 15), contentLength: 1), "custom", "{")); // Act & Assert ParseCodeBlockTest( @@ -972,11 +934,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddStringToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("custom", "}", "{"), - new SourceLocation(16, 0, 16), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(16, 0, 16), contentLength: 1), "custom", "}", "{")); // Act & Assert ParseCodeBlockTest( @@ -998,8 +957,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { // Arrange var expectedDiagnostic = RazorDiagnosticFactory.CreateParsing_DuplicateDirective( - "tagHelperPrefix", - new SourceSpan(null, 22 + Environment.NewLine.Length, 1, 0, 16)); + new SourceSpan(null, 22 + Environment.NewLine.Length, 1, 0, 16), "tagHelperPrefix"); // Act var document = ParseDocument( @@ -1068,9 +1026,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public void TagHelperPrefixDirective_RequiresValue() { // Arrange - var expectedError = new RazorError( - LegacyResources.FormatParseError_DirectiveMustHaveValue(SyntaxConstants.CSharp.TagHelperPrefixKeyword), - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 15); + var expectedError = RazorDiagnosticFactory.CreateParsing_DirectiveMustHaveValue( + new SourceSpan(filePath: null, absoluteIndex: 1, lineIndex: 0, characterIndex: 1, length: 15), SyntaxConstants.CSharp.TagHelperPrefixKeyword); // Act & Assert ParseBlockTest("@tagHelperPrefix ", @@ -1093,15 +1050,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var expectedErrors = new[] { - new RazorError( - LegacyResources.ParseError_Unterminated_String_Literal, - absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 1), - new RazorError( - LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(SyntaxConstants.CSharp.TagHelperPrefixKeyword), - absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 4), - new RazorError( - Resources.FormatInvalidTagHelperPrefixValue(SyntaxConstants.CSharp.TagHelperPrefixKeyword, '"', "\"Foo"), - absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 4) + RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( + new SourceSpan(filePath: null, absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 1)), + RazorDiagnosticFactory.CreateParsing_IncompleteQuotesAroundDirective( + new SourceSpan(filePath: null, absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 4), SyntaxConstants.CSharp.TagHelperPrefixKeyword), + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperPrefixValue( + new SourceSpan(filePath: null, absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 4), SyntaxConstants.CSharp.TagHelperPrefixKeyword, '"', "\"Foo"), }; // Act & Assert @@ -1124,15 +1078,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var expectedErrors = new[] { - new RazorError( - LegacyResources.ParseError_Unterminated_String_Literal, - absoluteIndex: 23, lineIndex: 0, columnIndex: 23, length: 1), - new RazorError( - LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(SyntaxConstants.CSharp.TagHelperPrefixKeyword), - absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 7), - new RazorError( - Resources.FormatInvalidTagHelperPrefixValue(SyntaxConstants.CSharp.TagHelperPrefixKeyword, ' ', "Foo \""), - absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 7) + RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( + new SourceSpan(filePath: null, absoluteIndex: 23, lineIndex: 0, characterIndex: 23, length: 1)), + RazorDiagnosticFactory.CreateParsing_IncompleteQuotesAroundDirective( + new SourceSpan(filePath: null, absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 7), SyntaxConstants.CSharp.TagHelperPrefixKeyword), + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperPrefixValue( + new SourceSpan(filePath: null, absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 7), SyntaxConstants.CSharp.TagHelperPrefixKeyword, ' ', "Foo \""), }; // Act & Assert @@ -1154,10 +1105,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var expectedErrors = new[] { - new RazorError( - Resources.FormatInvalidTagHelperLookupText(string.Empty), - new SourceLocation(18, 0, 18), - length: 1) + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(18, 0, 18), contentLength: 1), string.Empty) }; ParseBlockTest("@removeTagHelper \"\"", @@ -1173,7 +1122,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AsRemoveTagHelper( "\"\"", string.Empty, - legacyErrors: expectedErrors))); + errors: expectedErrors))); } [Fact] @@ -1181,10 +1130,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var expectedErrors = new[] { - new RazorError( - Resources.FormatInvalidTagHelperLookupText("Foo"), - new SourceLocation(17, 0, 17), - length: 3) + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(17, 0, 17), contentLength: 3), "Foo") }; ParseBlockTest("@removeTagHelper Foo", @@ -1200,7 +1147,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AsRemoveTagHelper( "Foo", "Foo", - legacyErrors: expectedErrors))); + errors: expectedErrors))); } [Fact] @@ -1208,10 +1155,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var expectedErrors = new[] { - new RazorError( - Resources.FormatInvalidTagHelperLookupText("'*, Foo'"), - new SourceLocation(17, 0, 17), - length: 8) + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(17, 0, 17), contentLength: 8), "'*, Foo'") }; ParseBlockTest("@removeTagHelper '*, Foo'", @@ -1225,7 +1170,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AsRemoveTagHelper( "'*, Foo'", "'*, Foo'", - legacyErrors: expectedErrors))); + errors: expectedErrors))); } [Fact] @@ -1233,10 +1178,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var expectedErrors = new[] { - new RazorError( - Resources.FormatInvalidTagHelperLookupText("Foo"), - new SourceLocation(18, 0, 18), - length: 3) + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(18, 0, 18), contentLength: 3), "Foo") }; ParseBlockTest("@removeTagHelper \"Foo\"", @@ -1252,7 +1195,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AsRemoveTagHelper( "\"Foo\"", "Foo", - legacyErrors: expectedErrors))); + errors: expectedErrors))); } [Fact] @@ -1280,13 +1223,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var expectedErrors = new[] { - new RazorError( - LegacyResources.FormatParseError_DirectiveMustHaveValue(SyntaxConstants.CSharp.RemoveTagHelperKeyword), - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 15), - new RazorError( - Resources.FormatInvalidTagHelperLookupText(string.Empty), - new SourceLocation(17, 0, 17), - length: 1), + RazorDiagnosticFactory.CreateParsing_DirectiveMustHaveValue( + new SourceSpan(filePath: null, absoluteIndex: 1, lineIndex: 0, characterIndex: 1, length: 15), SyntaxConstants.CSharp.RemoveTagHelperKeyword), + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(17, 0, 17), contentLength: 1), string.Empty), }; // Act & Assert @@ -1298,7 +1238,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Span(SpanKindInternal.Markup, " ", markup: false) .Accepts(AcceptedCharactersInternal.None), Factory.EmptyCSharp() - .AsRemoveTagHelper(string.Empty, string.Empty, legacyErrors: expectedErrors) + .AsRemoveTagHelper(string.Empty, string.Empty, errors: expectedErrors) .Accepts(AcceptedCharactersInternal.AnyExceptNewline))); } @@ -1308,16 +1248,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var expectedErrors = new[] { - new RazorError( - LegacyResources.ParseError_Unterminated_String_Literal, - absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 1), - new RazorError( - LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(SyntaxConstants.CSharp.RemoveTagHelperKeyword), - absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 4), - new RazorError( - Resources.FormatInvalidTagHelperLookupText("\"Foo"), - new SourceLocation(17, 0, 17), - length: 4), + RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( + new SourceSpan(filePath: null, absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 1)), + RazorDiagnosticFactory.CreateParsing_IncompleteQuotesAroundDirective( + new SourceSpan(filePath: null, absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 4), SyntaxConstants.CSharp.RemoveTagHelperKeyword), + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(17, 0, 17), contentLength: 4), "\"Foo"), }; // Act & Assert @@ -1331,7 +1267,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .Span(SpanKindInternal.Markup, " ", markup: false) .Accepts(AcceptedCharactersInternal.None), Factory.Code("\"Foo") - .AsRemoveTagHelper("\"Foo", "\"Foo", legacyErrors: expectedErrors))); + .AsRemoveTagHelper("\"Foo", "\"Foo", errors: expectedErrors))); } [Fact] @@ -1340,16 +1276,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var expectedErrors = new[] { - new RazorError( - LegacyResources.ParseError_Unterminated_String_Literal, - absoluteIndex: 20, lineIndex: 0, columnIndex: 20, length: 1), - new RazorError( - LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(SyntaxConstants.CSharp.RemoveTagHelperKeyword), - absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 4), - new RazorError( - Resources.FormatInvalidTagHelperLookupText("Foo\""), - new SourceLocation(17, 0, 17), - length: 4), + RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( + new SourceSpan(new SourceLocation(absoluteIndex: 20, lineIndex: 0, characterIndex: 20), contentLength: 1)), + RazorDiagnosticFactory.CreateParsing_IncompleteQuotesAroundDirective( + new SourceSpan(filePath: null, absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 4), SyntaxConstants.CSharp.RemoveTagHelperKeyword), + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(17, 0, 17), contentLength: 4), "Foo\""), }; // Act & Assert @@ -1363,7 +1295,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .Span(SpanKindInternal.Markup, " ", markup: false) .Accepts(AcceptedCharactersInternal.None), Factory.Code("Foo\"") - .AsRemoveTagHelper("Foo\"", "Foo\"", legacyErrors: expectedErrors) + .AsRemoveTagHelper("Foo\"", "Foo\"", errors: expectedErrors) .Accepts(AcceptedCharactersInternal.AnyExceptNewline))); } @@ -1372,10 +1304,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var expectedErrors = new[] { - new RazorError( - Resources.FormatInvalidTagHelperLookupText(string.Empty), - new SourceLocation(15, 0, 15), - length: 1) + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(15, 0, 15), contentLength: 1), string.Empty), }; ParseBlockTest("@addTagHelper \"\"", @@ -1391,7 +1321,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AsAddTagHelper( "\"\"", string.Empty, - legacyErrors: expectedErrors))); + errors: expectedErrors))); } [Fact] @@ -1399,10 +1329,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var expectedErrors = new[] { - new RazorError( - Resources.FormatInvalidTagHelperLookupText("Foo"), - new SourceLocation(14, 0, 14), - length: 3) + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(14, 0, 14), contentLength: 3), "Foo"), }; ParseBlockTest("@addTagHelper Foo", @@ -1416,7 +1344,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AsAddTagHelper( "Foo", "Foo", - legacyErrors: expectedErrors))); + errors: expectedErrors))); } [Fact] @@ -1424,10 +1352,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var expectedErrors = new[] { - new RazorError( - Resources.FormatInvalidTagHelperLookupText("Foo"), - new SourceLocation(15, 0, 15), - length: 3) + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(15, 0, 15), contentLength: 3), "Foo") }; ParseBlockTest("@addTagHelper \"Foo\"", @@ -1443,7 +1369,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AsAddTagHelper( "\"Foo\"", "Foo", - legacyErrors: expectedErrors))); + errors: expectedErrors))); } [Fact] @@ -1451,10 +1377,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var expectedErrors = new[] { - new RazorError( - Resources.FormatInvalidTagHelperLookupText("'*, Foo'"), - new SourceLocation(14, 0, 14), - length: 8) + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(14, 0, 14), contentLength: 8), "'*, Foo'") }; ParseBlockTest("@addTagHelper '*, Foo'", @@ -1468,7 +1392,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AsAddTagHelper( "'*, Foo'", "'*, Foo'", - legacyErrors: expectedErrors))); + errors: expectedErrors))); } [Fact] @@ -1498,13 +1422,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var expectedErrors = new[] { - new RazorError( - LegacyResources.FormatParseError_DirectiveMustHaveValue(SyntaxConstants.CSharp.AddTagHelperKeyword), - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 12), - new RazorError( - Resources.FormatInvalidTagHelperLookupText(string.Empty), - new SourceLocation(14, 0, 14), - length: 1), + RazorDiagnosticFactory.CreateParsing_DirectiveMustHaveValue( + new SourceSpan(filePath: null, absoluteIndex: 1, lineIndex: 0, characterIndex: 1, length: 12), SyntaxConstants.CSharp.AddTagHelperKeyword), + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(14, 0, 14), contentLength: 1), string.Empty), }; // Act & Assert @@ -1518,7 +1439,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .Span(SpanKindInternal.Markup, " ", markup: false) .Accepts(AcceptedCharactersInternal.None), Factory.EmptyCSharp() - .AsAddTagHelper(string.Empty, string.Empty, legacyErrors: expectedErrors) + .AsAddTagHelper(string.Empty, string.Empty, errors: expectedErrors) .Accepts(AcceptedCharactersInternal.AnyExceptNewline))); } @@ -1528,16 +1449,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var expectedErrors = new[] { - new RazorError( - LegacyResources.ParseError_Unterminated_String_Literal, - absoluteIndex: 14, lineIndex: 0, columnIndex: 14, length: 1), - new RazorError( - LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(SyntaxConstants.CSharp.AddTagHelperKeyword), - absoluteIndex: 14, lineIndex: 0, columnIndex: 14, length: 4), - new RazorError( - Resources.FormatInvalidTagHelperLookupText("\"Foo"), - new SourceLocation(14, 0, 14), - length: 4), + RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( + new SourceSpan(filePath: null, absoluteIndex: 14, lineIndex: 0, characterIndex: 14, length: 1)), + RazorDiagnosticFactory.CreateParsing_IncompleteQuotesAroundDirective( + new SourceSpan(filePath: null, absoluteIndex: 14, lineIndex: 0, characterIndex: 14, length: 4), SyntaxConstants.CSharp.AddTagHelperKeyword), + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(14, 0, 14), contentLength: 4), "\"Foo"), }; // Act & Assert @@ -1551,7 +1468,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .Span(SpanKindInternal.Markup, " ", markup: false) .Accepts(AcceptedCharactersInternal.None), Factory.Code("\"Foo") - .AsAddTagHelper("\"Foo", "\"Foo", legacyErrors: expectedErrors))); + .AsAddTagHelper("\"Foo", "\"Foo", errors: expectedErrors))); } [Fact] @@ -1560,16 +1477,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var expectedErrors = new[] { - new RazorError( - LegacyResources.ParseError_Unterminated_String_Literal, - absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 1), - new RazorError( - LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(SyntaxConstants.CSharp.AddTagHelperKeyword), - absoluteIndex: 14, lineIndex: 0, columnIndex: 14, length: 4), - new RazorError( - Resources.FormatInvalidTagHelperLookupText("Foo\""), - new SourceLocation(14, 0, 14), - length: 4), + RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( + new SourceSpan(filePath: null, absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 1)), + RazorDiagnosticFactory.CreateParsing_IncompleteQuotesAroundDirective( + new SourceSpan(filePath: null, absoluteIndex: 14, lineIndex: 0, characterIndex: 14, length: 4), SyntaxConstants.CSharp.AddTagHelperKeyword), + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(14, 0, 14), contentLength: 4), "Foo\""), }; // Act & Assert @@ -1583,7 +1496,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .Span(SpanKindInternal.Markup, " ", markup: false) .Accepts(AcceptedCharactersInternal.None), Factory.Code("Foo\"") - .AsAddTagHelper("Foo\"", "Foo\"", legacyErrors: expectedErrors) + .AsAddTagHelper("Foo\"", "Foo\"", errors: expectedErrors) .Accepts(AcceptedCharactersInternal.AnyExceptNewline))); } @@ -1865,24 +1778,20 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var directiveLocation = new SourceLocation(1, 2, 3); - var invalidTagHelperPrefixValueError = - "Invalid tag helper directive '{0}' value. '{1}' is not allowed in prefix '{2}'."; + RazorDiagnostic InvalidPrefixError(int length, char character, string prefix) + { + return RazorDiagnosticFactory.CreateParsing_InvalidTagHelperPrefixValue( + new SourceSpan(directiveLocation, length), SyntaxConstants.CSharp.TagHelperPrefixKeyword, character, prefix); + } - return new TheoryData> + return new TheoryData> { { "th ", directiveLocation, new[] { - new RazorError( - string.Format( - invalidTagHelperPrefixValueError, - SyntaxConstants.CSharp.TagHelperPrefixKeyword, - ' ', - "th "), - directiveLocation, - length: 3) + InvalidPrefixError(3, ' ', "th "), } }, { @@ -1890,14 +1799,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy directiveLocation, new[] { - new RazorError( - string.Format( - invalidTagHelperPrefixValueError, - SyntaxConstants.CSharp.TagHelperPrefixKeyword, - '\t', - "th\t"), - directiveLocation, - length: 3) + InvalidPrefixError(3, '\t', "th\t"), } }, { @@ -1905,14 +1807,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy directiveLocation, new[] { - new RazorError( - string.Format( - invalidTagHelperPrefixValueError, - SyntaxConstants.CSharp.TagHelperPrefixKeyword, - Environment.NewLine[0], - "th" + Environment.NewLine), - directiveLocation, - length: 2 + Environment.NewLine.Length) + InvalidPrefixError(2 + Environment.NewLine.Length, Environment.NewLine[0], "th" + Environment.NewLine), } }, { @@ -1920,14 +1815,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy directiveLocation, new[] { - new RazorError( - string.Format( - invalidTagHelperPrefixValueError, - SyntaxConstants.CSharp.TagHelperPrefixKeyword, - ' ', - " th "), - directiveLocation, - length: 4) + InvalidPrefixError(4, ' ', " th "), } }, { @@ -1935,14 +1823,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy directiveLocation, new[] { - new RazorError( - string.Format( - invalidTagHelperPrefixValueError, - SyntaxConstants.CSharp.TagHelperPrefixKeyword, - '@', - "@"), - directiveLocation, - length: 1) + InvalidPrefixError(1, '@', "@"), } }, { @@ -1950,14 +1831,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy directiveLocation, new[] { - new RazorError( - string.Format( - invalidTagHelperPrefixValueError, - SyntaxConstants.CSharp.TagHelperPrefixKeyword, - '@', - "t@h"), - directiveLocation, - length: 3) + InvalidPrefixError(3, '@', "t@h"), } }, { @@ -1965,14 +1839,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy directiveLocation, new[] { - new RazorError( - string.Format( - invalidTagHelperPrefixValueError, - SyntaxConstants.CSharp.TagHelperPrefixKeyword, - '!', - "!"), - directiveLocation, - length: 1) + InvalidPrefixError(1, '!', "!"), } }, { @@ -1980,14 +1847,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy directiveLocation, new[] { - new RazorError( - string.Format( - invalidTagHelperPrefixValueError, - SyntaxConstants.CSharp.TagHelperPrefixKeyword, - '!', - "!th"), - directiveLocation, - length: 3) + InvalidPrefixError(3, '!', "!th"), } }, }; @@ -2002,7 +1862,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy object expectedErrors) { // Arrange - var expectedDiagnostics = ((IEnumerable)expectedErrors).Select(RazorDiagnostic.Create); + var expectedDiagnostics = (IEnumerable)expectedErrors; var source = TestRazorSourceDocument.Create(); var options = RazorParserOptions.CreateDefault(); var context = new ParserContext(source, options); @@ -2072,22 +1932,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var parser = new CSharpCodeParser(context); - var expectedErrorMessage = string.Format( - "Invalid tag helper directive look up text '{0}'. The correct look up text " + - "format is: \"name, assemblyName\".", - directiveText); - var directive = new CSharpCodeParser.ParsedDirective() { DirectiveText = directiveText }; var diagnostics = new List(); - var expectedError = RazorDiagnostic.Create( - new RazorError( - expectedErrorMessage, - new SourceLocation(1, 2, 3), - errorLength)); + var expectedError = RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(1, 2, 3), errorLength), directiveText); // Act var result = parser.ParseAddOrRemoveDirective(directive, new SourceLocation(1, 2, 3), diagnostics); @@ -2103,11 +1955,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy string document, IEnumerable descriptors, Block expected, - params RazorError[] expectedErrors) + params RazorDiagnostic[] expectedErrors) { var result = ParseCodeBlock(document, descriptors, designTime: false); - EvaluateResults(result, expected, expectedErrors.Select(error => RazorDiagnostic.Create(error)).ToList()); + EvaluateResults(result, expected, expectedErrors); } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpErrorTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpErrorTest.cs index d9be2f5e7b..4d792c1a31 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpErrorTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpErrorTest.cs @@ -19,10 +19,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AsImplicitExpression(KeywordSet) .Accepts(AcceptedCharactersInternal.NonWhiteSpace) ), - new RazorError( - LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS('"'), - new SourceLocation(1, 0, 1), - length: 1)); + RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), + "\"")); } [Fact] @@ -34,10 +33,31 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Code("helper") .AsImplicitExpression(KeywordSet) .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - new RazorError( - LegacyResources.FormatParseError_HelperDirectiveNotAvailable(SyntaxConstants.CSharp.HelperKeyword), - new SourceLocation(1, 0, 1), - length: 6)); + RazorDiagnosticFactory.CreateParsing_HelperDirectiveNotAvailable( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 6))); + } + + [Fact] + public void ParseBlockWithNestedCodeBlockProducesError() + { + ParseBlockTest("@if { @{} }", + new StatementBlock( + Factory.CodeTransition(), + Factory.Code("if { ") + .AsStatement() + .Accepts(AcceptedCharactersInternal.Any), + new StatementBlock( + Factory.CodeTransition(), + Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), + Factory.EmptyCSharp() + .AsStatement() + .AutoCompleteWith(autoCompleteString: null), + Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), + Factory.Code(" }") + .AsStatement() + .Accepts(AcceptedCharactersInternal.Any)), + RazorDiagnosticFactory.CreateParsing_UnexpectedNestedCodeBlock( + new SourceSpan(new SourceLocation(7, 0, 7), contentLength: 1))); } [Fact] @@ -60,10 +80,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AsStatement() .With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = "}" }) ), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(LegacyResources.BlockName_Code, "}", "{"), - SourceLocation.Zero, - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), Resources.BlockName_Code, "}", "{")); } [Fact] @@ -88,10 +106,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.EmptyCSharp() .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - new RazorError( - LegacyResources.ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS, - new SourceLocation(1, 0, 1), - Environment.NewLine.Length)); + RazorDiagnosticFactory.CreateParsing_UnexpectedWhiteSpaceAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(1, 0, 1), Environment.NewLine.Length))); } [Fact] @@ -113,10 +129,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Code(" {}" + Environment.NewLine).AsStatement(), Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) ), - new RazorError( - LegacyResources.ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS, - new SourceLocation(6 + Environment.NewLine.Length, 1, 5), - length: 3)); + RazorDiagnosticFactory.CreateParsing_UnexpectedWhiteSpaceAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(6 + Environment.NewLine.Length, 1, 5), contentLength: 3))); } [Fact] @@ -136,13 +150,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), Factory.EmptyCSharp().AsStatement() ), - new RazorError( - LegacyResources.ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock, - 6 + Environment.NewLine.Length, 1, 5, length: 1), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(LegacyResources.BlockName_Code, "}", "{"), - SourceLocation.Zero, - length: 1)); + RazorDiagnosticFactory.CreateParsing_UnexpectedEndOfFileAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(6 + Environment.NewLine.Length, 1, 5), contentLength: 1)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), Resources.BlockName_Code, "}", "{")); } [Fact] @@ -154,10 +165,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.EmptyCSharp() .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - new RazorError( - LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("!"), - new SourceLocation(1, 0, 1), - length: 1)); + RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), + "!")); } [Fact] @@ -169,10 +179,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), Factory.Code($"foo bar{Environment.NewLine}baz").AsExpression() ), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(LegacyResources.BlockName_ExplicitExpression, ')', '('), - SourceLocation.Zero, - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), Resources.BlockName_ExplicitExpression, ")", "(")); } [Fact] @@ -186,10 +194,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), Factory.Code($"foo bar{Environment.NewLine}").AsExpression() ), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(LegacyResources.BlockName_ExplicitExpression, ')', '('), - SourceLocation.Zero, - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), Resources.BlockName_ExplicitExpression, ")", "(")); } [Fact] @@ -201,10 +207,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Code("Href(" + Environment.NewLine) .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) ), - new RazorError( - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"), - new SourceLocation(4, 0, 4), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(4, 0, 4), contentLength: 1), "(", ")")); } [Fact] @@ -218,10 +222,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Code($"Foo(Bar(Baz){Environment.NewLine}Biz{Environment.NewLine}Boz") .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) ), - new RazorError( - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"), - new SourceLocation(3, 0, 3), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(3, 0, 3), contentLength: 1), "(", ")")); } [Fact] @@ -237,10 +239,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Code($"Foo(Bar(Baz){Environment.NewLine}Biz{Environment.NewLine}") .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) ), - new RazorError( - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"), - new SourceLocation(3, 0, 3), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(3, 0, 3), contentLength: 1), "(", ")")); } [Fact] @@ -254,10 +254,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Code($"Foo[Bar[Baz]{Environment.NewLine}Biz{Environment.NewLine}Boz") .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) ), - new RazorError( - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("[", "]"), - new SourceLocation(3, 0, 3), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(3, 0, 3), contentLength: 1), "[", "]")); } [Fact] @@ -273,10 +271,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Code($"Foo[Bar[Baz]{Environment.NewLine}Biz{Environment.NewLine}") .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) ), - new RazorError( - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("[", "]"), - new SourceLocation(3, 0, 3), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(3, 0, 3), contentLength: 1), "[", "]")); } // Simple EOF handling errors: @@ -289,11 +285,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Code(" var foo = bar; if(foo != null) { bar(); } ") .AsStatement() .AutoCompleteWith("}")), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF( - LegacyResources.BlockName_Code, '}', '{'), - SourceLocation.Zero, - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), Resources.BlockName_Code, "}", "{")); } [Fact] @@ -302,11 +295,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(FunctionsDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("functions", '}', '{'), - new SourceLocation(10, 0, 10), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(10, 0, 10), contentLength: 1), "functions", "}", "{")); // Act & Assert ParseBlockTest( @@ -332,10 +322,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new StatementBlock( Factory.Code("if(foo) { baz(); } else { var foo = bar; if(foo != null) { bar(); } ").AsStatement() ), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("else", '}', '{'), - new SourceLocation(19, 0, 19), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(19, 0, 19), contentLength: 1), "else", "}", "{")); } [Fact] @@ -345,10 +333,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new StatementBlock( Factory.Code("if(foo) { baz(); } else if { var foo = bar; if(foo != null) { bar(); } ").AsStatement() ), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("else if", '}', '{'), - new SourceLocation(19, 0, 19), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(19, 0, 19), contentLength: 1), "else if", "}", "{")); } [Fact] @@ -358,10 +344,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new StatementBlock( Factory.Code("do { var foo = bar; if(foo != null) { bar(); } ").AsStatement() ), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("do", '}', '{'), - SourceLocation.Zero, - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), "do", "}", "{")); } [Fact] @@ -371,10 +355,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new StatementBlock( Factory.Code("try { var foo = bar; if(foo != null) { bar(); } ").AsStatement() ), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("try", '}', '{'), - SourceLocation.Zero, - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), "try", "}", "{")); } [Fact] @@ -384,10 +366,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new StatementBlock( Factory.Code("try { baz(); } catch(Foo) { var foo = bar; if(foo != null) { bar(); } ").AsStatement() ), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("catch", '}', '{'), - new SourceLocation(15, 0, 15), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(15, 0, 15), contentLength: 1), "catch", "}", "{")); } [Fact] @@ -397,10 +377,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new StatementBlock( Factory.Code("try { baz(); } finally { var foo = bar; if(foo != null) { bar(); } ").AsStatement() ), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("finally", '}', '{'), - new SourceLocation(15, 0, 15), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(15, 0, 15), contentLength: 1), "finally", "}", "{")); } [Fact] @@ -442,7 +420,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy [Fact] public void ParseBlockRequiresControlFlowStatementsToHaveBraces() { - var expectedMessage = LegacyResources.FormatParseError_SingleLine_ControlFlowStatements_Not_Allowed("{", "<"); + var expectedMessage = Resources.FormatParseError_SingleLine_ControlFlowStatements_Not_Allowed("{", "<"); ParseBlockTest("if(foo)

Bar

else if(bar)

Baz

else

Boz

", new StatementBlock( Factory.Code("if(foo) ").AsStatement(), @@ -464,9 +442,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None)), Factory.EmptyCSharp().AsStatement() ), - new RazorError(expectedMessage, 8, 0, 8, 1), - new RazorError(expectedMessage, 32, 0, 32, 1), - new RazorError(expectedMessage, 48, 0, 48, 1)); + RazorDiagnosticFactory.CreateParsing_SingleLineControlFlowStatementsNotAllowed( + new SourceSpan(new SourceLocation(8, 0, 8), contentLength: 1), "{", "<"), + RazorDiagnosticFactory.CreateParsing_SingleLineControlFlowStatementsNotAllowed( + new SourceSpan(new SourceLocation(32, 0, 32), contentLength: 1), "{", "<"), + RazorDiagnosticFactory.CreateParsing_SingleLineControlFlowStatementsNotAllowed( + new SourceSpan(new SourceLocation(48, 0, 48), contentLength: 1), "{", "<")); } [Fact] @@ -476,10 +457,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new StatementBlock( Factory.Code("if(foo)) { var bar = foo; }").AsStatement() ), - new RazorError( - LegacyResources.FormatParseError_SingleLine_ControlFlowStatements_Not_Allowed("{", ")"), - new SourceLocation(7, 0, 7), - length: 1)); + RazorDiagnosticFactory.CreateParsing_SingleLineControlFlowStatementsNotAllowed( + new SourceSpan(new SourceLocation(7, 0, 7), contentLength: 1), "{", ")")); } [Fact] @@ -497,10 +476,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)), Factory.Code("}").AsStatement() ), - new RazorError( - LegacyResources.ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start, - new SourceLocation(10, 0, 10), - length: 1)); + RazorDiagnosticFactory.CreateParsing_AtInCodeMustBeFollowedByColonParenOrIdentifierStart( + new SourceSpan(new SourceLocation(10, 0, 10), contentLength: 1))); } [Fact] @@ -511,10 +488,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new StatementBlock( Factory.Code("if(foo bar" + Environment.NewLine).AsStatement() ), - new RazorError( - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"), - new SourceLocation(2, 0, 2), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 1), "(", ")")); } [Fact] @@ -525,10 +500,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new StatementBlock( Factory.Code("foreach(foo bar" + Environment.NewLine).AsStatement() ), - new RazorError( - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"), - new SourceLocation(7, 0, 7), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(7, 0, 7), contentLength: 1), "(", ")")); } [Fact] @@ -539,10 +512,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new StatementBlock( Factory.Code("do { } while(foo bar" + Environment.NewLine).AsStatement() ), - new RazorError( - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"), - new SourceLocation(12, 0, 12), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(12, 0, 12), contentLength: 1), "(", ")")); } [Fact] @@ -553,10 +524,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new StatementBlock( Factory.Code("using(foo bar" + Environment.NewLine).AsStatement() ), - new RazorError( - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"), - new SourceLocation(5, 0, 5), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(5, 0, 5), contentLength: 1), "(", ")")); } [Fact] @@ -574,10 +543,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)), Factory.Code("}").AsStatement().Accepts(AcceptedCharactersInternal.None) ), - new RazorError( - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"), - new SourceLocation(2, 0, 2), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 1), "(", ")")); } [Fact] @@ -588,24 +555,18 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy + ";" + Environment.NewLine + "}", BlockKindInternal.Statement, SpanKindInternal.Code, - new RazorError( - LegacyResources.ParseError_Unterminated_String_Literal, - new SourceLocation(21 + Environment.NewLine.Length, 1, 12), - length: 1)); + RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( + new SourceSpan(new SourceLocation(21 + Environment.NewLine.Length, 1, 12), contentLength: 1))); } [Fact] public void ParseBlockTerminatesNormalStringAtEndOfFile() { SingleSpanBlockTest("if(foo) { var foo = \"blah blah blah blah blah", BlockKindInternal.Statement, SpanKindInternal.Code, - new RazorError( - LegacyResources.ParseError_Unterminated_String_Literal, - new SourceLocation(20, 0, 20), - length: 1), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("if", '}', '{'), - SourceLocation.Zero, - length: 1)); + RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( + new SourceSpan(new SourceLocation(20, 0, 20), contentLength: 1)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), "if", "}", "{")); } [Fact] @@ -617,14 +578,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy + "blah " + Environment.NewLine + "blah", BlockKindInternal.Statement, SpanKindInternal.Code, - new RazorError( - LegacyResources.ParseError_Unterminated_String_Literal, - new SourceLocation(20, 0, 20), - length: 1), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("if", '}', '{'), - SourceLocation.Zero, - length: 1)); + RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( + new SourceSpan(new SourceLocation(20, 0, 20), contentLength: 1)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), "if", "}", "{")); } [Fact] @@ -648,10 +605,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Markup(Environment.NewLine).Accepts(AcceptedCharactersInternal.None)), Factory.Code("}").AsStatement() ), - new RazorError( - LegacyResources.ParseError_Unterminated_String_Literal, - new SourceLocation(23 + Environment.NewLine.Length, 1, 14), - length: 1)); + RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( + new SourceSpan(new SourceLocation(23 + Environment.NewLine.Length, 1, 14), contentLength: 1))); } [Fact] @@ -681,12 +636,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), expectedErrors: new[] { - new RazorError( - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"), - new SourceLocation(14, 0, 14), - length: 1) + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(14, 0, 14), contentLength: 1), "(", ")"), }); - } private void RunUnterminatedSimpleKeywordBlock(string keyword) @@ -695,10 +647,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy keyword + " (foo) { var foo = bar; if(foo != null) { bar(); } ", BlockKindInternal.Statement, SpanKindInternal.Code, - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(keyword, '}', '{'), - SourceLocation.Zero, - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), keyword, "}", "{")); } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpExplicitExpressionTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpExplicitExpressionTest.cs index 83e0b9f2c1..afc2afa90a 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpExplicitExpressionTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpExplicitExpressionTest.cs @@ -29,11 +29,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), Factory.EmptyCSharp().AsExpression() ), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF( - LegacyResources.BlockName_ExplicitExpression, ")", "("), - new SourceLocation(1, 0, 1), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), + Resources.BlockName_ExplicitExpression, + ")", + "(")); } [Fact] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpImplicitExpressionTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpImplicitExpressionTest.cs index ce82632a59..3a013a6ec8 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpImplicitExpressionTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpImplicitExpressionTest.cs @@ -14,26 +14,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { get { - var noErrors = new RazorError[0]; - Func missingEndParenError = (index) => - new RazorError[1] + var noErrors = new RazorDiagnostic[0]; + Func missingEndBracketError = (index) => + new RazorDiagnostic[1] { - new RazorError( - "An opening \"(\" is missing the corresponding closing \")\".", - new SourceLocation(index, 0, index), - length: 1) - }; - Func missingEndBracketError = (index) => - new RazorError[1] - { - new RazorError( - "An opening \"[\" is missing the corresponding closing \"]\".", - new SourceLocation(index, 0, index), - length: 1) + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(index, 0, index), contentLength: 1), "[", "]"), }; // implicitExpression, expectedImplicitExpression, acceptedCharacters, expectedErrors - return new TheoryData + return new TheoryData { { "val??[", "val", AcceptedCharactersInternal.NonWhiteSpace, noErrors }, { "val??[0", "val", AcceptedCharactersInternal.NonWhiteSpace, noErrors }, @@ -68,7 +58,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy implicitExpresison, expectedImplicitExpression, (AcceptedCharactersInternal)acceptedCharacters, - (RazorError[])expectedErrors); + (RazorDiagnostic[])expectedErrors); } public static TheoryData NullConditionalOperatorData_Dot @@ -135,10 +125,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.EmptyCSharp() .AsImplicitExpression(KeywordSet) .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - new RazorError( - LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("/"), - new SourceLocation(1, 0, 1), - length: 1)); + RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), + "/")); } [Fact] @@ -150,10 +139,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.EmptyCSharp() .AsImplicitExpression(KeywordSet) .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - new RazorError( - LegacyResources.ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock, - new SourceLocation(1, 0, 1), - length: 1)); + RazorDiagnosticFactory.CreateParsing_UnexpectedEndOfFileAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1))); } [Fact] @@ -253,10 +240,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy ImplicitExpressionTest( "foo(()", "foo(()", acceptedCharacters: AcceptedCharactersInternal.Any, - errors: new RazorError( - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"), - new SourceLocation(4, 0, 4), - length: 1)); + errors: RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(4, 0, 4), contentLength: 1), "(", ")")); } [Fact] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpRazorCommentsTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpRazorCommentsTest.cs index c4ec18b465..eb626f3abe 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpRazorCommentsTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpRazorCommentsTest.cs @@ -25,10 +25,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy string.Empty, HtmlSymbolType.Unknown)) .Accepts(AcceptedCharactersInternal.Any))), - new RazorError( - LegacyResources.ParseError_RazorComment_Not_Terminated, - SourceLocation.Zero, - length: 2)); + RazorDiagnosticFactory.CreateParsing_RazorCommentNotTerminated( + new SourceSpan(SourceLocation.Zero, contentLength: 2))); } [Fact] @@ -79,10 +77,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .Accepts(AcceptedCharactersInternal.None)), Factory.Code(Environment.NewLine) .AsImplicitExpression(CSharpCodeParser.DefaultKeywords))), - new RazorError( - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"), - new SourceLocation(4, 0, 4), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(4, 0, 4), contentLength: 1), "(", ")")); } [Fact] @@ -104,14 +100,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy string.Empty, CSharpSymbolType.Unknown)) .Accepts(AcceptedCharactersInternal.Any)))), - new RazorError( - LegacyResources.ParseError_RazorComment_Not_Terminated, - new SourceLocation(5, 0, 5), - length: 2), - new RazorError( - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"), - new SourceLocation(4, 0, 4), - length: 1)); + RazorDiagnosticFactory.CreateParsing_RazorCommentNotTerminated( + new SourceSpan(new SourceLocation(5, 0, 5), contentLength: 2)), + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(4, 0, 4), contentLength: 1), "(", ")")); } [Fact] @@ -149,18 +141,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .Accepts(AcceptedCharactersInternal.None)), Factory.Markup(Environment.NewLine).With(SpanChunkGenerator.Null), Factory.Markup("}")))), - new RazorError( - LegacyResources.ParseError_TextTagCannotContainAttributes, - new SourceLocation(7 + Environment.NewLine.Length, 1, 5), - length: 4), - new RazorError( - LegacyResources.FormatParseError_MissingEndTag("text"), - new SourceLocation(7 + Environment.NewLine.Length, 1, 5), - length: 4), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(LegacyResources.BlockName_Code, "}", "{"), - new SourceLocation(1, 0, 1), - length: 1)); + RazorDiagnosticFactory.CreateParsing_TextTagCannotContainAttributes( + new SourceSpan(new SourceLocation(7 + Environment.NewLine.Length, 1, 5), contentLength: 4)), + RazorDiagnosticFactory.CreateParsing_MissingEndTag( + new SourceSpan(new SourceLocation(7 + Environment.NewLine.Length, 1, 5), contentLength: 4), "text"), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{")); } [Fact] @@ -182,15 +168,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .Accepts(AcceptedCharactersInternal.None), Factory.Span(SpanKindInternal.Comment, new CSharpSymbol(string.Empty, CSharpSymbolType.Unknown)) .Accepts(AcceptedCharactersInternal.Any)))), - new RazorError( - LegacyResources.ParseError_RazorComment_Not_Terminated, - new SourceLocation(2, 0, 2), - length: 2), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF( - LegacyResources.BlockName_Code, "}", "{"), - new SourceLocation(1, 0, 1), - length: 1)); + RazorDiagnosticFactory.CreateParsing_RazorCommentNotTerminated( + new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 2)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{")); } [Fact] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpReservedWordsTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpReservedWordsTest.cs index ce0382e7c6..21a2dacf19 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpReservedWordsTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpReservedWordsTest.cs @@ -16,10 +16,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new DirectiveBlock( Factory.MetaCode(word).Accepts(AcceptedCharactersInternal.None) ), - new RazorError( - LegacyResources.FormatParseError_ReservedWord(word), - SourceLocation.Zero, - word.Length)); + RazorDiagnosticFactory.CreateParsing_ReservedWord( + new SourceSpan(SourceLocation.Zero, word.Length), word)); } [Theory] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSectionTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSectionTest.cs index 2966814826..3ae95b1994 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSectionTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSectionTest.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Linq; using Microsoft.AspNetCore.Razor.Language.Extensions; using Xunit; @@ -16,11 +15,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsIdentifier(SectionDirective.Directive.Directive), - new SourceLocation(8, 0, 8), - length: Environment.NewLine.Length))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsIdentifier( + new SourceSpan(new SourceLocation(8, 0, 8), contentLength: Environment.NewLine.Length), SectionDirective.Directive.Directive)); // Act & Assert ParseDocumentTest( @@ -42,11 +38,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatUnexpectedEOFAfterDirective(SectionDirective.Directive.Directive, "{"), - new SourceLocation(25 + Environment.NewLine.Length, 0, 25 + Environment.NewLine.Length), - length: 1))); + RazorDiagnosticFactory.CreateParsing_UnexpectedEOFAfterDirective( + new SourceSpan(new SourceLocation(25 + Environment.NewLine.Length, 1, 4), contentLength: 1), + SectionDirective.Directive.Directive, + "{")); // Act & Assert ParseDocumentTest( @@ -69,11 +64,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsIdentifier(SectionDirective.Directive.Directive), - new SourceLocation(17, 0, 17), - length: Environment.NewLine.Length))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsIdentifier( + new SourceSpan(new SourceLocation(17, 0, 17), contentLength: Environment.NewLine.Length), SectionDirective.Directive.Directive)); // Act & Assert ParseDocumentTest( @@ -113,11 +105,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsIdentifier(SectionDirective.Directive.Directive), - new SourceLocation(9, 0, 9), - length: 1))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsIdentifier( + new SourceSpan(new SourceLocation(9, 0, 9), contentLength: 1), SectionDirective.Directive.Directive)); // Act & Assert ParseDocumentTest( @@ -144,11 +133,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatUnexpectedDirectiveLiteral(SectionDirective.Directive.Directive, "{"), - new SourceLocation(12, 0, 12), - length: 1))); + RazorDiagnosticFactory.CreateParsing_UnexpectedDirectiveLiteral( + new SourceSpan(new SourceLocation(12, 0, 12), contentLength: 1), + SectionDirective.Directive.Directive, + "{")); // Act & Assert ParseDocumentTest( @@ -176,17 +164,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var erroredChunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); erroredChunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - Resources.FormatDirectiveMustAppearAtStartOfLine("section"), - new SourceLocation(16, 0, 16), - 7))); + RazorDiagnosticFactory.CreateParsing_DirectiveMustAppearAtStartOfLine( + new SourceSpan(new SourceLocation(16, 0, 16), contentLength: 7), "section")); erroredChunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Sections_Cannot_Be_Nested(LegacyResources.SectionExample_CS), - new SourceLocation(15, 0, 15), - 8))); + RazorDiagnosticFactory.CreateParsing_SectionsCannotBeNested( + new SourceSpan(new SourceLocation(15, 0, 15), 8))); // Act & Assert ParseDocumentTest( @@ -230,11 +212,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(SectionDirective.Directive.Directive, "}", "{"), - new SourceLocation(13, 0, 13), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(13, 0, 13), contentLength: 1), SectionDirective.Directive.Directive, "}", "{")); // Act & Assert ParseDocumentTest( @@ -263,11 +242,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("section", "}", "{"), - new SourceLocation(13, 0, 13), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(13, 0, 13), contentLength: 1), "section", "}", "{")); // Act & Assert ParseDocumentTest( @@ -292,11 +268,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("section", "}", "{"), - new SourceLocation(13, 0, 13), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(13, 0, 13), contentLength: 1), "section", "}", "{")); // Act & Assert ParseDocumentTest( @@ -328,11 +301,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var newLine = Environment.NewLine; var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("section", "}", "{"), - new SourceLocation(13 + newLine.Length, 1, 0), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(13 + newLine.Length, 1, 0), contentLength: 1), "section", "}", "{")); var spaces = " "; // Act & Assert @@ -372,11 +342,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatUnexpectedEOFAfterDirective(SectionDirective.Directive.Directive, "{"), - new SourceLocation(18 + Environment.NewLine.Length, 0, 18 + Environment.NewLine.Length), - length: 1))); + RazorDiagnosticFactory.CreateParsing_UnexpectedEOFAfterDirective( + new SourceSpan(new SourceLocation(18 + Environment.NewLine.Length, 1, 0), contentLength: 1), + SectionDirective.Directive.Directive, + "{")); // Act & Assert ParseDocumentTest( diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSpecialBlockTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSpecialBlockTest.cs index 69e78889f9..ca472f33f5 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSpecialBlockTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSpecialBlockTest.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Linq; using Microsoft.AspNetCore.Razor.Language.Extensions; using Xunit; @@ -16,10 +15,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(InheritsDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatUnexpectedEOFAfterDirective(InheritsDirective.Directive.Directive, "type"), - new SourceLocation(9, 0, 9), 1))); + RazorDiagnosticFactory.CreateParsing_UnexpectedEOFAfterDirective( + new SourceSpan(new SourceLocation(9, 0, 9), 1), InheritsDirective.Directive.Directive, "type")); // Act & Assert ParseDocumentTest( @@ -57,10 +54,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(InheritsDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsTypeName(InheritsDirective.Directive.Directive), - 25, 0, 25, Environment.NewLine.Length))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsTypeName( + new SourceSpan(new SourceLocation(25, 0, 25), Environment.NewLine.Length), + InheritsDirective.Directive.Directive)); // Act & Assert ParseDocumentTest( @@ -88,10 +84,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AutoCompleteWith(autoCompleteString: null), Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) ), - new RazorError( - LegacyResources.ParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock, - new SourceLocation(2, 0, 2), - length: 5)); + RazorDiagnosticFactory.CreateParsing_NamespaceImportAndTypeAliasCannotExistWithinCodeBlock( + new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 5))); } [Fact] @@ -105,10 +99,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AutoCompleteWith(autoCompleteString: null), Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) ), - new RazorError( - LegacyResources.ParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock, - new SourceLocation(2, 0, 2), - length: 5)); + RazorDiagnosticFactory.CreateParsing_NamespaceImportAndTypeAliasCannotExistWithinCodeBlock( + new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 5))); } [Fact] @@ -192,11 +184,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(FunctionsDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("functions", "}", "{"), - new SourceLocation(10, 0, 10), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(10, 0, 10), contentLength: 1), "functions", "}", "{")); // Act & Assert ParseBlockTest( @@ -228,10 +217,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.EmptyCSharp() .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - new RazorError( - LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("/"), - new SourceLocation(1, 0, 1), - length: 1)); + RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), + "/")); } [Fact] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpStatementTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpStatementTest.cs index 490d252688..0d3a485441 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpStatementTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpStatementTest.cs @@ -248,13 +248,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy get { var factory = new SpanFactory(); - var unbalancedParenErrorString = "An opening \"(\" is missing the corresponding closing \")\"."; - var unbalancedBracketCatchErrorString = "The catch block is missing a closing \"}\" character. " + - "Make sure you have a matching \"}\" character for all the \"{\" characters within this block, " + - "and that none of the \"}\" characters are being interpreted as markup."; // document, expectedStatement, expectedErrors - return new TheoryData + return new TheoryData { { "@try { someMethod(); } catch(Exception) when (", @@ -263,7 +259,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory .Code("try { someMethod(); } catch(Exception) when (") .AsStatement()), - new[] { new RazorError(unbalancedParenErrorString, 45, 0, 45, 1) } + new[] + { + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(45, 0, 45), contentLength: 1), "(", ")"), + } }, { "@try { someMethod(); } catch(Exception) when (someMethod(", @@ -272,7 +272,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory .Code("try { someMethod(); } catch(Exception) when (someMethod(") .AsStatement()), - new[] { new RazorError(unbalancedParenErrorString, 45, 0, 45, 1) } + new[] + { + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(45, 0, 45), contentLength: 1), "(", ")"), + } }, { "@try { someMethod(); } catch(Exception) when (true) {", @@ -281,7 +285,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory .Code("try { someMethod(); } catch(Exception) when (true) {") .AsStatement()), - new[] { new RazorError(unbalancedBracketCatchErrorString, 23, 0, 23, 1) } + new[] + { + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(23, 0, 23), contentLength: 1), "catch", "}", "{"), + } }, }; } @@ -297,7 +305,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy FixupSpans = true; // Act & Assert - ParseBlockTest(document, (StatementBlock)expectedStatement, (RazorError[])expectedErrors); + ParseBlockTest(document, (StatementBlock)expectedStatement, (RazorDiagnostic[])expectedErrors); } [Fact] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTemplateTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTemplateTest.cs index 775f2a3c4f..0631ff1c7f 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTemplateTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTemplateTest.cs @@ -312,12 +312,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy ParseBlockTest("{ var foo = bar; Html.ExecuteTemplate(foo," + testTemplateWithDoubleTransitionCode + "); }", expected); } - private static RazorError GetNestedTemplateError(int characterIndex) + private static RazorDiagnostic GetNestedTemplateError(int characterIndex) { - return new RazorError( - LegacyResources.ParseError_InlineMarkup_Blocks_Cannot_Be_Nested, - new SourceLocation(characterIndex, 0, characterIndex), - length: 1); + return RazorDiagnosticFactory.CreateParsing_InlineMarkupBlocksCannotBeNested( + new SourceSpan(new SourceLocation(characterIndex, 0, characterIndex), contentLength: 1)); } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpToMarkupSwitchTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpToMarkupSwitchTest.cs index fa51eb681f..1d96a65590 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpToMarkupSwitchTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpToMarkupSwitchTest.cs @@ -111,10 +111,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Code(" " + Environment.NewLine).AsStatement(), Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) ), true, - new RazorError( - LegacyResources.ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start, - new SourceLocation(5 + Environment.NewLine.Length, 1, 4), - length: 1)); + RazorDiagnosticFactory.CreateParsing_AtInCodeMustBeFollowedByColonParenOrIdentifierStart( + new SourceSpan(new SourceLocation(5 + Environment.NewLine.Length, 1, 4), contentLength: 1))); } [Fact] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpVerbatimBlockTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpVerbatimBlockTest.cs index dde4e6e58c..903e68f313 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpVerbatimBlockTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpVerbatimBlockTest.cs @@ -44,10 +44,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy designTime: true, expectedErrors: new[] { - new RazorError( - LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("}"), - new SourceLocation(2, 0, 2), - length: 1) + RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 1), + "}") }); } @@ -69,10 +68,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy designTime: true, expectedErrors: new[] { - new RazorError( - LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("."), - new SourceLocation(2, 0, 2), - length: 1) + RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 1), + ".") }); } @@ -94,10 +92,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Code(Environment.NewLine).AsStatement(), Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), /* designTimeParser */ true, - new RazorError( - LegacyResources.ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS, - new SourceLocation(6 + Environment.NewLine.Length, 1, 5), - Environment.NewLine.Length)); + RazorDiagnosticFactory.CreateParsing_UnexpectedWhiteSpaceAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(6 + Environment.NewLine.Length, 1, 5), Environment.NewLine.Length))); } [Fact] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CodeParserTestBase.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CodeParserTestBase.cs index f67b159189..f0af2d1530 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CodeParserTestBase.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CodeParserTestBase.cs @@ -14,17 +14,17 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return ParseCodeBlock(document, directives, designTime); } - internal void ImplicitExpressionTest(string input, params RazorError[] errors) + internal void ImplicitExpressionTest(string input, params RazorDiagnostic[] errors) { ImplicitExpressionTest(input, AcceptedCharactersInternal.NonWhiteSpace, errors); } - internal void ImplicitExpressionTest(string input, AcceptedCharactersInternal acceptedCharacters, params RazorError[] errors) + internal void ImplicitExpressionTest(string input, AcceptedCharactersInternal acceptedCharacters, params RazorDiagnostic[] errors) { ImplicitExpressionTest(input, input, acceptedCharacters, errors); } - internal void ImplicitExpressionTest(string input, string expected, params RazorError[] errors) + internal void ImplicitExpressionTest(string input, string expected, params RazorDiagnostic[] errors) { ImplicitExpressionTest(input, expected, AcceptedCharactersInternal.NonWhiteSpace, errors); } @@ -39,28 +39,28 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy SingleSpanBlockTest(document, spanContent, blockKind, spanType, acceptedCharacters, expectedErrors: null); } - internal override void SingleSpanBlockTest(string document, BlockKindInternal blockKind, SpanKindInternal spanType, params RazorError[] expectedError) + internal override void SingleSpanBlockTest(string document, BlockKindInternal blockKind, SpanKindInternal spanType, params RazorDiagnostic[] expectedError) { SingleSpanBlockTest(document, document, blockKind, spanType, expectedError); } - internal override void SingleSpanBlockTest(string document, string spanContent, BlockKindInternal blockKind, SpanKindInternal spanType, params RazorError[] expectedErrors) + internal override void SingleSpanBlockTest(string document, string spanContent, BlockKindInternal blockKind, SpanKindInternal spanType, params RazorDiagnostic[] expectedErrors) { - SingleSpanBlockTest(document, spanContent, blockKind, spanType, AcceptedCharactersInternal.Any, expectedErrors ?? new RazorError[0]); + SingleSpanBlockTest(document, spanContent, blockKind, spanType, AcceptedCharactersInternal.Any, expectedErrors ?? new RazorDiagnostic[0]); } - internal override void SingleSpanBlockTest(string document, BlockKindInternal blockKind, SpanKindInternal spanType, AcceptedCharactersInternal acceptedCharacters, params RazorError[] expectedError) + internal override void SingleSpanBlockTest(string document, BlockKindInternal blockKind, SpanKindInternal spanType, AcceptedCharactersInternal acceptedCharacters, params RazorDiagnostic[] expectedError) { SingleSpanBlockTest(document, document, blockKind, spanType, acceptedCharacters, expectedError); } - internal override void SingleSpanBlockTest(string document, string spanContent, BlockKindInternal blockKind, SpanKindInternal spanType, AcceptedCharactersInternal acceptedCharacters, params RazorError[] expectedErrors) + internal override void SingleSpanBlockTest(string document, string spanContent, BlockKindInternal blockKind, SpanKindInternal spanType, AcceptedCharactersInternal acceptedCharacters, params RazorDiagnostic[] expectedErrors) { var b = CreateSimpleBlockAndSpan(spanContent, blockKind, spanType, acceptedCharacters); - ParseBlockTest(document, b, expectedErrors ?? new RazorError[0]); + ParseBlockTest(document, b, expectedErrors ?? new RazorDiagnostic[0]); } - internal void ImplicitExpressionTest(string input, string expected, AcceptedCharactersInternal acceptedCharacters, params RazorError[] errors) + internal void ImplicitExpressionTest(string input, string expected, AcceptedCharactersInternal acceptedCharacters, params RazorDiagnostic[] errors) { var factory = CreateSpanFactory(); ParseBlockTest(SyntaxConstants.TransitionString + input, diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlAttributeTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlAttributeTest.cs index e074835fd1..8687be85d3 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlAttributeTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlAttributeTest.cs @@ -40,11 +40,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var suffixLocation1 = new SourceLocation( absoluteIndex: 8 + newlineLength + attributeNameLength, lineIndex: 1, - characterIndex: 5 + attributeNameLength); + characterIndex: 5); var valueLocation1 = new SourceLocation( absoluteIndex: 5 + attributeNameLength + newlineLength, lineIndex: 1, - characterIndex: 2 + attributeNameLength); + characterIndex: 2); var prefixLocation2 = SourceLocationTracker.Advance(suffixLocation1, "'"); var suffixLocation2 = new SourceLocation( absoluteIndex: 15 + attributeNameLength * 2 + newlineLength * 2, @@ -102,7 +102,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var suffixLocation1 = new SourceLocation( absoluteIndex: 10 + newlineLength + attributeNameLength, lineIndex: 1, - characterIndex: 5 + attributeNameLength + newlineLength); + characterIndex: 7 + attributeNameLength); var valueLocation1 = new SourceLocation( absoluteIndex: 7 + attributeNameLength + newlineLength, lineIndex: 1, diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlBlockTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlBlockTest.cs index f0cf332e1f..f54ba50d37 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlBlockTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlBlockTest.cs @@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.EmptyCSharp().AsStatement(), Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), Factory.EmptyHtml()), - new RazorError[0]); + new RazorDiagnostic[0]); } [Fact] @@ -47,11 +47,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock( new MarkupTagBlock( Factory.Markup("<"))))), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF( - LegacyResources.BlockName_Code, "}", "{"), - new SourceLocation(1, 0, 1), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{")); } [Fact] @@ -82,14 +79,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy designTime: true, expectedErrors: new[] { - new RazorError( - LegacyResources.FormatParseError_UnexpectedEndTag("html"), - new SourceLocation(5 + Environment.NewLine.Length * 2, 2, 2), - length: 4), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("code", "}", "{"), - new SourceLocation(1, 0, 1), - length: 1) + RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag( + new SourceSpan(new SourceLocation(5 + Environment.NewLine.Length * 2, 2, 2), contentLength: 4), "html"), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), }); } @@ -102,10 +95,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupTagBlock( Factory.Markup($"< {Environment.NewLine} "))), designTime: true, - expectedErrors: new RazorError( - LegacyResources.FormatParseError_UnfinishedTag(string.Empty), - new SourceLocation(1, 0, 1), - length: 1)); + expectedErrors: RazorDiagnosticFactory.CreateParsing_UnfinishedTag( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), string.Empty)); } [Fact] @@ -335,10 +326,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock( new MarkupTagBlock( Factory.Markup("").Accepts(AcceptedCharactersInternal.None))), - new RazorError( - LegacyResources.FormatParseError_MissingEndTag("foo"), - new SourceLocation(1, 0, 1), - length: 3)); + RazorDiagnosticFactory.CreateParsing_MissingEndTag( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 3), "foo")); } [Fact] @@ -458,10 +447,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), new MarkupTagBlock( Factory.Markup("").Accepts(AcceptedCharactersInternal.None))), - new RazorError( - LegacyResources.FormatParseError_MissingEndTag("foo"), - new SourceLocation(1, 0, 1), - length: 3)); + RazorDiagnosticFactory.CreateParsing_MissingEndTag( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 3), "foo")); } @@ -620,10 +607,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock( new MarkupTagBlock( Factory.Markup("
"))); - var expectedErrors = new RazorError[] + var expectedErrors = new RazorDiagnostic[] { - new RazorError( - @"A space or line break was encountered after the ""@"" character. Only valid identifiers, keywords, comments, ""("" and ""{"" are valid at the start of a code block and they must occur immediately following ""@"" with no space in between.", - new SourceLocation(12, 0, 12), - length: 1), - new RazorError( - @"""' />"" is not valid at the start of a code block. Only identifiers, keywords, comments, ""("" and ""{"" are valid.", - new SourceLocation(14, 0, 14), - length: 4), + RazorDiagnosticFactory.CreateParsing_UnexpectedWhiteSpaceAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(12, 0, 12), contentLength: 1)), + RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(14, 0, 14), contentLength: 4), + "' />"), }; // Act & Assert diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlErrorTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlErrorTest.cs index 0856a18c43..497fceedaa 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlErrorTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlErrorTest.cs @@ -28,10 +28,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.MarkupTransition("").Accepts(AcceptedCharactersInternal.Any)), new MarkupTagBlock( Factory.MarkupTransition(""))), - new RazorError( - LegacyResources.ParseError_TextTagCannotContainAttributes, - new SourceLocation(1, 0, 1), - length: 4)); + RazorDiagnosticFactory.CreateParsing_TextTagCannotContainAttributes( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 4))); } [Fact] @@ -43,10 +41,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.MarkupTransition("")), new MarkupTagBlock( Factory.MarkupTransition("").Accepts(AcceptedCharactersInternal.Any))), - new RazorError( - LegacyResources.ParseError_TextTagCannotContainAttributes, - new SourceLocation(8, 0, 8), - length: 4)); + RazorDiagnosticFactory.CreateParsing_TextTagCannotContainAttributes( + new SourceSpan(new SourceLocation(8, 0, 8), contentLength: 4))); } [Fact] @@ -54,10 +50,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { ParseBlockTest("foo bar ", new MarkupBlock(), - new RazorError( - LegacyResources.ParseError_MarkupBlock_Must_Start_With_Tag, - SourceLocation.Zero, - length: 3)); + RazorDiagnosticFactory.CreateParsing_MarkupBlockMustStartWithTag( + new SourceSpan(SourceLocation.Zero, contentLength: 3))); } [Fact] @@ -68,10 +62,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupTagBlock( Factory.Markup("
").Accepts(AcceptedCharactersInternal.None)), Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)), - new RazorError( - LegacyResources.FormatParseError_UnexpectedEndTag("foo"), - new SourceLocation(2, 0, 2), - length: 3)); + RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag( + new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 3), "foo")); } [Fact] @@ -85,10 +77,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), new MarkupTagBlock( Factory.Markup("").Accepts(AcceptedCharactersInternal.None))), - new RazorError( - LegacyResources.FormatParseError_MissingEndTag("p"), - new SourceLocation(1, 0, 1), - length: 1)); + RazorDiagnosticFactory.CreateParsing_MissingEndTag( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p")); } [Fact] @@ -99,10 +89,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupTagBlock( Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), Factory.Markup("blah blah blah blah blah")), - new RazorError( - LegacyResources.FormatParseError_MissingEndTag("foo"), - new SourceLocation(1, 0, 1), - length: 3)); + RazorDiagnosticFactory.CreateParsing_MissingEndTag( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 3), "foo")); } [Fact] @@ -115,10 +103,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock(new AttributeBlockChunkGenerator("bar", new LocationTagged(" bar=", 4, 0, 4), new LocationTagged(string.Empty, 12, 0, 12)), Factory.Markup(" bar=").With(SpanChunkGenerator.Null), Factory.Markup("baz").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 9, 0, 9), new LocationTagged("baz", 9, 0, 9)))))), - new RazorError( - LegacyResources.FormatParseError_UnfinishedTag("foo"), - new SourceLocation(1, 0, 1), - length: 3)); + RazorDiagnosticFactory.CreateParsing_UnfinishedTag( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 3), "foo")); } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlTagsTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlTagsTest.cs index c1b3b1a688..0a86c7a06b 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlTagsTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlTagsTest.cs @@ -39,10 +39,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), BlockFactory.MarkupTagBlock("", AcceptedCharactersInternal.None), Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)), - new RazorError( - LegacyResources.FormatParseError_MissingEndTag("p"), - new SourceLocation(1, 0, 1), - length: 1)); + RazorDiagnosticFactory.CreateParsing_MissingEndTag( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p")); } [Fact] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/RazorErrorTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/RazorErrorTest.cs deleted file mode 100644 index 698add61b6..0000000000 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/RazorErrorTest.cs +++ /dev/null @@ -1,75 +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; -using Newtonsoft.Json; -using Xunit; - -namespace Microsoft.AspNetCore.Razor.Language.Legacy -{ - public class RazorErrorTest - { - [Fact] - public void RazorError_CanBeSerialized() - { - // Arrange - var error = new RazorError( - message: "Testing", - location: new SourceLocation(absoluteIndex: 1, lineIndex: 2, characterIndex: 3), - length: 456); - var expectedSerializedError = - $"{{\"{nameof(RazorError.Message)}\":\"Testing\",\"{nameof(RazorError.Location)}\":{{\"" + - $"{nameof(SourceLocation.FilePath)}\":null,\"" + - $"{nameof(SourceLocation.AbsoluteIndex)}\":1,\"{nameof(SourceLocation.LineIndex)}\":2,\"" + - $"{nameof(SourceLocation.CharacterIndex)}\":3}},\"{nameof(RazorError.Length)}\":456}}"; - - // Act - var serializedError = JsonConvert.SerializeObject(error); - - // Assert - Assert.Equal(expectedSerializedError, serializedError, StringComparer.Ordinal); - } - - [Fact] - public void RazorError_WithFilePath_CanBeSerialized() - { - // Arrange - var error = new RazorError( - message: "Testing", - location: new SourceLocation("some-path", absoluteIndex: 1, lineIndex: 2, characterIndex: 56), - length: 3); - var expectedSerializedError = - $"{{\"{nameof(RazorError.Message)}\":\"Testing\",\"{nameof(RazorError.Location)}\":{{\"" + - $"{nameof(SourceLocation.FilePath)}\":\"some-path\",\"" + - $"{nameof(SourceLocation.AbsoluteIndex)}\":1,\"{nameof(SourceLocation.LineIndex)}\":2,\"" + - $"{nameof(SourceLocation.CharacterIndex)}\":56}},\"{nameof(RazorError.Length)}\":3}}"; - - // Act - var serializedError = JsonConvert.SerializeObject(error); - - // Assert - Assert.Equal(expectedSerializedError, serializedError, StringComparer.Ordinal); - } - - [Fact] - public void RazorError_CanBeDeserialized() - { - // Arrange - var error = new RazorError( - message: "Testing", - location: new SourceLocation("somepath", absoluteIndex: 1, lineIndex: 2, characterIndex: 3), - length: 456); - var serializedError = JsonConvert.SerializeObject(error); - - // Act - var deserializedError = JsonConvert.DeserializeObject(serializedError); - - // Assert - Assert.Equal("Testing", deserializedError.Message, StringComparer.Ordinal); - Assert.Equal(1, deserializedError.Location.AbsoluteIndex); - Assert.Equal(2, deserializedError.Location.LineIndex); - Assert.Equal(3, deserializedError.Location.CharacterIndex); - Assert.Equal(456, deserializedError.Length); - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/SpanTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/SpanTest.cs index 4c2ee94e41..5c52dd7967 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/SpanTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/SpanTest.cs @@ -26,7 +26,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Assert.Equal(2, span.Length); } - // Note: This is more of an integration-like test. However, it's valuable to determine // that the Span's ReplaceWith code is properly propogating change notifications to parents. [Fact] @@ -54,5 +53,26 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Assert.Equal(5, originalBlockLength); Assert.Equal(2, block.Length); } + + [Fact] + public void Clone_ClonesSpan() + { + // Arrange + var spanBuilder = new SpanBuilder(new SourceLocation(1, 2, 3)) + { + EditHandler = new SpanEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString), + Kind = SpanKindInternal.Transition, + ChunkGenerator = new ExpressionChunkGenerator(), + }; + spanBuilder.Accept(new CSharpSymbol("@", CSharpSymbolType.Transition)); + var span = spanBuilder.Build(); + + // Act + var copy = (Span)span.Clone(); + + // Assert + Assert.Equal(span, copy); + Assert.NotSame(span, copy); + } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperBlockRewriterTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperBlockRewriterTest.cs index cc6b408e3d..9b2adc4d07 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperBlockRewriterTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperBlockRewriterTest.cs @@ -156,7 +156,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorError[0]); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorDiagnostic[0]); } public static TheoryData WithoutEndTagElementData @@ -230,7 +230,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorError[0]); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorDiagnostic[0]); } public static TheoryData TagStructureCompatibilityData @@ -334,7 +334,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorError[0]); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorDiagnostic[0]); } public static TheoryData MalformedTagHelperAttributeBlockData @@ -343,11 +343,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var factory = new SpanFactory(); var blockFactory = new BlockFactory(factory); - var errorFormatUnclosed = "Found a malformed '{0}' tag helper. Tag helpers must have a start and " + - "end tag or be self closing."; - var errorFormatNoCloseAngle = "Missing close angle for tag helper '{0}'."; - var errorFormatNoCSharp = "The tag helper '{0}' must not have C# in the element's attribute " + - "declaration area."; Func createInvalidDoBlock = extraCode => { return new MarkupBlock( @@ -362,7 +357,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Code("do {" + extraCode).AsStatement()))); }; - return new TheoryData + return new TheoryData { { "

+ return new TheoryData { { ""))), new [] { - new RazorError( - string.Format(CultureInfo.InvariantCulture, errorFormatUnclosed, "strong"), - new SourceLocation(3, 0, 3), - length: 6) + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(new SourceLocation(3, 0, 3), contentLength: 6), "strong") } }, { @@ -925,10 +818,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.MarkupTagBlock("

"))), new [] { - new RazorError( - string.Format(CultureInfo.InvariantCulture, errorFormatUnclosed, "p"), - new SourceLocation(14, 0, 14), - length: 1) + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(new SourceLocation(14, 0, 14), contentLength: 1), "p") } } }; @@ -942,7 +833,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy object expectedOutput, object expectedErrors) { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors, "strong", "p"); + RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors, "strong", "p"); } public static TheoryData CodeTagHelperAttributesData @@ -1219,7 +1110,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy descriptors, documentContent, (MarkupBlock)expectedOutput, - expectedErrors: Enumerable.Empty()); + expectedErrors: Enumerable.Empty()); } public static IEnumerable IncompleteHelperBlockData @@ -1228,8 +1119,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var factory = new SpanFactory(); var blockFactory = new BlockFactory(factory); - var malformedErrorFormat = "Found a malformed '{0}' tag helper. Tag helpers must have a start and " + - "end tag or be self closing."; yield return new object[] { @@ -1258,14 +1147,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }, new MarkupTagHelperBlock("strong")), blockFactory.MarkupTagBlock("")), - new RazorError[] + new RazorDiagnostic[] { - new RazorError( - string.Format(CultureInfo.InvariantCulture, malformedErrorFormat, "strong"), - absoluteIndex: 53, lineIndex: 0, columnIndex: 53, length: 6), - new RazorError( - string.Format(CultureInfo.InvariantCulture, malformedErrorFormat, "strong"), - absoluteIndex: 66, lineIndex: 0, columnIndex: 66, length: 6) + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(absoluteIndex: 53, lineIndex: 0, characterIndex: 53, length: 6), "strong"), + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(absoluteIndex: 66, lineIndex: 0, characterIndex: 66, length: 6), "strong") } }; yield return new object[] @@ -1278,11 +1165,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupTagHelperBlock("strong", factory.Markup("World")), blockFactory.MarkupTagBlock(""))), - new RazorError[] + new RazorDiagnostic[] { - new RazorError( - string.Format(CultureInfo.InvariantCulture, malformedErrorFormat, "p"), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 1) + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(absoluteIndex: 6, lineIndex: 0, characterIndex: 6, length: 1), "p") } }; yield return new object[] @@ -1295,14 +1181,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupTagHelperBlock("strong", factory.Markup("World"), blockFactory.MarkupTagBlock("")))), - new RazorError[] + new RazorDiagnostic[] { - new RazorError( - string.Format(CultureInfo.InvariantCulture, malformedErrorFormat, "p"), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 1), - new RazorError( - string.Format(CultureInfo.InvariantCulture, malformedErrorFormat, "strong"), - absoluteIndex: 15, lineIndex: 0, columnIndex: 15, length: 6) + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(absoluteIndex: 6, lineIndex: 0, characterIndex: 6, length: 1), "p"), + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(absoluteIndex: 15, lineIndex: 0, characterIndex: 15, length: 6), "strong") } }; yield return new object[] @@ -1321,12 +1205,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new TagHelperAttributeNode("style", factory.Markup("color:red;")) }, factory.Markup("World")))), - new RazorError[] + new RazorDiagnostic[] { - new RazorError( - string.Format(CultureInfo.InvariantCulture, malformedErrorFormat, "p"), - new SourceLocation(1, 0, 1), - length: 1) + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p") } }; } @@ -1339,7 +1221,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy object expectedOutput, object expectedErrors) { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors, "strong", "p"); + RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors, "strong", "p"); } @@ -1917,7 +1799,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy [MemberData(nameof(EmptyAttributeTagHelperData))] public void Rewrite_UnderstandsEmptyAttributeTagHelpers(string documentContent, object expectedOutput) { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, new RazorError[0], "p"); + RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, new RazorDiagnostic[0], "p"); } public static TheoryData EmptyTagHelperBoundAttributeData @@ -1925,13 +1807,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy get { var factory = new SpanFactory(); - var emptyAttributeError = - "Attribute '{0}' on tag helper element '{1}' requires a value. Tag helper bound attributes of " + - "type '{2}' cannot be empty or contain only whitespace."; var boolTypeName = typeof(bool).FullName; // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "", @@ -1945,9 +1824,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(emptyAttributeError, "bound", "myth", boolTypeName), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(6, 0, 6, 5), + "bound", + "myth", + boolTypeName) } }, { @@ -1963,7 +1844,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.CodeMarkup(" true").With(new ExpressionChunkGenerator()), AttributeStructure.SingleQuotes) })), - new RazorError[0] + new RazorDiagnostic[0] }, { "", @@ -1980,9 +1861,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(emptyAttributeError, "bound", "myth", boolTypeName), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(6, 0, 6, 5), + "bound", + "myth", + boolTypeName), } }, { @@ -1998,12 +1881,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(emptyAttributeError, "bound", "myth", boolTypeName), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5), - new RazorError( - string.Format(emptyAttributeError, "bound", "myth", boolTypeName), - absoluteIndex: 16, lineIndex: 0, columnIndex: 16, length: 5) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(6, 0, 6, 5), + "bound", + "myth", + boolTypeName), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(16, 0, 16, 5), + "bound", + "myth", + boolTypeName), } }, { @@ -2024,12 +1911,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(emptyAttributeError, "bound", "myth", boolTypeName), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5), - new RazorError( - string.Format(emptyAttributeError, "bound", "myth", boolTypeName), - absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 5) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(6, 0, 6, 5), + "bound", + "myth", + boolTypeName), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(17, 0, 17, 5), + "bound", + "myth", + boolTypeName), } }, { @@ -2051,9 +1942,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(emptyAttributeError, "bound", "myth", boolTypeName), - absoluteIndex: 19, lineIndex: 0, columnIndex: 19, length: 5) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(19, 0, 19, 5), + "bound", + "myth", + boolTypeName), } }, { @@ -2072,9 +1965,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(emptyAttributeError, "bound", "myth", boolTypeName), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(6, 0, 6, 5), + "bound", + "myth", + boolTypeName), } }, { @@ -2093,9 +1988,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(emptyAttributeError, "bound", "myth", boolTypeName), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(6, 0, 6, 5), + "bound", + "myth", + boolTypeName), } }, { @@ -2122,9 +2019,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(emptyAttributeError, "bound", "myth", boolTypeName), - absoluteIndex: 31, lineIndex: 0, columnIndex: 31, length: 5), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(31, 0, 31, 5), + "bound", + "myth", + boolTypeName), } }, { @@ -2139,9 +2038,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(emptyAttributeError, "BouND", "myth", boolTypeName), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(6, 0, 6, 5), + "BouND", + "myth", + boolTypeName), } }, { @@ -2157,12 +2058,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(emptyAttributeError, "BOUND", "myth", boolTypeName), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5), - new RazorError( - string.Format(emptyAttributeError, "bOUnd", "myth", boolTypeName), - absoluteIndex: 18, lineIndex: 0, columnIndex: 18, length: 5) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(6, 0, 6, 5), + "BOUND", + "myth", + boolTypeName), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(18, 0, 18, 5), + "bOUnd", + "myth", + boolTypeName), } }, { @@ -2180,9 +2085,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(emptyAttributeError, "BOUND", "myth", boolTypeName), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(6, 0, 6, 5), + "BOUND", + "myth", + boolTypeName), } }, { @@ -2207,7 +2114,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy AttributeStructure.SingleQuotes) } })), - new RazorError[0] + new RazorDiagnostic[0] }, { "", @@ -2233,7 +2140,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy AttributeStructure.SingleQuotes) } })), - new RazorError[0] + new RazorDiagnostic[0] }, }; } @@ -2265,7 +2172,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors); } public static IEnumerable ScriptBlockData @@ -2861,7 +2768,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy object expectedOutput) { // Act & Assert - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, Enumerable.Empty(), "input"); + RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, Enumerable.Empty(), "input"); } public static TheoryData MinimizedAttributeData_Document @@ -2869,11 +2776,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy get { var factory = new SpanFactory(); - var noErrors = new RazorError[0]; - var errorFormat = "Attribute '{0}' on tag helper element '{1}' requires a value. Tag helper bound " + - "attributes of type '{2}' cannot be empty or contain only whitespace."; - var emptyKeyFormat = "The tag helper attribute '{0}' in element '{1}' is missing a key. The " + - "syntax is '<{1} {0}{{ key }}=\"value\">'."; + var noErrors = new RazorDiagnostic[0]; var stringType = typeof(string).FullName; var intType = typeof(int).FullName; var expressionString = "@DateTime.Now + 1"; @@ -2900,7 +2803,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("1", index + 16, 0, index + 16))))); // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "", @@ -2926,8 +2829,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-string", "p", stringType), 3, 0, 3, 12) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(3, 0, 3, 12), + "bound-string", + "p", + stringType), } }, { @@ -2942,8 +2848,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-required-string", "input", stringType), 7, 0, 7, 21) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(7, 0, 7, 21), + "bound-required-string", + "input", + stringType), } }, { @@ -2958,8 +2867,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-required-int", "input", intType), 7, 0, 7, 18) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(7, 0, 7, 18), + "bound-required-int", + "input", + intType), } }, { @@ -2972,7 +2884,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { new TagHelperAttributeNode("bound-int", null, AttributeStructure.Minimized), })), - new[] { new RazorError(string.Format(errorFormat, "bound-int", "p", intType), 3, 0, 3, 9) } + new[] + { + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(3, 0, 3, 9), + "bound-int", + "p", + intType), + } }, { "", @@ -2986,12 +2905,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "int-dictionary", "input", typeof(IDictionary).Namespace + ".IDictionary"), - absoluteIndex: 7, - lineIndex: 0, - columnIndex: 7, - length: 14), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(7, 0, 7, 14), + "int-dictionary", + "input", + typeof(IDictionary).Namespace + ".IDictionary"), } }, { @@ -3006,12 +2924,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "string-dictionary", "input", typeof(IDictionary).Namespace + ".IDictionary"), - absoluteIndex: 7, - lineIndex: 0, - columnIndex: 7, - length: 17), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(7, 0, 7, 17), + "string-dictionary", + "input", + typeof(IDictionary).Namespace + ".IDictionary"), } }, { @@ -3026,18 +2943,15 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "int-prefix-", "input", typeof(int).FullName), - absoluteIndex: 7, - lineIndex: 0, - columnIndex: 7, - length: 11), - new RazorError( - string.Format(emptyKeyFormat, "int-prefix-", "input"), - absoluteIndex: 7, - lineIndex: 0, - columnIndex: 7, - length: 11), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(7, 0, 7, 11), + "int-prefix-", + "input", + intType), + RazorDiagnosticFactory.CreateParsing_TagHelperIndexerAttributeNameMustIncludeKey( + new SourceSpan(7, 0, 7, 11), + "int-prefix-", + "input"), } }, { @@ -3052,18 +2966,15 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "string-prefix-", "input", typeof(string).FullName), - absoluteIndex: 7, - lineIndex: 0, - columnIndex: 7, - length: 14), - new RazorError( - string.Format(emptyKeyFormat, "string-prefix-", "input"), - absoluteIndex: 7, - lineIndex: 0, - columnIndex: 7, - length: 14), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(7, 0, 7, 14), + "string-prefix-", + "input", + stringType), + RazorDiagnosticFactory.CreateParsing_TagHelperIndexerAttributeNameMustIncludeKey( + new SourceSpan(7, 0, 7, 14), + "string-prefix-", + "input"), } }, { @@ -3078,12 +2989,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "int-prefix-value", "input", typeof(int).FullName), - absoluteIndex: 7, - lineIndex: 0, - columnIndex: 7, - length: 16), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(7, 0, 7, 16), + "int-prefix-value", + "input", + intType), } }, { @@ -3098,12 +3008,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "string-prefix-value", "input", typeof(string).FullName), - absoluteIndex: 7, - lineIndex: 0, - columnIndex: 7, - length: 19), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(7, 0, 7, 19), + "string-prefix-value", + "input", + stringType), } }, { @@ -3118,12 +3027,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "int-prefix-value", "input", typeof(int).FullName), - absoluteIndex: 7, - lineIndex: 0, - columnIndex: 7, - length: 16), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(7, 0, 7, 16), + "int-prefix-value", + "input", + intType), } }, { @@ -3136,7 +3044,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { new TagHelperAttributeNode("string-prefix-value", new MarkupBlock(), AttributeStructure.SingleQuotes), })), - new RazorError[0] + new RazorDiagnostic[0] }, { "", @@ -3151,7 +3059,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.CodeMarkup("3").With(new ExpressionChunkGenerator()), AttributeStructure.SingleQuotes), })), - new RazorError[0] + new RazorDiagnostic[0] }, { "", @@ -3168,7 +3076,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup(" string")), AttributeStructure.SingleQuotes), })), - new RazorError[0] + new RazorDiagnostic[0] }, { "", @@ -3183,12 +3091,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-required-string", "input", stringType), - absoluteIndex: 24, - lineIndex: 0, - columnIndex: 24, - length: 21) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(24, 0, 24, 21), + "bound-required-string", + "input", + stringType), } }, { @@ -3204,8 +3111,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError(string.Format(errorFormat, "bound-int", "p", intType), 3, 0, 3, 9), - new RazorError(string.Format(errorFormat, "bound-string", "p", stringType), 13, 0, 13, 12), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(3, 0, 3, 9), + "bound-int", + "p", + intType), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(13, 0, 13, 12), + "bound-string", + "p", + stringType), } }, { @@ -3222,14 +3137,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-required-int", "input", intType), 7, 0, 7, 18), - new RazorError( - string.Format(errorFormat, "bound-required-string", "input", stringType), - absoluteIndex: 43, - lineIndex: 0, - columnIndex: 43, - length: 21) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(7, 0, 7, 18), + "bound-required-int", + "input", + intType), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(43, 0, 43, 21), + "bound-required-string", + "input", + stringType), } }, { @@ -3246,9 +3163,21 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError(string.Format(errorFormat, "bound-int", "p", intType), 3, 0, 3, 9), - new RazorError(string.Format(errorFormat, "bound-string", "p", stringType), 13, 0, 13, 12), - new RazorError(string.Format(errorFormat, "bound-string", "p", stringType), 26, 0, 26, 12), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(3, 0, 3, 9), + "bound-int", + "p", + intType), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(13, 0, 13, 12), + "bound-string", + "p", + stringType), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(26, 0, 26, 12), + "bound-string", + "p", + stringType), } }, { @@ -3277,12 +3206,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-string", "p", stringType), - absoluteIndex: 3, - lineIndex: 0, - columnIndex: 3, - length: 12) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(3, 0, 3, 12), + "bound-string", + "p", + stringType), } }, { @@ -3311,12 +3239,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-string", "p", stringType), - absoluteIndex: 15, - lineIndex: 0, - columnIndex: 15, - length: 12) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(15, 0, 15, 12), + "bound-string", + "p", + stringType), } }, { @@ -3332,12 +3259,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-required-string", "input", stringType), - absoluteIndex: 7, - lineIndex: 0, - columnIndex: 7, - length: 21) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(7, 0, 7, 21), + "bound-required-string", + "input", + stringType), } }, { @@ -3353,12 +3279,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-required-string", "input", stringType), - absoluteIndex: 19, - lineIndex: 0, - columnIndex: 19, - length: 21) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(19, 0, 19, 21), + "bound-required-string", + "input", + stringType), } }, { @@ -3374,8 +3299,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-required-int", "input", intType), 7, 0, 7, 18) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(7, 0, 7, 18), + "bound-required-int", + "input", + intType), } }, { @@ -3391,7 +3319,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError(string.Format(errorFormat, "bound-int", "p", intType), 3, 0, 3, 9) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(3, 0, 3, 9), + "bound-int", + "p", + intType), } }, { @@ -3407,7 +3339,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError(string.Format(errorFormat, "bound-required-int", "input", intType), 19, 0, 19, 18) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(19, 0, 19, 18), + "bound-required-int", + "input", + intType), } }, { @@ -3423,7 +3359,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError(string.Format(errorFormat, "bound-int", "p", intType), 15, 0, 15, 9) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(15, 0, 15, 9), + "bound-int", + "p", + intType), } }, { @@ -3439,8 +3379,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-required-int", "input", intType), 33, 0, 33, 18) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(33, 0, 33, 18), + "bound-required-int", + "input", + intType), } }, { @@ -3456,7 +3399,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError(string.Format(errorFormat, "bound-int", "p", intType), 29, 0, 29, 9) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(29, 0, 29, 9), + "bound-int", + "p", + intType), } }, { @@ -3476,14 +3423,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-required-int", "input", intType), 10, 0, 10, 18), - new RazorError( - string.Format(errorFormat, "bound-required-string", "input", stringType), - absoluteIndex: 57, - lineIndex: 0, - columnIndex: 57, - length: 21), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(10, 0, 10, 18), + "bound-required-int", + "input", + intType), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(57, 0, 57, 21), + "bound-required-string", + "input", + stringType), } }, { @@ -3503,9 +3452,21 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError(string.Format(errorFormat, "bound-int", "p", intType), 6, 0, 6, 9), - new RazorError(string.Format(errorFormat, "bound-string", "p", stringType), 44, 0, 44, 12), - new RazorError(string.Format(errorFormat, "bound-string", "p", stringType), 84, 0, 84, 12), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(6, 0, 6, 9), + "bound-int", + "p", + intType), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(44, 0, 44, 12), + "bound-string", + "p", + stringType), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(84, 0, 84, 12), + "bound-string", + "p", + stringType), } }, }; @@ -3612,12 +3573,15 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy data[1] = buildStatementBlock(() => data[1] as MarkupBlock); - var errors = data[2] as RazorError[]; + var errors = data[2] as RazorDiagnostic[]; for (var i = 0; i < errors.Length; i++) { - var error = errors[i]; - error.Location = SourceLocationTracker.Advance(error.Location, "@{"); + var error = errors[i] as DefaultRazorDiagnostic; + var currentErrorLocation = new SourceLocation(error.Span.AbsoluteIndex, error.Span.LineIndex, error.Span.CharacterIndex); + var newErrorLocation = SourceLocationTracker.Advance(currentErrorLocation, "@{"); + var copiedDiagnostic = new DefaultRazorDiagnostic(error.Descriptor, new SourceSpan(newErrorLocation, error.Span.Length), error.Args); + errors[i] = copiedDiagnostic; } } @@ -3630,17 +3594,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy get { var factory = new SpanFactory(); - var noErrors = new RazorError[0]; - var errorFormatUnclosed = "Found a malformed '{0}' tag helper. Tag helpers must have a start and " + - "end tag or be self closing."; - var errorFormatNoCloseAngle = "Missing close angle for tag helper '{0}'."; - var errorFormatNoValue = "Attribute '{0}' on tag helper element '{1}' requires a value. Tag helper bound " + - "attributes of type '{2}' cannot be empty or contain only whitespace."; + var noErrors = new RazorDiagnostic[0]; var stringType = typeof(string).FullName; var intType = typeof(int).FullName; // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "(), + children: new[] + { + new SpanBuilder(SourceLocation.Zero).Build(), + new SpanBuilder(new SourceLocation(0, 1, 2)).Build(), + }).Build(); + + // Act + var copy = (TagHelperBlock)tagHelper.Clone(); + + // Assert + ParserTestBase.EvaluateParseTree(copy, tagHelper); + Assert.Collection( + copy.Children, + child => Assert.NotSame(tagHelper.Children[0], child), + child => Assert.NotSame(tagHelper.Children[1], child)); + } + + [Fact] + public void Clone_ClonesTagHelperAttributes() + { + // Arrange + var tagHelper = (TagHelperBlock)new TagHelperBlockBuilder( + "p", + TagMode.StartTagAndEndTag, + attributes: new List() + { + new TagHelperAttributeNode("class", new SpanBuilder(SourceLocation.Zero).Build(), AttributeStructure.NoQuotes), + new TagHelperAttributeNode("checked", new SpanBuilder(SourceLocation.Undefined).Build(), AttributeStructure.NoQuotes) + }, + children: Enumerable.Empty()).Build(); + + // Act + var copy = (TagHelperBlock)tagHelper.Clone(); + + // Assert + ParserTestBase.EvaluateParseTree(copy, tagHelper); + Assert.Collection( + copy.Attributes, + attribute => Assert.NotSame(tagHelper.Attributes[0], attribute), + attribute => Assert.NotSame(tagHelper.Attributes[1], attribute)); + } + + [Fact] + public void Clone_ClonesTagHelperSourceStartTag() + { + // Arrange + var tagHelper = (TagHelperBlock)new TagHelperBlockBuilder( + "p", + TagMode.StartTagAndEndTag, + attributes: new List(), + children: Enumerable.Empty()) + { + SourceStartTag = new BlockBuilder() + { + Type = BlockKindInternal.Comment, + ChunkGenerator = new RazorCommentChunkGenerator() + }.Build() + }.Build(); + + // Act + var copy = (TagHelperBlock)tagHelper.Clone(); + + // Assert + ParserTestBase.EvaluateParseTree(copy, tagHelper); + Assert.NotSame(tagHelper.SourceStartTag, copy.SourceStartTag); + } + + [Fact] + public void Clone_ClonesTagHelperSourceEndTag() + { + // Arrange + var tagHelper = (TagHelperBlock)new TagHelperBlockBuilder( + "p", + TagMode.StartTagAndEndTag, + attributes: new List(), + children: Enumerable.Empty()) + { + SourceEndTag = new BlockBuilder() + { + Type = BlockKindInternal.Comment, + ChunkGenerator = new RazorCommentChunkGenerator() + }.Build() + }.Build(); + + // Act + var copy = (TagHelperBlock)tagHelper.Clone(); + + // Assert + ParserTestBase.EvaluateParseTree(copy, tagHelper); + Assert.NotSame(tagHelper.SourceEndTag, copy.SourceEndTag); + } + [Fact] public void FlattenFlattensSelfClosingTagHelpers() { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperParseTreeRewriterTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperParseTreeRewriterTest.cs index 5c75651f43..2feccbe1a4 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperParseTreeRewriterTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperParseTreeRewriterTest.cs @@ -74,20 +74,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var factory = new SpanFactory(); var blockFactory = new BlockFactory(factory); - Func errorFormatUnclosed = (location, tagName) => - new RazorError( - $"Found a malformed '{tagName}' tag helper. Tag helpers must have a start and end tag or be " + - "self closing.", - new SourceLocation(location, 0, location), - tagName.Length); - Func errorFormatNoCloseAngle = (location, tagName) => - new RazorError( - $"Missing close angle for tag helper '{tagName}'.", - new SourceLocation(location, 0, location), - tagName.Length); + Func errorFormatUnclosed = (location, tagName) => + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(new SourceLocation(location, 0, location), tagName.Length), tagName); + + Func errorFormatNoCloseAngle = (location, tagName) => + RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( + new SourceSpan(new SourceLocation(location, 0, location), tagName.Length), tagName); // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "

", @@ -173,7 +169,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors); } public static TheoryData NestedVoidSelfClosingRequiredParentData @@ -279,7 +275,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorError[0]); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorDiagnostic[0]); } public static TheoryData NestedRequiredParentData @@ -354,7 +350,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorError[0]); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorDiagnostic[0]); } [Fact] @@ -381,7 +377,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy descriptors, documentContent, expectedOutput, - expectedErrors: Enumerable.Empty(), + expectedErrors: Enumerable.Empty(), tagHelperPrefix: "th:"); } @@ -409,7 +405,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy descriptors, documentContent, expectedOutput, - expectedErrors: Enumerable.Empty(), + expectedErrors: Enumerable.Empty(), tagHelperPrefix: "th:"); } @@ -433,12 +429,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .Build(), }; var expectedErrors = new[] { - new RazorError( - LegacyResources.FormatTagHelpersParseTreeRewriter_FoundMalformedTagHelper("th:strong"), - absoluteIndex: 8, - lineIndex: 0, - columnIndex: 8, - length: 9), + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(filePath: null, absoluteIndex: 8, lineIndex: 0, characterIndex: 8, length: 9), + "th:strong"), }; // Act & Assert @@ -474,7 +467,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy descriptors, documentContent, expectedOutput, - expectedErrors: Enumerable.Empty(), + expectedErrors: Enumerable.Empty(), tagHelperPrefix: "th:"); } @@ -755,12 +748,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy $"{Environment.NewLine} {Environment.NewLine}

"; var newLineLength = Environment.NewLine.Length; var expectedErrors = new[] { - new RazorError( - LegacyResources.FormatTagHelperParseTreeRewriter_InvalidNestedTag("strong", "p", "br"), - absoluteIndex: 8 + newLineLength, - lineIndex: 1, - columnIndex: 5, - length: 6), + RazorDiagnosticFactory.CreateTagHelper_InvalidNestedTag( + new SourceSpan(absoluteIndex: 8 + newLineLength, lineIndex: 1, characterIndex: 5, length: 6), "strong", "p", "br"), }; var expectedOutput = new MarkupBlock( new MarkupTagHelperBlock("p", @@ -790,12 +779,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var documentContent = ""; var expectedErrors = new[] { - new RazorError( - LegacyResources.FormatTagHelperParseTreeRewriter_InvalidNestedTag("strong", "strong", "br"), - absoluteIndex: 18, - lineIndex: 0, - columnIndex: 18, - length: 6) + RazorDiagnosticFactory.CreateTagHelper_InvalidNestedTag( + new SourceSpan(absoluteIndex: 18, lineIndex: 0, characterIndex: 18, length: 6), "strong", "strong", "br") }; var expectedOutput = new MarkupBlock( new MarkupTagHelperBlock("strong", @@ -853,7 +838,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, expectedOutput, expectedErrors: new RazorError[0]); + EvaluateData(descriptors, documentContent, expectedOutput, expectedErrors: new RazorDiagnostic[0]); } [Fact] @@ -889,7 +874,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, expectedOutput, expectedErrors: new RazorError[0]); + EvaluateData(descriptors, documentContent, expectedOutput, expectedErrors: new RazorDiagnostic[0]); } public static TheoryData AllowedChildrenData @@ -898,25 +883,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var factory = new SpanFactory(); var blockFactory = new BlockFactory(factory); - Func nestedTagError = - (childName, parentName, allowed, location, length) => new RazorError( - LegacyResources.FormatTagHelperParseTreeRewriter_InvalidNestedTag( - childName, - parentName, - allowed), - absoluteIndex: location, - lineIndex: 0, - columnIndex: location, - length: length); - Func nestedContentError = - (parentName, allowed, location, length) => new RazorError( - LegacyResources.FormatTagHelperParseTreeRewriter_CannotHaveNonTagContent(parentName, allowed), - absoluteIndex: location, - lineIndex: 0, - columnIndex: location, - length: length); + Func nestedTagError = + (childName, parentName, allowed, location, length) => + RazorDiagnosticFactory.CreateTagHelper_InvalidNestedTag( + new SourceSpan(absoluteIndex: location, lineIndex: 0, characterIndex: location, length: length), childName, parentName, allowed); + Func nestedContentError = + (parentName, allowed, location, length) => + RazorDiagnosticFactory.CreateTagHelper_CannotHaveNonTagContent( + new SourceSpan(absoluteIndex: location, lineIndex: 0, characterIndex: location, length: length), parentName, allowed); - return new TheoryData, MarkupBlock, RazorError[]> + return new TheoryData, MarkupBlock, RazorDiagnostic[]> { { "


", @@ -924,7 +900,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock( new MarkupTagHelperBlock("p", new MarkupTagHelperBlock("br", TagMode.SelfClosing))), - new RazorError[0] + new RazorDiagnostic[0] }, { $"

{Environment.NewLine}
{Environment.NewLine}

", @@ -934,7 +910,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup(Environment.NewLine), new MarkupTagHelperBlock("br", TagMode.SelfClosing), factory.Markup(Environment.NewLine))), - new RazorError[0] + new RazorDiagnostic[0] }, { "


", @@ -1129,7 +1105,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors); } [Fact] @@ -1152,12 +1128,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy BlockFactory.MarkupTagBlock(""; var expectedOutput = new MarkupBlock(blockFactory.MarkupTagBlock("")); var descriptors = new TagHelperDescriptor[] @@ -1253,16 +1217,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var factory = new SpanFactory(); var blockFactory = new BlockFactory(factory); - var expectedError = new RazorError( - LegacyResources.FormatTagHelperParseTreeRewriter_InconsistentTagStructure( - "InputTagHelper1", - "InputTagHelper2", - "input", - nameof(TagMatchingRuleDescriptor.TagStructure)), - absoluteIndex: 0, - lineIndex: 0, - columnIndex: 0, - length: 7); + var expectedError = RazorDiagnosticFactory.CreateTagHelper_InconsistentTagStructure( + new SourceSpan(absoluteIndex: 0, lineIndex: 0, characterIndex: 0, length: 7), "InputTagHelper1", "InputTagHelper2", "input"); var documentContent = ""; var expectedOutput = new MarkupBlock(new MarkupTagHelperBlock("input", TagMode.StartTagOnly)); var descriptors = new TagHelperDescriptor[] @@ -1711,7 +1667,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorError[0]); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorDiagnostic[0]); } public static TheoryData NestedRequiredAttributeData @@ -1964,7 +1920,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorError[0]); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorDiagnostic[0]); } public static TheoryData MalformedRequiredAttributeData @@ -1973,17 +1929,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var factory = new SpanFactory(); var blockFactory = new BlockFactory(factory); - var errorFormatUnclosed = "Found a malformed '{0}' tag helper. Tag helpers must have a start and " + - "end tag or be self closing."; - var errorFormatNoCloseAngle = "Missing close angle for tag helper '{0}'."; // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { ""), blockFactory.MarkupTagBlock(""))), new[] { - new RazorError( - string.Format(CultureInfo.InvariantCulture, errorFormatNoCloseAngle, "p"), - new SourceLocation(1, 0, 1), - length: 1), - new RazorError( - string.Format(CultureInfo.InvariantCulture, errorFormatUnclosed, "p"), - new SourceLocation(1, 0, 1), - length: 1), + RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), } }, { @@ -2103,14 +2040,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy children: blockFactory.MarkupTagBlock("

"))), new[] { - new RazorError( - string.Format(CultureInfo.InvariantCulture, errorFormatNoCloseAngle, "p"), - new SourceLocation(1, 0, 1), - length: 1), - new RazorError( - string.Format(CultureInfo.InvariantCulture, errorFormatUnclosed, "p"), - new SourceLocation(1, 0, 1), - length: 1), + RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), } }, { @@ -2124,14 +2057,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(CultureInfo.InvariantCulture, errorFormatNoCloseAngle, "p"), - new SourceLocation(1, 0, 1), - length: 1), - new RazorError( - string.Format(CultureInfo.InvariantCulture, errorFormatNoCloseAngle, "p"), - new SourceLocation(17, 0, 17), - length: 1) + RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), + RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( + new SourceSpan(new SourceLocation(17, 0, 17), contentLength: 1), "p") } }, { @@ -2146,14 +2075,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(CultureInfo.InvariantCulture, errorFormatNoCloseAngle, "p"), - new SourceLocation(1, 0, 1), - length: 1), - new RazorError( - string.Format(CultureInfo.InvariantCulture, errorFormatNoCloseAngle, "p"), - new SourceLocation(34, 0, 34), - length: 1) + RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), + RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( + new SourceSpan(new SourceLocation(34, 0, 34), contentLength: 1), "p") } }, }; @@ -2179,7 +2104,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors); } public static TheoryData PrefixedTagHelperBoundData @@ -2333,7 +2258,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy (IEnumerable)availableDescriptors, documentContent, (MarkupBlock)expectedOutput, - expectedErrors: Enumerable.Empty(), + expectedErrors: Enumerable.Empty(), tagHelperPrefix: "th:"); } @@ -2343,13 +2268,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var factory = new SpanFactory(); var blockFactory = new BlockFactory(factory); - var errorFormatNormalUnclosed = - "The \"{0}\" element was not closed. All elements must be either self-closing or have a " + - "matching end tag."; - var errorMatchingBrace = - "The code block is missing a closing \"}\" character. Make sure you have a matching \"}\" " + - "character for all the \"{\" characters within this block, and that none of the \"}\" " + - "characters are being interpreted as markup."; Func, MarkupBlock> buildStatementBlock = (insideBuilder) => { @@ -2365,7 +2283,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "@{}", @@ -2394,12 +2312,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("}")))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorFormatNormalUnclosed, "!text"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + RazorDiagnosticFactory.CreateParsing_MissingEndTag( + new SourceSpan(filePath: null, absoluteIndex: 3, lineIndex: 0, characterIndex: 3, length: 5), "!text"), } }, { @@ -2423,7 +2339,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("\"").With(SpanChunkGenerator.Null)), factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{words with spaces}", @@ -2447,7 +2363,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), factory.Markup("words with spaces"), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{}", @@ -2484,7 +2400,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("btn", 34, 0, 34)))), factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{}", @@ -2520,7 +2436,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("'").With(SpanChunkGenerator.Null)), factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, }; } @@ -2532,19 +2448,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var factory = new SpanFactory(); var blockFactory = new BlockFactory(factory); - var errorFormatMalformed = - "Found a malformed '{0}' tag helper. Tag helpers must have a start and end tag or be self " + - "closing."; - var errorFormatNormalUnclosed = - "The \"{0}\" element was not closed. All elements must be either self-closing or have a " + - "matching end tag."; - var errorFormatNormalNotStarted = - "Encountered end tag \"{0}\" with no matching start tag. Are your start/end tags properly " + - "balanced?"; - var errorMatchingBrace = - "The code block is missing a closing \"}\" character. Make sure you have a matching \"}\" " + - "character for all the \"{\" characters within this block, and that none of the \"}\" " + - "characters are being interpreted as markup."; + + RazorDiagnostic MissingEndTagError(string tagName) + { + return RazorDiagnosticFactory.CreateParsing_MissingEndTag( + new SourceSpan(filePath: null, absoluteIndex: 3, lineIndex: 0, characterIndex: 3, length: tagName.Length), tagName); + } Func, MarkupBlock> buildStatementBlock = (insideBuilder) => { @@ -2560,7 +2469,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "@{}", @@ -2574,12 +2483,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("}")))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorFormatNormalUnclosed, "!text", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + MissingEndTagError("!text"), } }, { @@ -2589,9 +2495,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), new [] { - new RazorError( - string.Format(errorFormatNormalNotStarted, "!text", CultureInfo.InvariantCulture), - absoluteIndex: 4, lineIndex: 0, columnIndex: 4, length: 5), + RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag( + new SourceSpan(filePath: null, absoluteIndex: 4, lineIndex: 0, characterIndex: 4, length: 5), "!text"), } }, { @@ -2600,7 +2505,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy () => new MarkupBlock( blockFactory.EscapedMarkupTagBlock("<", "text>", AcceptedCharactersInternal.None), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{words and spaces}", @@ -2609,7 +2514,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock("<", "text>", AcceptedCharactersInternal.None), factory.Markup("words and spaces"), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{}", @@ -2619,12 +2524,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.MarkupTagBlock("", AcceptedCharactersInternal.None))), new [] { - new RazorError( - string.Format(errorFormatNormalUnclosed, "!text", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5), - new RazorError( - string.Format(errorFormatMalformed, "text", CultureInfo.InvariantCulture), - absoluteIndex: 11, lineIndex: 0, columnIndex: 11, length: 4) + MissingEndTagError("!text"), + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(absoluteIndex: 11, lineIndex: 0, characterIndex: 11, length: 4), "text") } }, { @@ -2638,9 +2540,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("text>").Accepts(AcceptedCharactersInternal.None)))), new [] { - new RazorError( - string.Format(errorFormatNormalUnclosed, "text", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 4) + MissingEndTagError("text"), } }, { @@ -2650,7 +2550,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock("<", "text>", AcceptedCharactersInternal.None), new MarkupTagHelperBlock("text"), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{}", @@ -2669,12 +2569,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("}")))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorFormatNormalUnclosed, "text", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 4) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + MissingEndTagError("text"), } }, { @@ -2694,12 +2591,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.EmptyHtml()), new [] { - new RazorError( - string.Format(errorFormatNormalNotStarted, "text", CultureInfo.InvariantCulture), - absoluteIndex: 19, lineIndex: 0, columnIndex: 19, length: 4), - new RazorError( - string.Format(errorFormatMalformed, "text", CultureInfo.InvariantCulture), - absoluteIndex: 19, lineIndex: 0, columnIndex: 19, length: 4) + RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag( + new SourceSpan(filePath: null, absoluteIndex: 19, lineIndex: 0, characterIndex: 19, length: 4), "text"), + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(absoluteIndex: 19, lineIndex: 0, characterIndex: 19, length: 4), "text") } }, }; @@ -2714,7 +2609,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy object expectedOutput, object expectedErrors) { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors, "p", "text"); + RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors, "p", "text"); } public static TheoryData OptOut_WithPartialTextTagData @@ -2723,15 +2618,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var factory = new SpanFactory(); var blockFactory = new BlockFactory(factory); - var errorMatchingBrace = - "The code block is missing a closing \"}\" character. Make sure you have a matching \"}\" " + - "character for all the \"{\" characters within this block, and that none of the \"}\" " + - "characters are being interpreted as markup."; - var errorEOFMatchingBrace = - "End of file or an unexpected character was reached before the \"{0}\" tag could be parsed. " + - "Elements inside markup blocks must be complete. They must either be self-closing " + - "(\"
\") or have matching end tags (\"

Hello

\"). If you intended " + - "to display a \"<\" character, use the \"<\" HTML entity."; + + RazorDiagnostic UnfinishedTagError(string tagName, int length) + { + return RazorDiagnosticFactory.CreateParsing_UnfinishedTag( + new SourceSpan(filePath: null, absoluteIndex: 3, lineIndex: 0, characterIndex: 3, length: length), + tagName); + } Func, MarkupBlock> buildPartialStatementBlock = (insideBuilder) => { @@ -2744,7 +2637,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "@{ new MarkupBlock(blockFactory.EscapedMarkupTagBlock("<", "text}"))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorEOFMatchingBrace, "!text}"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 6) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + UnfinishedTagError("!text}", 6), } }, { @@ -2770,12 +2660,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock(factory.Markup("}"))))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorEOFMatchingBrace, "!text"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + UnfinishedTagError("!text", 5), } }, { @@ -2798,12 +2685,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("}", 15, 0, 15))))))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorEOFMatchingBrace, "!text"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + UnfinishedTagError("!text", 5), } }, { @@ -2826,12 +2710,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("btn}", 16, 0, 16))))))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorEOFMatchingBrace, "!text"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + UnfinishedTagError("!text", 5), } }, { @@ -2857,12 +2738,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock(factory.Markup("}"))))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorEOFMatchingBrace, "!text"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + UnfinishedTagError("!text", 5), } }, { @@ -2889,12 +2767,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock(factory.Markup("}"))))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorEOFMatchingBrace, "!text"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + UnfinishedTagError("!text", 5), } } }; @@ -2908,7 +2783,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy object expectedOutput, object expectedErrors) { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors, "text"); + RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors, "text"); } public static TheoryData OptOut_WithPartialData_CSharp @@ -2917,15 +2792,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var factory = new SpanFactory(); var blockFactory = new BlockFactory(factory); - var errorMatchingBrace = - "The code block is missing a closing \"}\" character. Make sure you have a matching \"}\" " + - "character for all the \"{\" characters within this block, and that none of the \"}\" " + - "characters are being interpreted as markup."; - var errorEOFMatchingBrace = - "End of file or an unexpected character was reached before the \"{0}\" tag could be parsed. " + - "Elements inside markup blocks must be complete. They must either be self-closing " + - "(\"
\") or have matching end tags (\"

Hello

\"). If you intended " + - "to display a \"<\" character, use the \"<\" HTML entity."; + + RazorDiagnostic UnfinishedTagError(string tagName) + { + return RazorDiagnosticFactory.CreateParsing_UnfinishedTag( + new SourceSpan(filePath: null, absoluteIndex: 3, lineIndex: 0, characterIndex: 3, length: tagName.Length), + tagName); + } Func, MarkupBlock> buildPartialStatementBlock = (insideBuilder) => { @@ -2938,7 +2811,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "@{ new MarkupBlock(blockFactory.EscapedMarkupTagBlock("<", "}"))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorEOFMatchingBrace, "!}"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + UnfinishedTagError("!}"), } }, { @@ -2960,12 +2830,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy () => new MarkupBlock(blockFactory.EscapedMarkupTagBlock("<", "p}"))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorEOFMatchingBrace, "!p}"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 3) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + UnfinishedTagError("!p}"), } }, { @@ -2975,12 +2842,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock("<", "p /", new MarkupBlock(factory.Markup("}"))))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorEOFMatchingBrace, "!p"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + UnfinishedTagError("!p"), } }, { @@ -3003,12 +2867,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("}", 12, 0, 12))))))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorEOFMatchingBrace, "!p"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + UnfinishedTagError("!p"), } }, { @@ -3031,12 +2892,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("btn}", 13, 0, 13))))))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorEOFMatchingBrace, "!p"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + UnfinishedTagError("!p"), } }, { @@ -3066,12 +2924,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("}", 18, 0, 18))))))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorEOFMatchingBrace, "!p"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + UnfinishedTagError("!p"), } }, { @@ -3097,12 +2952,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock(factory.Markup("}"))))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorEOFMatchingBrace, "!p"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + UnfinishedTagError("!p"), } }, { @@ -3130,12 +2982,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("}"))))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorEOFMatchingBrace, "!p"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + UnfinishedTagError("!p"), } } }; @@ -3149,7 +2998,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy object expectedOutput, object expectedErrors) { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors, "strong", "p"); + RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors, "strong", "p"); } public static TheoryData OptOut_WithPartialData_HTML @@ -3256,7 +3105,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy string documentContent, object expectedOutput) { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, new RazorError[0], "strong", "p"); + RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, new RazorDiagnostic[0], "strong", "p"); } public static TheoryData OptOut_WithBlockData_CSharp @@ -3265,19 +3114,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var factory = new SpanFactory(); var blockFactory = new BlockFactory(factory); - var errorFormatMalformed = - "Found a malformed '{0}' tag helper. Tag helpers must have a start and end tag or be self " + - "closing."; - var errorFormatNormalUnclosed = - "The \"{0}\" element was not closed. All elements must be either self-closing or have a " + - "matching end tag."; - var errorFormatNormalNotStarted = - "Encountered end tag \"{0}\" with no matching start tag. Are your start/end tags properly " + - "balanced?"; - var errorMatchingBrace = - "The code block is missing a closing \"}\" character. Make sure you have a matching \"}\" " + - "character for all the \"{\" characters within this block, and that none of the \"}\" " + - "characters are being interpreted as markup."; + + RazorDiagnostic MissingEndTagError(string tagName, int index = 3) + { + return RazorDiagnosticFactory.CreateParsing_MissingEndTag( + new SourceSpan(filePath: null, absoluteIndex: index, lineIndex: 0, characterIndex: index, length: tagName.Length), tagName); + } Func, MarkupBlock> buildStatementBlock = (insideBuilder) => { @@ -3293,7 +3135,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "@{}", @@ -3307,12 +3149,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("}")))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorFormatNormalUnclosed, "!p", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + MissingEndTagError("!p"), } }, { @@ -3322,9 +3161,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), new [] { - new RazorError( - string.Format(errorFormatNormalNotStarted, "!p", CultureInfo.InvariantCulture), - absoluteIndex: 4, lineIndex: 0, columnIndex: 4, length: 2), + RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag( + new SourceSpan(filePath: null, absoluteIndex: 4, lineIndex: 0, characterIndex: 4, length: 2), "!p"), } }, { @@ -3333,7 +3171,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy () => new MarkupBlock( blockFactory.EscapedMarkupTagBlock("<", "p>", AcceptedCharactersInternal.None), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{words and spaces}", @@ -3342,7 +3180,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock("<", "p>", AcceptedCharactersInternal.None), factory.Markup("words and spaces"), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{

}", @@ -3352,12 +3190,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None))), new [] { - new RazorError( - string.Format(errorFormatNormalUnclosed, "!p", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2), - new RazorError( - string.Format(errorFormatMalformed, "p", CultureInfo.InvariantCulture), - absoluteIndex: 8, lineIndex: 0, columnIndex: 8, length: 1) + MissingEndTagError("!p"), + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(absoluteIndex: 8, lineIndex: 0, characterIndex: 8, length: 1), "p") } }, { @@ -3368,12 +3203,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None)))), new [] { - new RazorError( - string.Format(errorFormatNormalUnclosed, "p", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1), - new RazorError( - string.Format(errorFormatMalformed, "p", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1) + MissingEndTagError("p"), + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(absoluteIndex: 3, lineIndex: 0, characterIndex: 3, length: 1), "p") } }, { @@ -3383,7 +3215,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupTagHelperBlock("p", blockFactory.EscapedMarkupTagBlock("<", "p>", AcceptedCharactersInternal.None), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None)))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{

}", @@ -3399,15 +3231,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("}"))))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorFormatNormalUnclosed, "p", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1), - new RazorError( - string.Format(errorFormatMalformed, "p", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + MissingEndTagError("p"), + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(absoluteIndex: 3, lineIndex: 0, characterIndex: 3, length: 1), "p") } }, { @@ -3427,12 +3255,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.EmptyHtml()), new [] { - new RazorError( - string.Format(errorFormatNormalNotStarted, "p", CultureInfo.InvariantCulture), - absoluteIndex: 13, lineIndex: 0, columnIndex: 13, length: 1), - new RazorError( - string.Format(errorFormatMalformed, "p", CultureInfo.InvariantCulture), - absoluteIndex: 13, lineIndex: 0, columnIndex: 13, length: 1) + RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag( + new SourceSpan(filePath: null, absoluteIndex: 13, lineIndex: 0, characterIndex: 13, length: 1), "p"), + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(absoluteIndex: 13, lineIndex: 0, characterIndex: 13, length: 1), "p") } }, { @@ -3452,18 +3278,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.EmptyHtml()), new [] { - new RazorError( - string.Format(errorFormatNormalUnclosed, "strong", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 6), - new RazorError( - string.Format(errorFormatMalformed, "strong", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 6), - new RazorError( - string.Format(errorFormatNormalNotStarted, "strong", CultureInfo.InvariantCulture), - absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 6), - new RazorError( - string.Format(errorFormatMalformed, "strong", CultureInfo.InvariantCulture), - absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 6) + MissingEndTagError("strong"), + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(absoluteIndex: 3, lineIndex: 0, characterIndex: 3, length: 6), "strong"), + RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag( + new SourceSpan(filePath: null, absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 6), "strong"), + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 6), "strong") } }, { @@ -3481,7 +3302,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.EmptyCSharp().AsStatement(), factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), factory.EmptyHtml()), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{

}", @@ -3504,24 +3325,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.EmptyHtml()), new [] { - new RazorError( - string.Format(errorFormatNormalUnclosed, "p", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1), - new RazorError( - string.Format(errorFormatMalformed, "p", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1), - new RazorError( - string.Format(errorFormatMalformed, "strong", CultureInfo.InvariantCulture), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 6), - new RazorError( - string.Format(errorFormatNormalUnclosed, "!p", CultureInfo.InvariantCulture), - absoluteIndex: 24, lineIndex: 0, columnIndex: 24, length: 2), - new RazorError( - string.Format(errorFormatMalformed, "strong", CultureInfo.InvariantCulture), - absoluteIndex: 29, lineIndex: 0, columnIndex: 29, length: 6), - new RazorError( - string.Format(errorFormatNormalNotStarted, "!p", CultureInfo.InvariantCulture), - absoluteIndex: 38, lineIndex: 0, columnIndex: 38, length: 2), + MissingEndTagError("p"), + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(absoluteIndex: 3, lineIndex: 0, characterIndex: 3, length: 1), "p"), + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(absoluteIndex: 6, lineIndex: 0, characterIndex: 6, length: 6), "strong"), + MissingEndTagError("!p", index: 24), + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(absoluteIndex: 29, lineIndex: 0, characterIndex: 29, length: 6), "strong"), + RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag( + new SourceSpan(filePath: null, absoluteIndex: 38, lineIndex: 0, characterIndex: 38, length: 2), "!p"), } }, }; @@ -3534,13 +3347,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var factory = new SpanFactory(); var blockFactory = new BlockFactory(factory); - var errorFormatNormalUnclosed = - "The \"{0}\" element was not closed. All elements must be either self-closing or have a " + - "matching end tag."; - var errorMatchingBrace = - "The code block is missing a closing \"}\" character. Make sure you have a matching \"}\" " + - "character for all the \"{\" characters within this block, and that none of the \"}\" " + - "characters are being interpreted as markup."; Func, MarkupBlock> buildStatementBlock = (insideBuilder) => { @@ -3556,7 +3362,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "@{}", @@ -3585,12 +3391,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("}")))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorFormatNormalUnclosed, "!p"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + RazorDiagnosticFactory.CreateParsing_MissingEndTag( + new SourceSpan(filePath: null, absoluteIndex: 3, lineIndex: 0, characterIndex: 3, length: 2), "!p"), } }, { @@ -3614,7 +3418,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("\"").With(SpanChunkGenerator.Null)), factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{words with spaces}", @@ -3638,7 +3442,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), factory.Markup("words with spaces"), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{}", @@ -3675,7 +3479,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("btn", 31, 0, 31)))), factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{}", @@ -3711,7 +3515,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("'").With(SpanChunkGenerator.Null)), factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, }; } @@ -3725,7 +3529,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy object expectedOutput, object expectedErrors) { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors, "strong", "p"); + RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors, "strong", "p"); } public static TheoryData OptOut_WithBlockData_HTML @@ -3734,30 +3538,28 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var factory = new SpanFactory(); var blockFactory = new BlockFactory(factory); - var errorFormatUnclosed = "Found a malformed '{0}' tag helper. Tag helpers must have a start and " + - "end tag or be self closing."; // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "", new MarkupBlock( blockFactory.EscapedMarkupTagBlock("<", "p>")), - new RazorError[0] + new RazorDiagnostic[0] }, { "", new MarkupBlock( blockFactory.EscapedMarkupTagBlock("")), - new RazorError[0] + new RazorDiagnostic[0] }, { "", new MarkupBlock( blockFactory.EscapedMarkupTagBlock("<", "p>"), blockFactory.EscapedMarkupTagBlock("")), - new RazorError[0] + new RazorDiagnostic[0] }, { "words and spaces", @@ -3765,7 +3567,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock("<", "p>"), factory.Markup("words and spaces"), blockFactory.EscapedMarkupTagBlock("")), - new RazorError[0] + new RazorDiagnostic[0] }, { "

", @@ -3774,9 +3576,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.MarkupTagBlock("

")), new [] { - new RazorError( - string.Format(errorFormatUnclosed, "p", CultureInfo.InvariantCulture), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 1) + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(absoluteIndex: 6, lineIndex: 0, characterIndex: 6, length: 1), "p") } }, { @@ -3785,10 +3586,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupTagHelperBlock("p", blockFactory.EscapedMarkupTagBlock(""))), new [] { - new RazorError( - string.Format(errorFormatUnclosed, "p", CultureInfo.InvariantCulture), - new SourceLocation(1, 0, 1), - length: 1) + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p") } }, { @@ -3797,7 +3596,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupTagHelperBlock("p", blockFactory.EscapedMarkupTagBlock("<", "p>"), blockFactory.EscapedMarkupTagBlock(""))), - new RazorError[0] + new RazorDiagnostic[0] }, { "

", @@ -3807,10 +3606,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock(""))), new [] { - new RazorError( - string.Format(errorFormatUnclosed, "p", CultureInfo.InvariantCulture), - new SourceLocation(1, 0, 1), - length: 1) + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p") } }, { @@ -3821,10 +3618,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.MarkupTagBlock("

")), new [] { - new RazorError( - string.Format(errorFormatUnclosed, "p", CultureInfo.InvariantCulture), - new SourceLocation(11, 0, 11), - length: 1) + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(new SourceLocation(11, 0, 11), contentLength: 1), "p") } }, { @@ -3832,7 +3627,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock( new MarkupTagHelperBlock("strong", blockFactory.EscapedMarkupTagBlock(""))), - new RazorError[0] + new RazorDiagnostic[0] }, { "", @@ -3840,7 +3635,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupTagHelperBlock("strong"), blockFactory.EscapedMarkupTagBlock("<", "p>"), blockFactory.EscapedMarkupTagBlock("")), - new RazorError[0] + new RazorDiagnostic[0] }, { "

", @@ -3852,10 +3647,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock(""))), new [] { - new RazorError( - string.Format(errorFormatUnclosed, "p", CultureInfo.InvariantCulture), - new SourceLocation(1, 0, 1), - length: 1) + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p") } }, }; @@ -3870,7 +3663,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var blockFactory = new BlockFactory(factory); // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "", @@ -3891,7 +3684,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("btn", 11, 0, 11))), factory.Markup("\"").With(SpanChunkGenerator.Null)), factory.Markup(">"))), - new RazorError[0] + new RazorDiagnostic[0] }, { "", @@ -3913,7 +3706,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("\"").With(SpanChunkGenerator.Null)), factory.Markup(">")), blockFactory.EscapedMarkupTagBlock("")), - new RazorError[0] + new RazorDiagnostic[0] }, { "words and spaces", @@ -3936,7 +3729,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup(">")), factory.Markup("words and spaces"), blockFactory.EscapedMarkupTagBlock("")), - new RazorError[0] + new RazorDiagnostic[0] }, { "", @@ -3972,7 +3765,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("btn", 29, 0, 29)))), factory.Markup(">")), blockFactory.EscapedMarkupTagBlock("")), - new RazorError[0] + new RazorDiagnostic[0] }, { "", @@ -4007,7 +3800,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("'").With(SpanChunkGenerator.Null)), factory.Markup(">")), blockFactory.EscapedMarkupTagBlock("")), - new RazorError[0] + new RazorDiagnostic[0] }, }; } @@ -4021,7 +3814,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy object expectedOutput, object expectedErrors) { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors, "strong", "p"); + RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors, "strong", "p"); } public static IEnumerable TextTagsBlockData @@ -4305,10 +4098,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.EmptyHtml()); var expectedErrors = new[] { - new RazorError( - "Encountered end tag \"div\" with no matching start tag. Are your start/end tags properly balanced?", - new SourceLocation(9, 0, 9), - 3), + RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag( + new SourceSpan(new SourceLocation(9, 0, 9), contentLength: 3), "div"), }; RunParseTreeRewriterTest(documentContent, expectedOutput, expectedErrors); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperRewritingTestBase.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperRewritingTestBase.cs index 8471aaf23a..8271cee1a9 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperRewritingTestBase.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperRewritingTestBase.cs @@ -16,14 +16,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy RunParseTreeRewriterTest( documentContent, expectedOutput, - errors: Enumerable.Empty(), + errors: Enumerable.Empty(), tagNames: tagNames); } internal void RunParseTreeRewriterTest( string documentContent, MarkupBlock expectedOutput, - IEnumerable errors, + IEnumerable errors, params string[] tagNames) { var descriptors = BuildDescriptors(tagNames); @@ -50,7 +50,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy IEnumerable descriptors, string documentContent, MarkupBlock expectedOutput, - IEnumerable expectedErrors, + IEnumerable expectedErrors, string tagHelperPrefix = null, RazorParserFeatureFlags featureFlags = null) { @@ -63,12 +63,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var actualTree = parseTreeRewriter.Rewrite(syntaxTree.Root, errorSink); - var allErrors = syntaxTree.Diagnostics.Concat(errorSink.Errors.Select(error => RazorDiagnostic.Create(error))); + var allErrors = syntaxTree.Diagnostics.Concat(errorSink.Errors); var actualErrors = allErrors .OrderBy(error => error.Span.AbsoluteIndex) .ToList(); - EvaluateRazorErrors(actualErrors, expectedErrors.Select(error => RazorDiagnostic.Create(error)).ToList()); + EvaluateRazorErrors(actualErrors, expectedErrors.ToList()); EvaluateParseTree(actualTree, expectedOutput); } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TokenizerLookaheadTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TokenizerLookaheadTest.cs index d8b98becfd..6abd70ad3e 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TokenizerLookaheadTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TokenizerLookaheadTest.cs @@ -106,7 +106,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy protected override CSharpSymbol CreateSymbol( string content, CSharpSymbolType type, - IReadOnlyList errors) + IReadOnlyList errors) { throw new NotImplementedException(); } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/LegacyRazorDiagnosticTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/LegacyRazorDiagnosticTest.cs deleted file mode 100644 index bc67e730c7..0000000000 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/LegacyRazorDiagnosticTest.cs +++ /dev/null @@ -1,170 +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; -using System.Globalization; -using Microsoft.AspNetCore.Razor.Language.Legacy; -using Xunit; - -namespace Microsoft.AspNetCore.Razor.Language -{ - public class LegacyRazorDiagnosticTest - { - [Fact] - public void LegacyRazorDiagnostic_Ctor() - { - // Arrange - var span = new SourceSpan("test.cs", 15, 1, 8, 5); - var error = new RazorError("This is an error", new SourceLocation("test.cs", 15, 1, 8), 5); - - // Act - var diagnostic = new LegacyRazorDiagnostic(error); - - // Assert - Assert.Equal("RZ9999", diagnostic.Id); - Assert.Equal(RazorDiagnosticSeverity.Error, diagnostic.Severity); - Assert.Equal(span, diagnostic.Span); - } - - [Fact] - public void LegacyRazorDiagnostic_GetMessage() - { - // Arrange - var error = new RazorError("This is an error", SourceLocation.Zero, 5); - var diagnostic = new LegacyRazorDiagnostic(error); - - // Act - var result = diagnostic.GetMessage(); - - // Assert - Assert.Equal("This is an error", result); - } - - // RazorError doesn't support format strings. - [Fact] - public void LegacyRazorDiagnostic_GetMessage_FormatProvider() - { - // Arrange - var error = new RazorError("This is an error", SourceLocation.Zero, 5); - var diagnostic = new LegacyRazorDiagnostic(error); - - // Act - var result = diagnostic.GetMessage(CultureInfo.InvariantCulture); - - // Assert - Assert.Equal("This is an error", result); - } - - [Fact] - public void LegacyRazorDiagnostic_ToString() - { - // Arrange - var error = new RazorError("This is an error", SourceLocation.Zero, 5); - var diagnostic = new LegacyRazorDiagnostic(error); - - // Act - var result = diagnostic.ToString(); - - // Assert - Assert.Equal("(1,1): Error RZ9999: This is an error", result); - } - - [Fact] - public void LegacyRazorDiagnostic_ToString_FormatProvider() - { - // Arrange - var error = new RazorError("This is an error", SourceLocation.Zero, 5); - var diagnostic = new LegacyRazorDiagnostic(new RazorError("This is an error", SourceLocation.Zero, 5)); - - // Act - var result = ((IFormattable)diagnostic).ToString("ignored", CultureInfo.InvariantCulture); - - // Assert - Assert.Equal("(1,1): Error RZ9999: This is an error", result); - } - - [Fact] - public void LegacyRazorDiagnostic_Equals() - { - // Arrange - var diagnostic1 = new LegacyRazorDiagnostic(new RazorError("This is an error", SourceLocation.Zero, 5)); - var diagnostic2 = new LegacyRazorDiagnostic(new RazorError("This is an error", SourceLocation.Zero, 5)); - - // Act - var result = diagnostic1.Equals(diagnostic2); - - // Assert - Assert.True(result); - } - - [Fact] - public void LegacyRazorDiagnostic_NotEquals_DifferentLocation() - { - // Arrange - var diagnostic1 = new LegacyRazorDiagnostic(new RazorError("This is an error", SourceLocation.Zero, 5)); - var diagnostic2 = new LegacyRazorDiagnostic(new RazorError("This is an error", SourceLocation.Zero, 1)); - - // Act - var result = diagnostic1.Equals(diagnostic2); - - // Assert - Assert.False(result); - } - - [Fact] - public void LegacyRazorDiagnostic_NotEquals_DifferentMessage() - { - // Arrange - var diagnostic1 = new LegacyRazorDiagnostic(new RazorError("This is an error", SourceLocation.Zero, 5)); - var diagnostic2 = new LegacyRazorDiagnostic(new RazorError("This is maybe an error", SourceLocation.Zero, 5)); - - // Act - var result = diagnostic1.Equals(diagnostic2); - - // Assert - Assert.False(result); - } - - [Fact] - public void LegacyRazorDiagnostic_HashCodesEqual() - { - // Arrange - var diagnostic1 = new LegacyRazorDiagnostic(new RazorError("This is an error", SourceLocation.Zero, 5)); - var diagnostic2 = new LegacyRazorDiagnostic(new RazorError("This is an error", SourceLocation.Zero, 5)); - - // Act - var result = diagnostic1.GetHashCode() == diagnostic2.GetHashCode(); - - // Assert - Assert.True(result); - } - - [Fact] - public void LegacyRazorDiagnostic_HashCodesNotEqual_DifferentLocation() - { - // Arrange - var diagnostic1 = new LegacyRazorDiagnostic(new RazorError("This is an error", SourceLocation.Zero, 5)); - var diagnostic2 = new LegacyRazorDiagnostic(new RazorError("This is an error", SourceLocation.Zero, 2)); - - // Act - var result = diagnostic1.GetHashCode() == diagnostic2.GetHashCode(); - - // Assert - Assert.False(result); - } - - [Fact] - public void LegacyRazorDiagnostic_HashCodesNotEqual_DifferentMessage() - { - // Arrange - var diagnostic1 = new LegacyRazorDiagnostic(new RazorError("This is an error", SourceLocation.Zero, 5)); - var diagnostic2 = new LegacyRazorDiagnostic(new RazorError("This is maybe an error", SourceLocation.Zero, 5)); - - // Act - var result = diagnostic1.GetHashCode() == diagnostic2.GetHashCode(); - - // Assert - Assert.False(result); - } - } -} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Microsoft.AspNetCore.Razor.Language.Test.csproj b/test/Microsoft.AspNetCore.Razor.Language.Test/Microsoft.AspNetCore.Razor.Language.Test.csproj index 0481f4e948..8f15748273 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Microsoft.AspNetCore.Razor.Language.Test.csproj +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Microsoft.AspNetCore.Razor.Language.Test.csproj @@ -5,6 +5,7 @@ $(TargetFrameworks);netcoreapp2.0 $(TargetFrameworks);net46 $(DefaultItemExcludes);TestFiles\**\* + $(DefineConstants);GENERATE_BASELINES diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorCodeDocumentExtensionsTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorCodeDocumentExtensionsTest.cs index 14c6aa4453..41f899512b 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorCodeDocumentExtensionsTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorCodeDocumentExtensionsTest.cs @@ -148,5 +148,67 @@ namespace Microsoft.AspNetCore.Razor.Language // Assert Assert.Same(expected, codeDocument.Items[typeof(TagHelperDocumentContext)]); } + + [Fact] + public void GetParserOptions_ReturnsSyntaxTree() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + var expected = RazorParserOptions.CreateDefault(); + codeDocument.Items[typeof(RazorParserOptions)] = expected; + + // Act + var actual = codeDocument.GetParserOptions(); + + // Assert + Assert.Same(expected, actual); + } + + [Fact] + public void SetParserOptions_SetsSyntaxTree() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + var expected = RazorParserOptions.CreateDefault(); + + // Act + codeDocument.SetParserOptions(expected); + + // Assert + Assert.Same(expected, codeDocument.Items[typeof(RazorParserOptions)]); + } + + [Fact] + public void GetCodeGenerationOptions_ReturnsSyntaxTree() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + var expected = RazorCodeGenerationOptions.CreateDefault(); + codeDocument.Items[typeof(RazorCodeGenerationOptions)] = expected; + + // Act + var actual = codeDocument.GetCodeGenerationOptions(); + + // Assert + Assert.Same(expected, actual); + } + + [Fact] + public void SetCodeGenerationOptions_SetsSyntaxTree() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + var expected = RazorCodeGenerationOptions.CreateDefault(); + + // Act + codeDocument.SetCodeGenerationOptions(expected); + + // Assert + Assert.Same(expected, codeDocument.Items[typeof(RazorCodeGenerationOptions)]); + } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorDiagnosticTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorDiagnosticTest.cs index 795a7e1340..0ad45e8ed5 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorDiagnosticTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorDiagnosticTest.cs @@ -41,22 +41,5 @@ namespace Microsoft.AspNetCore.Razor.Language Assert.Equal(RazorDiagnosticSeverity.Error, defaultDiagnostic.Severity); Assert.Equal(span, diagnostic.Span); } - - [Fact] - public void Create_WithRazorError_CreatesLegacyRazorDiagnostic() - { - // Arrange - var span = new SourceSpan("test.cs", 15, 1, 8, 5); - var error = new RazorError("This is an error", new SourceLocation("test.cs", 15, 1, 8), 5); - - // Act - var diagnostic = RazorDiagnostic.Create(error); - - // Assert - var legacyDiagnostic = Assert.IsType(diagnostic); - Assert.Equal("RZ9999", legacyDiagnostic.Id); - Assert.Equal(RazorDiagnosticSeverity.Error, legacyDiagnostic.Severity); - Assert.Equal(span, diagnostic.Span); - } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorEngineTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorEngineTest.cs index 57639292ea..424b5fddd4 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorEngineTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorEngineTest.cs @@ -144,7 +144,8 @@ namespace Microsoft.AspNetCore.Razor.Language Assert.Collection( feature.TargetExtensions, - extension => Assert.False(Assert.IsType(extension).DesignTime), + extension => Assert.IsType(extension), + extension => Assert.IsType(extension), extension => Assert.IsType(extension)); } @@ -154,9 +155,11 @@ namespace Microsoft.AspNetCore.Razor.Language features, feature => Assert.IsType(feature), feature => Assert.IsType(feature), + feature => Assert.IsType(feature), feature => Assert.IsType(feature), feature => Assert.IsType(feature), feature => Assert.IsType(feature), + feature => Assert.IsType(feature), feature => Assert.IsType(feature), feature => Assert.IsType(feature), feature => Assert.IsType(feature), @@ -186,7 +189,8 @@ namespace Microsoft.AspNetCore.Razor.Language Assert.Collection( feature.TargetExtensions, - extension => Assert.True(Assert.IsType(extension).DesignTime), + extension => Assert.IsType(extension), + extension => Assert.IsType(extension), extension => Assert.IsType(extension)); } @@ -196,9 +200,11 @@ namespace Microsoft.AspNetCore.Razor.Language features, feature => Assert.IsType(feature), feature => Assert.IsType(feature), + feature => Assert.IsType(feature), feature => Assert.IsType(feature), feature => Assert.IsType(feature), feature => Assert.IsType(feature), + feature => Assert.IsType(feature), feature => Assert.IsType(feature), feature => Assert.IsType(feature), feature => Assert.IsType(feature), diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorProjectEngineBuilderExtensionsTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorProjectEngineBuilderExtensionsTest.cs new file mode 100644 index 0000000000..f0a57128c3 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorProjectEngineBuilderExtensionsTest.cs @@ -0,0 +1,103 @@ +// 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.CodeGeneration; +using Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class RazorProjectEngineBuilderExtensionsTest + { + [Fact] + public void SetImportFeature_SetsTheImportFeature() + { + // Arrange + var builder = new DefaultRazorProjectEngineBuilder(RazorConfiguration.Default, Mock.Of()); + var testFeature1 = Mock.Of(); + var testFeature2 = Mock.Of(); + builder.Features.Add(testFeature1); + builder.Features.Add(testFeature2); + var newFeature = Mock.Of(); + + // Act + builder.SetImportFeature(newFeature); + + // Assert + var feature = Assert.Single(builder.Features); + Assert.Same(newFeature, feature); + } + + [Fact] + public void AddTargetExtension_CreatesAndAddsToTargetExtensionFeatureIfItDoesNotExist() + { + // Arrange + var builder = new DefaultRazorProjectEngineBuilder(RazorConfiguration.Default, Mock.Of()); + var expectedExtension = Mock.Of(); + + // Act + builder.AddTargetExtension(expectedExtension); + + // Assert + var feature = Assert.Single(builder.Features); + var codeTargetExtensionFeature = Assert.IsAssignableFrom(feature); + var extensions = Assert.Single(codeTargetExtensionFeature.TargetExtensions); + Assert.Same(expectedExtension, extensions); + } + + [Fact] + public void AddTargetExtension_UsesExistingFeatureIfExistsAndAddsTo() + { + // Arrange + var builder = new DefaultRazorProjectEngineBuilder(RazorConfiguration.Default, Mock.Of()); + var codeTargetExtensionFeature = new DefaultRazorTargetExtensionFeature(); + builder.Features.Add(codeTargetExtensionFeature); + var expectedExtension = Mock.Of(); + + // Act + builder.AddTargetExtension(expectedExtension); + + // Assert + var feature = Assert.Single(builder.Features); + Assert.Same(codeTargetExtensionFeature, feature); + var extensions = Assert.Single(codeTargetExtensionFeature.TargetExtensions); + Assert.Same(expectedExtension, extensions); + } + + [Fact] + public void AddDirective_CreatesAndAddsToDirectiveFeatureIfItDoesNotExist() + { + // Arrange + var builder = new DefaultRazorProjectEngineBuilder(RazorConfiguration.Default, Mock.Of()); + var expectedDirective = Mock.Of(); + + // Act + builder.AddDirective(expectedDirective); + + // Assert + var feature = Assert.Single(builder.Features); + var directiveFeature = Assert.IsAssignableFrom(feature); + var directive = Assert.Single(directiveFeature.Directives); + Assert.Same(expectedDirective, directive); + } + + [Fact] + public void AddDirective_UsesExistingFeatureIfExistsAndAddsTo() + { + // Arrange + var builder = new DefaultRazorProjectEngineBuilder(RazorConfiguration.Default, Mock.Of()); + var directiveFeature = new DefaultRazorDirectiveFeature(); + builder.Features.Add(directiveFeature); + var expecteDirective = Mock.Of(); + + // Act + builder.AddDirective(expecteDirective); + + // Assert + var feature = Assert.Single(builder.Features); + Assert.Same(directiveFeature, feature); + var directive = Assert.Single(directiveFeature.Directives); + Assert.Same(expecteDirective, directive); + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorProjectEngineFeatureBaseTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorProjectEngineFeatureBaseTest.cs new file mode 100644 index 0000000000..8344e787c7 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorProjectEngineFeatureBaseTest.cs @@ -0,0 +1,34 @@ +// 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 Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class RazorProjectEngineFeatureBaseTest + { + [Fact] + public void ProjectEngineSetter_CallsOnInitialized() + { + // Arrange + var testFeature = new TestFeature(); + + // Act + testFeature.ProjectEngine = Mock.Of(); + + // Assert + Assert.Equal(1, testFeature.InitializationCount); + } + + private class TestFeature : RazorProjectEngineFeatureBase + { + public int InitializationCount { get; private set; } + + protected override void OnInitialized() + { + InitializationCount++; + } + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorProjectEngineTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorProjectEngineTest.cs new file mode 100644 index 0000000000..d901c16199 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorProjectEngineTest.cs @@ -0,0 +1,85 @@ +// 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.Linq; +using Microsoft.AspNetCore.Razor.Language.Extensions; +using Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Test +{ + public class RazorProjectEngineTest + { + [Fact] + public void CreateDesignTime_Lambda_AddsFeaturesAndPhases() + { + // Arrange + + // Act + var engine = RazorProjectEngine.Create(RazorConfiguration.Default, Mock.Of()); + + // Assert + AssertDefaultPhases(engine); + AssertDefaultFeatures(engine); + AssertDefaultDirectives(engine); + AssertDefaultTargetExtensions(engine); + } + + private static void AssertDefaultPhases(RazorProjectEngine engine) + { + Assert.Collection( + engine.Phases, + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase)); + } + + private static void AssertDefaultFeatures(RazorProjectEngine engine) + { + var features = engine.EngineFeatures.OrderBy(f => f.GetType().Name).ToArray(); + Assert.Collection( + features, + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature)); + } + + private static void AssertDefaultDirectives(RazorProjectEngine engine) + { + var feature = engine.EngineFeatures.OfType().FirstOrDefault(); + Assert.NotNull(feature); + Assert.Empty(feature.Directives); + } + + private static void AssertDefaultTargetExtensions(RazorProjectEngine engine) + { + var feature = engine.EngineFeatures.OfType().FirstOrDefault(); + Assert.NotNull(feature); + + var extensions = feature.TargetExtensions.OrderBy(f => f.GetType().Name).ToArray(); + Assert.Collection( + extensions, + extension => Assert.IsType(extension), + extension => Assert.IsType(extension), + extension => Assert.IsType(extension), + extension => Assert.IsType(extension)); + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorSourceDocumentTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorSourceDocumentTest.cs index 7288f8a43c..9c05f2851c 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorSourceDocumentTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorSourceDocumentTest.cs @@ -37,6 +37,22 @@ namespace Microsoft.AspNetCore.Razor.Language Assert.Same(Encoding.UTF32, Assert.IsType(document).Encoding); } + [Fact] + public void ReadFrom_WithProperties() + { + // Arrange + var content = TestRazorSourceDocument.CreateStreamContent(encoding: Encoding.UTF32); + var properties = new RazorSourceDocumentProperties("c:\\myapp\\filePath.cshtml", "filePath.cshtml"); + + // Act + var document = RazorSourceDocument.ReadFrom(content, Encoding.UTF32, properties); + + // Assert + Assert.Equal("c:\\myapp\\filePath.cshtml", document.FilePath); + Assert.Equal("filePath.cshtml", document.RelativePath); + Assert.Same(Encoding.UTF32, Assert.IsType(document).Encoding); + } + [Fact] public void ReadFrom_EmptyStream_WithEncoding() { @@ -52,30 +68,62 @@ namespace Microsoft.AspNetCore.Razor.Language } [Fact] - public void ReadFrom_UsesProjectItemPhysicalPath() + public void ReadFrom_ProjectItem() { // Arrange - var projectItem = new TestRazorProjectItem("/test-path", "some-physical-path"); + var projectItem = new TestRazorProjectItem("filePath.cshtml", "c:\\myapp\\filePath.cshtml", "filePath.cshtml", "c:\\myapp\\"); // Act var document = RazorSourceDocument.ReadFrom(projectItem); // Assert - Assert.Equal(projectItem.PhysicalPath, document.FilePath); + Assert.Equal("c:\\myapp\\filePath.cshtml", document.FilePath); + Assert.Equal("filePath.cshtml", document.RelativePath); Assert.Equal(projectItem.Content, ReadContent(document)); } [Fact] - public void ReadFrom_ProjectItem() + public void ReadFrom_ProjectItem_NoRelativePath() { // Arrange - var projectItem = new TestRazorProjectItem("/test-path"); + var projectItem = new TestRazorProjectItem("filePath.cshtml", "c:\\myapp\\filePath.cshtml", basePath: "c:\\myapp\\"); // Act var document = RazorSourceDocument.ReadFrom(projectItem); // Assert - Assert.Equal(projectItem.FilePath, document.FilePath); + Assert.Equal("c:\\myapp\\filePath.cshtml", document.FilePath); + Assert.Equal("filePath.cshtml", document.RelativePath); + Assert.Equal(projectItem.Content, ReadContent(document)); + } + + [Fact] + public void ReadFrom_ProjectItem_FallbackToRelativePath() + { + // Arrange + var projectItem = new TestRazorProjectItem("filePath.cshtml", relativePhysicalPath: "filePath.cshtml", basePath: "c:\\myapp\\"); + + // Act + var document = RazorSourceDocument.ReadFrom(projectItem); + + // Assert + Assert.Equal("filePath.cshtml", document.FilePath); + Assert.Equal("filePath.cshtml", document.RelativePath); + Assert.Equal(projectItem.Content, ReadContent(document)); + } + + [Fact] + public void ReadFrom_ProjectItem_FallbackToFileName() + { + // Arrange + var projectItem = new TestRazorProjectItem("filePath.cshtml", basePath: "c:\\myapp\\"); + + // Act + var document = RazorSourceDocument.ReadFrom(projectItem); + + // Assert + Assert.Equal("filePath.cshtml", document.FilePath); + Assert.Equal("filePath.cshtml", document.RelativePath); Assert.Equal(projectItem.Content, ReadContent(document)); } @@ -112,6 +160,54 @@ namespace Microsoft.AspNetCore.Razor.Language Assert.Same(encoding, document.Encoding); } + [Fact] + public void Create_WithProperties() + { + // Arrange + var content = "Hello world"; + var properties = new RazorSourceDocumentProperties("c:\\myapp\\filePath.cshtml", "filePath.cshtml"); + + // Act + var document = RazorSourceDocument.Create(content, Encoding.UTF32, properties); + + // Assert + Assert.Equal("c:\\myapp\\filePath.cshtml", document.FilePath); + Assert.Equal("filePath.cshtml", document.RelativePath); + Assert.Equal(content, ReadContent(document)); + Assert.Same(Encoding.UTF32, Assert.IsType(document).Encoding); + } + + [Fact] + public void ReadFrom_WithProjectItem_FallbackToFilePath_WhenRelativePhysicalPathIsNull() + { + // Arrange + var filePath = "filePath.cshtml"; + var projectItem = new TestRazorProjectItem(filePath, relativePhysicalPath: null); + + // Act + var document = RazorSourceDocument.ReadFrom(projectItem); + + // Assert + Assert.Equal(filePath, document.FilePath); + Assert.Equal(filePath, document.RelativePath); + } + + [Fact] + public void ReadFrom_WithProjectItem_UsesRelativePhysicalPath() + { + // Arrange + var filePath = "filePath.cshtml"; + var relativePhysicalPath = "relative-path.cshtml"; + var projectItem = new TestRazorProjectItem(filePath, relativePhysicalPath: relativePhysicalPath); + + // Act + var document = RazorSourceDocument.ReadFrom(projectItem); + + // Assert + Assert.Equal(relativePhysicalPath, document.FilePath); + Assert.Equal(relativePhysicalPath, document.RelativePath); + } + private static string ReadContent(RazorSourceDocument razorSourceDocument) { var buffer = new char[razorSourceDocument.Length]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorSyntaxTreeTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorSyntaxTreeTest.cs index 54466376cd..09b36651ce 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorSyntaxTreeTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorSyntaxTreeTest.cs @@ -29,7 +29,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Test { // Arrange var filePath = "test.cshtml"; - var source = TestRazorSourceDocument.Create("@if (true) { @if(false) {

@something.
} }", fileName: filePath); + var source = TestRazorSourceDocument.Create("@if (true) { @if(false) {
@something.
} }", filePath: filePath); // Act var syntaxTree = RazorSyntaxTree.Parse(source); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorTemplateEngineTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorTemplateEngineTest.cs index 453788d36c..e77c5a05fa 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorTemplateEngineTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorTemplateEngineTest.cs @@ -15,16 +15,16 @@ namespace Microsoft.AspNetCore.Razor.Language public void GetImports_CanQueryInformationOnNonExistentFileWithoutImports() { // Arrange - var project = new TestRazorProject(); + var fileSystem = new TestRazorProjectFileSystem(); var razorEngine = RazorEngine.Create(); - var templateEngine = new RazorTemplateEngine(razorEngine, project) + var templateEngine = new RazorTemplateEngine(razorEngine, fileSystem) { Options = { ImportsFileName = "MyImport.cshtml" } }; - var projectItemToQuery = project.GetItem("/Views/Home/Index.cshtml"); + var projectItemToQuery = fileSystem.GetItem("/Views/Home/Index.cshtml"); // Act var imports = templateEngine.GetImports(projectItemToQuery); @@ -39,7 +39,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var path = "/Views/Home/MyImport.cshtml"; var projectItem = new TestRazorProjectItem(path); - var project = new TestRazorProject(new[] { projectItem }); + var project = new TestRazorProjectFileSystem(new[] { projectItem }); var razorEngine = RazorEngine.Create(); var templateEngine = new RazorTemplateEngine(razorEngine, project) { @@ -62,7 +62,7 @@ namespace Microsoft.AspNetCore.Razor.Language public void GenerateCode_ThrowsIfItemCannotBeFound() { // Arrange - var project = new TestRazorProject(new RazorProjectItem[] { }); + var project = new TestRazorProjectFileSystem(new RazorProjectItem[] { }); var razorEngine = RazorEngine.Create(); var templateEngine = new RazorTemplateEngine(razorEngine, project); @@ -76,7 +76,7 @@ namespace Microsoft.AspNetCore.Razor.Language public void SettingOptions_ThrowsIfValueIsNull() { // Arrange - var project = new TestRazorProject(new RazorProjectItem[] { }); + var project = new TestRazorProjectFileSystem(new RazorProjectItem[] { }); var razorEngine = RazorEngine.Create(); var templateEngine = new RazorTemplateEngine(razorEngine, project); @@ -92,7 +92,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var path = "/Views/Home/Index.cshtml"; var projectItem = new TestRazorProjectItem(path); - var project = new TestRazorProject(new[] { projectItem }); + var project = new TestRazorProjectFileSystem(new[] { projectItem }); var razorEngine = RazorEngine.Create(); var templateEngine = new RazorTemplateEngine(razorEngine, project); @@ -110,7 +110,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var path = "/Views/Home/Index.cshtml"; - var project = new TestRazorProject(new RazorProjectItem[] { }); + var project = new TestRazorProjectFileSystem(new RazorProjectItem[] { }); var razorEngine = RazorEngine.Create(); var templateEngine = new RazorTemplateEngine(razorEngine, project); @@ -125,7 +125,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var path = "/Views/Home/Index.cshtml"; var projectItem = new TestRazorProjectItem(path); - var project = new TestRazorProject(new[] { projectItem }); + var project = new TestRazorProjectFileSystem(new[] { projectItem }); var razorEngine = RazorEngine.Create(); var templateEngine = new RazorTemplateEngine(razorEngine, project); @@ -144,7 +144,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var path = "/Views/Home/Index.cshtml"; var projectItem = new TestRazorProjectItem(path); - var project = new TestRazorProject(new[] { projectItem }); + var project = new TestRazorProjectFileSystem(new[] { projectItem }); var razorEngine = RazorEngine.Create(); var templateEngine = new RazorTemplateEngine(razorEngine, project); @@ -168,7 +168,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var projectItem = new TestRazorProjectItem("/Views/Home/Index.cshtml"); - var project = new TestRazorProject(new[] { projectItem }); + var project = new TestRazorProjectFileSystem(new[] { projectItem }); var razorEngine = RazorEngine.Create(); var templateEngine = new RazorTemplateEngine(razorEngine, project) { @@ -192,7 +192,7 @@ namespace Microsoft.AspNetCore.Razor.Language var projectItem = new TestRazorProjectItem("/Views/Home/Index.cshtml"); var import1 = new TestRazorProjectItem("/MyImport.cshtml"); var import2 = new TestRazorProjectItem("/Views/Home/MyImport.cshtml"); - var project = new TestRazorProject(new[] { import1, import2, projectItem }); + var project = new TestRazorProjectFileSystem(new[] { import1, import2, projectItem }); var razorEngine = RazorEngine.Create(); var templateEngine = new RazorTemplateEngine(razorEngine, project) { @@ -218,7 +218,7 @@ namespace Microsoft.AspNetCore.Razor.Language var projectItem = new TestRazorProjectItem("/Views/Home/Index.cshtml"); var import1 = new TestRazorProjectItem("/MyImport.cshtml"); var import2 = new TestRazorProjectItem("/Views/Home/MyImport.cshtml"); - var project = new TestRazorProject(new[] { import1, import2, projectItem }); + var project = new TestRazorProjectFileSystem(new[] { import1, import2, projectItem }); var razorEngine = RazorEngine.Create(); var defaultImport = RazorSourceDocument.ReadFrom(new MemoryStream(), "Default.cshtml"); var templateEngine = new RazorTemplateEngine(razorEngine, project) @@ -245,7 +245,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var projectItem = new TestRazorProjectItem("/Views/Home/Index.cshtml"); - var project = new TestRazorProject(new[] { projectItem }); + var project = new TestRazorProjectFileSystem(new[] { projectItem }); var razorEngine = RazorEngine.Create(); var defaultImport = RazorSourceDocument.ReadFrom(new MemoryStream(), "Default.cshtml"); var templateEngine = new RazorTemplateEngine(razorEngine, project) @@ -269,7 +269,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var expected = new[] { "/Views/Home/MyImport.cshtml", "/Views/MyImport.cshtml", "/MyImport.cshtml" }; - var project = new TestRazorProject(); + var project = new TestRazorProjectFileSystem(); var razorEngine = RazorEngine.Create(); var templateEngine = new RazorTemplateEngine(razorEngine, project) { @@ -293,9 +293,9 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var expected = new[] { "/Views/Home/MyImport.cshtml", "/Views/MyImport.cshtml", "/MyImport.cshtml" }; var projectItem = new TestRazorProjectItem("/Views/Home/Index.cshtml"); - var project = new TestRazorProject(new[] { projectItem }); + var fileSystem = new TestRazorProjectFileSystem(new[] { projectItem }); var razorEngine = RazorEngine.Create(); - var templateEngine = new RazorTemplateEngine(razorEngine, project) + var templateEngine = new RazorTemplateEngine(razorEngine, fileSystem) { Options = { @@ -310,5 +310,51 @@ namespace Microsoft.AspNetCore.Razor.Language var paths = imports.Select(i => i.FilePath); Assert.Equal(expected, paths); } + + [Fact] + public void CreateCodeDocument_WithFileSystemProject_ReturnsCorrectItems() + { + // Arrange + var testFolder = Path.Combine( + TestProject.GetProjectDirectory(typeof(DefaultRazorProjectFileSystemTest)), + "TestFiles", + "DefaultRazorProjectFileSystem"); + + var project = new DefaultRazorProjectFileSystem(testFolder); + var razorEngine = RazorEngine.Create(); + var templateEngine = new RazorTemplateEngine(razorEngine, project) + { + Options = + { + ImportsFileName = "_ViewImports.cshtml" + } + }; + + // Act + var codeDocument = templateEngine.CreateCodeDocument("/Views/Home/Index.cshtml"); + + // Assert + Assert.Collection( + codeDocument.Imports, + item => + { + Assert.Equal(Path.Combine(testFolder, "_ViewImports.cshtml"), item.FilePath); + Assert.Equal("_ViewImports.cshtml", item.RelativePath); + + }, + item => + { + Assert.Equal(Path.Combine(testFolder, "Views", "_ViewImports.cshtml"), item.FilePath); + Assert.Equal(Path.Combine("Views", "_ViewImports.cshtml"), item.RelativePath); + + }, + item => + { + Assert.Equal(Path.Combine(testFolder, "Views", "Home", "_ViewImports.cshtml"), item.FilePath); + Assert.Equal(Path.Combine("Views", "Home", "_ViewImports.cshtml"), item.RelativePath); + + }); + } + } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/SourceLocationTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/SourceLocationTest.cs index ec7fd726ca..c2401c56b7 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/SourceLocationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/SourceLocationTest.cs @@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.Razor.Language } [Fact] - public void Equals_ReturnsTrue_FilePathsNullAndAbsoluteIndicesMatch() + public void Equals_ReturnsFalse_FilePathsNullAndAbsoluteIndicesMatch() { // Arrange var sourceLocationA = new SourceLocation(10, 3, 4); @@ -71,7 +71,7 @@ namespace Microsoft.AspNetCore.Razor.Language var result = sourceLocationA.Equals(sourceLocationB); // Assert - Assert.True(result); + Assert.False(result); } [Fact] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/StreamSourceDocumentTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/StreamSourceDocumentTest.cs index 84163a1c57..f377450320 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/StreamSourceDocumentTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/StreamSourceDocumentTest.cs @@ -10,13 +10,69 @@ namespace Microsoft.AspNetCore.Razor.Language { public class StreamSourceDocumentTest { + [Fact] + public void FilePath() + { + // Arrange + var content = "Hello World!"; + var stream = CreateBOMStream(content, Encoding.UTF8); + + // Act + var document = new StreamSourceDocument(stream, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: "file.cshtml", relativePath: null)); + + // Assert + Assert.Equal("file.cshtml", document.FilePath); + } + + [Fact] + public void FilePath_Null() + { + // Arrange + var content = "Hello World!"; + var stream = CreateBOMStream(content, Encoding.UTF8); + + // Act + var document = new StreamSourceDocument(stream, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: null, relativePath: null)); + + // Assert + Assert.Null(document.FilePath); + } + + [Fact] + public void RelativePath() + { + // Arrange + var content = "Hello World!"; + var stream = CreateBOMStream(content, Encoding.UTF8); + + // Act + var document = new StreamSourceDocument(stream, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: null, relativePath: "file.cshtml")); + + // Assert + Assert.Equal("file.cshtml", document.RelativePath); + } + + [Fact] + public void RelativePath_Null() + { + // Arrange + var content = "Hello World!"; + var stream = CreateBOMStream(content, Encoding.UTF8); + + // Act + var document = new StreamSourceDocument(stream, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: null, relativePath: null)); + + // Assert + Assert.Null(document.RelativePath); + } + [Fact] public void GetChecksum_ReturnsCopiedChecksum() { // Arrange var content = "Hello World!"; var stream = CreateBOMStream(content, Encoding.UTF8); - var document = new StreamSourceDocument(stream, Encoding.UTF8, "file.cshtml"); + var document = new StreamSourceDocument(stream, null, RazorSourceDocumentProperties.Default); // Act var firstChecksum = document.GetChecksum(); @@ -33,7 +89,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var content = "Hello World!"; var stream = CreateBOMStream(content, Encoding.UTF8); - var document = new StreamSourceDocument(stream, Encoding.UTF8, "file.cshtml"); + var document = new StreamSourceDocument(stream, Encoding.UTF8, RazorSourceDocumentProperties.Default); var expectedChecksum = new byte[] { 70, 180, 84, 105, 70, 79, 152, 31, 71, 157, 46, 159, 50, 83, 1, 243, 222, 48, 90, 18 }; // Act @@ -49,7 +105,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var content = "Hello World!"; var stream = CreateBOMStream(content, Encoding.UTF32); - var document = new StreamSourceDocument(stream, encoding: null, fileName: "file.cshtml"); + var document = new StreamSourceDocument(stream, null, RazorSourceDocumentProperties.Default); var expectedChecksum = new byte[] { 159, 154, 109, 89, 250, 163, 165, 108, 2, 112, 34, 4, 247, 161, 82, 168, 77, 213, 107, 71 }; // Act @@ -66,11 +122,10 @@ namespace Microsoft.AspNetCore.Razor.Language var content = TestRazorSourceDocument.CreateStreamContent(encoding: Encoding.UTF32); // Act - var document = new StreamSourceDocument(content, encoding: null, fileName: "file.cshtml"); + var document = new StreamSourceDocument(content, null, RazorSourceDocumentProperties.Default); // Assert Assert.IsType(document); - Assert.Equal("file.cshtml", document.FilePath); Assert.Equal(Encoding.UTF32, document.Encoding); } @@ -81,11 +136,10 @@ namespace Microsoft.AspNetCore.Razor.Language var content = TestRazorSourceDocument.CreateStreamContent(content: string.Empty, encoding: Encoding.UTF32); // Act - var document = new StreamSourceDocument(content, encoding: null, fileName: "file.cshtml"); + var document = new StreamSourceDocument(content, null, RazorSourceDocumentProperties.Default); // Assert Assert.IsType(document); - Assert.Equal("file.cshtml", document.FilePath); Assert.Equal(Encoding.UTF32, document.Encoding); } @@ -98,7 +152,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Act & Assert var exception = Assert.Throws( - () => new StreamSourceDocument(content, Encoding.UTF8, "file.cshtml")); + () => new StreamSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default)); Assert.Equal(expectedMessage, exception.Message); } @@ -115,12 +169,11 @@ namespace Microsoft.AspNetCore.Razor.Language var stream = TestRazorSourceDocument.CreateStreamContent(content); // Act - var document = new StreamSourceDocument(stream, encoding: null, fileName: "file.cshtml"); + var document = new StreamSourceDocument(stream, null, RazorSourceDocumentProperties.Default); // Assert var streamDocument = Assert.IsType(document); Assert.IsType(streamDocument._innerSourceDocument); - Assert.Equal("file.cshtml", document.FilePath); Assert.Same(Encoding.UTF8, document.Encoding); Assert.Equal(content, ReadContent(document)); } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/StringSourceDocumentTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/StringSourceDocumentTest.cs index 16acfc8be9..8306d2bf80 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/StringSourceDocumentTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/StringSourceDocumentTest.cs @@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var content = "Hello World!"; - var document = new StringSourceDocument(content, Encoding.UTF8, "file.cshtml"); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var firstChecksum = document.GetChecksum(); @@ -29,7 +29,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var content = "Hello World!"; - var document = new StringSourceDocument(content, Encoding.UTF8, "file.cshtml"); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); var expectedChecksum = new byte[] { 46, 247, 189, 230, 8, 206, 84, 4, 233, 125, 95, 4, 47, 149, 248, 159, 28, 35, 40, 113 }; // Act @@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var content = "Hello World!"; - var document = new StringSourceDocument(content, Encoding.UTF32, "file.cshtml"); + var document = new StringSourceDocument(content, Encoding.UTF32, RazorSourceDocumentProperties.Default); var expectedChecksum = new byte[] { 8, 149, 159, 15, 242, 255, 115, 227, 219, 78, 61, 53, 127, 239, 77, 239, 215, 140, 248, 44 }; // Act @@ -60,7 +60,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var expectedContent = "Hello, World!"; var indexerBuffer = new char[expectedContent.Length]; - var document = new StringSourceDocument(expectedContent, Encoding.UTF8, filePath: "file.cshtml"); + var document = new StringSourceDocument(expectedContent, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act for (var i = 0; i < document.Length; i++) @@ -78,7 +78,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var expectedContent = "Hello, World!"; - var document = new StringSourceDocument(expectedContent, Encoding.UTF8, filePath: "file.cshtml"); + var document = new StringSourceDocument(expectedContent, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act & Assert Assert.Equal(expectedContent.Length, document.Length); @@ -91,7 +91,7 @@ namespace Microsoft.AspNetCore.Razor.Language var content = "Hello, World!"; // Act - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: "file.cshtml"); + var document = new StringSourceDocument(content, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: "file.cshtml", relativePath: null)); // Assert Assert.Equal("file.cshtml", document.FilePath); @@ -104,18 +104,44 @@ namespace Microsoft.AspNetCore.Razor.Language var content = "Hello, World!"; // Act - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: null, relativePath: null)); // Assert Assert.Null(document.FilePath); } + [Fact] + public void RelativePath() + { + // Arrange + var content = "Hello, World!"; + + // Act + var document = new StringSourceDocument(content, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: null, relativePath: "file.cshtml")); + + // Assert + Assert.Equal("file.cshtml", document.RelativePath); + } + + [Fact] + public void RelativePath_Null() + { + // Arrange + var content = "Hello, World!"; + + // Act + var document = new StringSourceDocument(content, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: null, relativePath: null)); + + // Assert + Assert.Null(document.RelativePath); + } + [Fact] public void CopyTo_PartialCopyFromStart() { // Arrange var content = "Hello, World!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); var expectedContent = "Hello"; var charBuffer = new char[expectedContent.Length]; @@ -132,7 +158,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var content = "Hello, World!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); var expectedContent = "$Hello"; var charBuffer = new char[expectedContent.Length]; charBuffer[0] = '$'; @@ -150,7 +176,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var content = "Hello, World!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); var expectedContent = "World"; var charBuffer = new char[expectedContent.Length]; @@ -162,28 +188,12 @@ namespace Microsoft.AspNetCore.Razor.Language Assert.Equal(expectedContent, copiedContent); } - [Fact] - public void CopyTo_WithEncoding() - { - // Arrange - var content = "Hi"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); - var charBuffer = new char[2]; - - // Act - document.CopyTo(0, charBuffer, 0, 2); - - // Assert - var copiedContent = new string(charBuffer); - Assert.Equal("Hi", copiedContent); - } - [Fact] public void CopyTo_CanCopyMultipleTimes() { // Arrange var content = "Hi"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act & Assert // @@ -202,7 +212,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var content = string.Empty; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = document.Lines.Count; @@ -216,7 +226,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var content = string.Empty; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = document.Lines.GetLineLength(0); @@ -230,7 +240,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var content = "hello\n"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = document.Lines.GetLineLength(0); @@ -244,7 +254,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var content = "hello\r\n"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = document.Lines.GetLineLength(0); @@ -263,7 +273,7 @@ namespace Microsoft.AspNetCore.Razor.Language .Append("jumps over the lazy dog.") .ToString(); - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = GetAllSourceMappings(document); @@ -278,7 +288,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var content = "Hello\r\nWorld!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = GetAllSourceMappings(document); @@ -293,7 +303,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var content = "Hello\rWorld!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = GetAllSourceMappings(document); @@ -309,7 +319,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var content = "Hello\rBig\r\nWorld!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = GetAllSourceMappings(document); @@ -324,7 +334,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var content = "Hello\nWorld!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = GetAllSourceMappings(document); @@ -339,7 +349,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var content = "Hello\u0085World!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = GetAllSourceMappings(document); @@ -354,7 +364,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var content = "Hello\u2028World!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = GetAllSourceMappings(document); @@ -369,7 +379,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var content = "Hello\u2029World!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = GetAllSourceMappings(document); @@ -384,7 +394,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var content = "Hello, World!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: "Hi.cshtml"); + var document = new StringSourceDocument(content, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: "Hi.cshtml", relativePath: null)); // Act var actual = document.Lines.GetLocation(1); @@ -394,6 +404,22 @@ namespace Microsoft.AspNetCore.Razor.Language Assert.Equal(1, actual.AbsoluteIndex); } + [Fact] + public void Lines_GetLocation_PrefersRelativePath() + { + // Arrange + var content = "Hello, World!"; + + var document = new StringSourceDocument(content, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: "Hi.cshtml", relativePath: "Bye.cshtml")); + + // Act + var actual = document.Lines.GetLocation(1); + + // Assert + Assert.Equal("Bye.cshtml", actual.FilePath); + Assert.Equal(1, actual.AbsoluteIndex); + } + // Beginnings of lines are special because the BinarySearch in the implementation // will succeed. It's a different code path. [Fact] @@ -402,7 +428,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var content = "Hello\nBig\r\nWorld!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = document.Lines.GetLocation(0); @@ -418,7 +444,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var content = "Hello\nBig\r\nWorld!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = document.Lines.GetLocation(5); @@ -434,7 +460,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var content = "Hello\nBig\r\nWorld!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = document.Lines.GetLocation(7); @@ -450,7 +476,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var content = "Hello\nBig\r\nWorld!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = document.Lines.GetLocation(11); @@ -466,7 +492,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var content = "Hello\nBig\r\nWorld!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = document.Lines.GetLocation(16); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/FileSystemRazorProject/Home.cshtml b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/Home.cshtml similarity index 100% rename from test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/FileSystemRazorProject/Home.cshtml rename to test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/Home.cshtml diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/FileSystemRazorProject/Views/About/About.cshtml b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/Views/About/About.cshtml similarity index 100% rename from test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/FileSystemRazorProject/Views/About/About.cshtml rename to test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/Views/About/About.cshtml diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/FileSystemRazorProject/Views/Home/Index.cshtml b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/Views/Home/Index.cshtml similarity index 100% rename from test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/FileSystemRazorProject/Views/Home/Index.cshtml rename to test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/Views/Home/Index.cshtml diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/FileSystemRazorProject/Views/Home/Index.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/Views/Home/Index.txt similarity index 100% rename from test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/FileSystemRazorProject/Views/Home/Index.txt rename to test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/Views/Home/Index.txt diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/Views/Home/_ViewImports.cshtml b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/Views/Home/_ViewImports.cshtml new file mode 100644 index 0000000000..5f282702bb --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/Views/Home/_ViewImports.cshtml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/Views/_ViewImports.cshtml b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/Views/_ViewImports.cshtml new file mode 100644 index 0000000000..5f282702bb --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/Views/_ViewImports.cshtml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/_ViewImports.cshtml b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/_ViewImports.cshtml new file mode 100644 index 0000000000..5f282702bb --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/_ViewImports.cshtml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/BasicIntegrationTest/CustomDirective.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/BasicIntegrationTest/CustomDirective.ir.txt index 2e159a5cba..6142bc2eb1 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/BasicIntegrationTest/CustomDirective.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/BasicIntegrationTest/CustomDirective.ir.txt @@ -1,4 +1,6 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Razor + RazorSourceChecksumAttribute - ClassDeclaration - - public - Template - - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/BasicIntegrationTest/Empty.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/BasicIntegrationTest/Empty.ir.txt index 2e159a5cba..6142bc2eb1 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/BasicIntegrationTest/Empty.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/BasicIntegrationTest/Empty.ir.txt @@ -1,4 +1,6 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Razor + RazorSourceChecksumAttribute - ClassDeclaration - - public - Template - - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/BasicIntegrationTest/HelloWorld.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/BasicIntegrationTest/HelloWorld.ir.txt index 98b909d3f4..83409ed68c 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/BasicIntegrationTest/HelloWorld.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/BasicIntegrationTest/HelloWorld.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Razor + RazorSourceChecksumAttribute - ClassDeclaration - - public - Template - - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [13] HelloWorld.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_Runtime.codegen.cs index 4436f2c17b..32dba3fdc3 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "ea06819774d4f892a37cc84688446440dee29bd6" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_AttributeTargetingTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"ea06819774d4f892a37cc84688446440dee29bd6", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_AttributeTargetingTagHelpers_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("catchAll", new global::Microsoft.AspNetCore.Html.HtmlString("hi"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_Runtime.ir.txt index 25aafc533b..1fbf6fd6c7 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_AttributeTargetingTagHelpers_Runtime - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - catchAll - hi - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_1 - type - checkbox - HtmlAttributeValueStyle.DoubleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_Runtime.codegen.cs index d5996bfd6b..5b92f3a416 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "00b5e01b7a405dcfde7e4d512ee930daaa1778b5" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Await_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"00b5e01b7a405dcfde7e4d512ee930daaa1778b5", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Await_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_Runtime.ir.txt index 1f2ab0b7c2..1890add00a 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Await_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (91:6,0 [100] Await.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Runtime.codegen.cs index 171a43089d..bec15180ea 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Runtime.codegen.cs @@ -1,6 +1,7 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "d351c0c4dc0afdbf46547fcd87692951d2e4871f" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicImports_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden @@ -19,6 +20,9 @@ using System.Text; #line default #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"d351c0c4dc0afdbf46547fcd87692951d2e4871f", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports.cshtml")] + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"8aa538f3517d6d8922adaf817015cf8a61a57046", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Imports0.cshtml")] + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"ad27b5360a3a2ab427f824e417620a745c0f45de", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Imports1.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicImports_Runtime : Hello { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Runtime.ir.txt index a50f1190ac..014ca50451 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Runtime.ir.txt @@ -1,8 +1,12 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles UsingDirective - (1:0,1 [28] BasicImports_Imports0.cshtml) - System.Globalization UsingDirective - (30:1,1 [29] BasicImports_Imports0.cshtml) - System.ComponentModel UsingDirective - (23:1,1 [20] BasicImports_Imports1.cshtml) - System.Text + RazorSourceChecksumAttribute - + RazorSourceChecksumAttribute - + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicImports_Runtime - Hello - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [18] BasicImports.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_Runtime.codegen.cs index 979b35b5b0..5b647f3ed5 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "e05d346bc9435e651c4c8f34515c1b5f2cff294a" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_Prefixed_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"e05d346bc9435e651c4c8f34515c1b5f2cff294a", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_Prefixed_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "checkbox", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_Runtime.ir.txt index c9d169d3af..f78f3256b9 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_Prefixed_Runtime - - PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - type - checkbox - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - class - Hello World - HtmlAttributeValueStyle.DoubleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper_Runtime.codegen.cs index 001fa0894b..116a67d3f1 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "8479a280916bffac36ca773a941b3f9155fe4ace" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_RemoveTagHelper_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"8479a280916bffac36ca773a941b3f9155fe4ace", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_RemoveTagHelper_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "text", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper_Runtime.ir.txt index d6c82f8c3c..ef78c52e75 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_RemoveTagHelper_Runtime - - PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - type - text - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_1 - type - checkbox - HtmlAttributeValueStyle.DoubleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Runtime.codegen.cs index fd36bca122..716d143e8b 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "56c40717284b82fcb2ee9f60f09e8c6c0bda8959" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"56c40717284b82fcb2ee9f60f09e8c6c0bda8959", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("data", new global::Microsoft.AspNetCore.Html.HtmlString("-delay1000"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Runtime.ir.txt index a5acd5c506..ce7caef785 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_Runtime - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - data - -delay1000 - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_1 - type - text - HtmlAttributeValueStyle.DoubleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_Runtime.codegen.cs index 1dae6c06c2..f491305fbf 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "ba7d8f5f5159a2389c780aa606885ef6c917a45a" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Blocks_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"ba7d8f5f5159a2389c780aa606885ef6c917a45a", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Blocks_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_Runtime.ir.txt index ad45f51432..9fa7984a1d 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Blocks_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [18] Blocks.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_Runtime.codegen.cs index 3821c22d4d..4764d6208a 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "d287720a0df9d4595ed4f009c44479d9c7b0a800" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CSharp7_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"d287720a0df9d4595ed4f009c44479d9c7b0a800", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CSharp7_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_Runtime.ir.txt index e7d0eb4998..ff3f1b48ff 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CSharp7_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [8] CSharp7.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.diagnostics.txt index 9fb02062cb..c3072c6248 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF.cshtml(1,2): Error RZ9999: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF.cshtml(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.codegen.cs index 9cfca93cb8..546075b30f 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "5f82673b13daf5e28291f3bfb58df5e3a94e13cc" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlockAtEOF_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"5f82673b13daf5e28291f3bfb58df5e3a94e13cc", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlockAtEOF_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.diagnostics.txt index 9fb02062cb..c3072c6248 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF.cshtml(1,2): Error RZ9999: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF.cshtml(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.ir.txt index c905d540e8..daf2692204 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlockAtEOF_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [0] CodeBlockAtEOF.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_Runtime.codegen.cs index dba89ef37d..669b4af337 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "13e48ff59aab8106ceb68dd4a10b0bdf10c322fc" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlockWithTextElement_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"13e48ff59aab8106ceb68dd4a10b0bdf10c322fc", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlockWithTextElement_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_Runtime.ir.txt index 1dccf74278..0c163f3a41 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlockWithTextElement_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [17] CodeBlockWithTextElement.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_Runtime.codegen.cs index 328c5c3e99..20f8423105 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "019ce8023d064d08ca88c597b764aea895ec5841" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlock_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"019ce8023d064d08ca88c597b764aea895ec5841", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlock_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_Runtime.ir.txt index 962866d7d7..f700c27032 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlock_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [115] CodeBlock.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_Runtime.codegen.cs index f35abe18ef..49b9f25807 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "6c8cd00002dfc24a4fd1b1c3f079728b7697257f" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ComplexTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"6c8cd00002dfc24a4fd1b1c3f079728b7697257f", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ComplexTagHelpers_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "text", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_Runtime.ir.txt index ca0a9a40fe..92bc67f8c6 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ComplexTagHelpers_Runtime - - PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - type - text - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - value - - HtmlAttributeValueStyle.DoubleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_Runtime.codegen.cs index f990427ccb..d0a163333f 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "088be4e50958bcab0f1d1ac04d2c28dcd8049bf5" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ConditionalAttributes_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"088be4e50958bcab0f1d1ac04d2c28dcd8049bf5", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ConditionalAttributes_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_Runtime.ir.txt index 120563b3f3..3b1e6f21df 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ConditionalAttributes_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [44] ConditionalAttributes.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes_Runtime.codegen.cs index 9db2df6588..98e21a7edc 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "1ba28534da506a7c741c3d82251fd700658ff7c8" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CssSelectorTagHelperAttributes_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"1ba28534da506a7c741c3d82251fd700658ff7c8", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CssSelectorTagHelperAttributes_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("href", new global::Microsoft.AspNetCore.Html.HtmlString("~/"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes_Runtime.ir.txt index 7f6deff99d..ef34c24d71 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CssSelectorTagHelperAttributes_Runtime - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - href - ~/ - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - href - ~/hello - HtmlAttributeValueStyle.DoubleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_Runtime.codegen.cs index 1253a67096..88d12d14f5 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "f64041250fa76433a1542ae43458ed7ba286a01c" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DuplicateAttributeTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"f64041250fa76433a1542ae43458ed7ba286a01c", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DuplicateAttributeTagHelpers_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "button", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_Runtime.ir.txt index 5280049d8c..f2e84ead91 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DuplicateAttributeTagHelpers_Runtime - - PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - type - button - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - TYPE - checkbox - HtmlAttributeValueStyle.DoubleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_Runtime.codegen.cs index 7fdf724432..4e0cb04880 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "cce7d92553451468e4599af8a8329633dbad75a3" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DuplicateTargetTagHelper_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"cce7d92553451468e4599af8a8329633dbad75a3", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DuplicateTargetTagHelper_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "checkbox", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_Runtime.ir.txt index 276a121283..d86a4d2b8c 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DuplicateTargetTagHelper_Runtime - - PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - type - checkbox - HtmlAttributeValueStyle.DoubleQuotes DefaultTagHelperRuntime - diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_Runtime.codegen.cs index 1a008757c0..ad9774545c 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "e044ca9442dd9f93d8ce7f93a79c46a542221f1e" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DynamicAttributeTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"e044ca9442dd9f93d8ce7f93a79c46a542221f1e", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DynamicAttributeTagHelpers_Runtime { #line hidden diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_Runtime.ir.txt index 7695ef4f6c..72a0832670 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DynamicAttributeTagHelpers_Runtime - - DefaultTagHelperRuntime - FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_DesignTime.diagnostics.txt index f4d4633005..0b20997aff 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_DesignTime.diagnostics.txt @@ -1,3 +1,3 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml(4,18): Error RZ9999: Attribute 'checked' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml(5,8): Error RZ9999: Attribute 'age' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml(6,23): Error RZ9999: Attribute 'checked' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml(4,18): Error RZ2008: Attribute 'checked' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml(5,8): Error RZ2008: Attribute 'age' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml(6,23): Error RZ2008: Attribute 'checked' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.codegen.cs index d62ca0372c..bdcfeab925 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "ebd7c5a5d3edbcd879a6437ec728fafa9c84d312" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyAttributeTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"ebd7c5a5d3edbcd879a6437ec728fafa9c84d312", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyAttributeTagHelpers_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.diagnostics.txt index f4d4633005..0b20997aff 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.diagnostics.txt @@ -1,3 +1,3 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml(4,18): Error RZ9999: Attribute 'checked' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml(5,8): Error RZ9999: Attribute 'age' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml(6,23): Error RZ9999: Attribute 'checked' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml(4,18): Error RZ2008: Attribute 'checked' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml(5,8): Error RZ2008: Attribute 'age' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml(6,23): Error RZ2008: Attribute 'checked' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.ir.txt index cc0af5d4a2..f8c39dee99 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyAttributeTagHelpers_Runtime - - PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - type - - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - class - - HtmlAttributeValueStyle.DoubleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_Runtime.codegen.cs index bc4425b55b..4d127cd32d 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "a81f9de6dc302ab6600f3808428e5247ed389511" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyCodeBlock_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"a81f9de6dc302ab6600f3808428e5247ed389511", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyCodeBlock_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_Runtime.ir.txt index 8c313f73c7..75e7307e0f 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyCodeBlock_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [18] EmptyCodeBlock.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_Runtime.codegen.cs index 6ff66e6a8c..45b4ed17d0 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "e6467906896d16277c5a0cf962ac6d863c58852f" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyExplicitExpression_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"e6467906896d16277c5a0cf962ac6d863c58852f", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyExplicitExpression_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_Runtime.ir.txt index 23c889ee0f..c3daa8feb5 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyExplicitExpression_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [18] EmptyExplicitExpression.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.diagnostics.txt index c0a89d2ef4..84ac278f6d 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml(2,6): Error RZ9999: A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{" are valid at the start of a code block and they must occur immediately following "@" with no space in between. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml(2,6): Error RZ1003: A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{" are valid at the start of a code block and they must occur immediately following "@" with no space in between. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.codegen.cs index 993c4303fb..6a7443dbc7 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "b21853e37dde51b305bde9602624934d4d6affd3" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyImplicitExpressionInCode_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"b21853e37dde51b305bde9602624934d4d6affd3", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyImplicitExpressionInCode_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.diagnostics.txt index c0a89d2ef4..84ac278f6d 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml(2,6): Error RZ9999: A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{" are valid at the start of a code block and they must occur immediately following "@" with no space in between. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml(2,6): Error RZ1003: A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{" are valid at the start of a code block and they must occur immediately following "@" with no space in between. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.ir.txt index 952bf2bcb0..b910f3841c 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyImplicitExpressionInCode_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [6] EmptyImplicitExpressionInCode.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.diagnostics.txt index 862260264e..5524460d0c 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml(3,2): Error RZ9999: "!" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml(3,2): Error RZ1005: "!" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.codegen.cs index 46eeadae27..599ecb7a1e 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "8ed47ba5d7cac644fdbb2c4f816d49bdeed1ac45" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyImplicitExpression_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"8ed47ba5d7cac644fdbb2c4f816d49bdeed1ac45", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyImplicitExpression_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.diagnostics.txt index 862260264e..5524460d0c 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml(3,2): Error RZ9999: "!" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml(3,2): Error RZ1005: "!" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.ir.txt index e404569687..e4187049bb 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyImplicitExpression_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [18] EmptyImplicitExpression.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_Runtime.codegen.cs index e665652ed6..58378b6745 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "c55ebb3869f93768c36d432f769272b9f8feeb0b" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EnumTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"c55ebb3869f93768c36d432f769272b9f8feeb0b", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EnumTagHelpers_Runtime { #line hidden diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_Runtime.ir.txt index d7dced8096..e38db1bbaa 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EnumTagHelpers_Runtime - - DefaultTagHelperRuntime - FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_Runtime.codegen.cs index 349f6fdcbe..a35cbde3b6 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "e082322a2f2c103fcc2779608d1ef7fe4b915d75" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EscapedTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"e082322a2f2c103fcc2779608d1ef7fe4b915d75", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EscapedTagHelpers_Runtime { #line hidden diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_Runtime.ir.txt index 272ff7b035..18242c571b 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EscapedTagHelpers_Runtime - - DefaultTagHelperRuntime - FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.diagnostics.txt index 2050eeea35..4e0bfb131d 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml(3,2): Error RZ9999: The explicit expression block is missing a closing ")" character. Make sure you have a matching ")" character for all the "(" characters within this block, and that none of the ")" characters are being interpreted as markup. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml(3,2): Error RZ1006: The explicit expression block is missing a closing ")" character. Make sure you have a matching ")" character for all the "(" characters within this block, and that none of the ")" characters are being interpreted as markup. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.codegen.cs index 636c407d05..584fb48088 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "bf53afff8ab65f1af9b9a82f9a571f1cd023dfc0" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpressionAtEOF_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"bf53afff8ab65f1af9b9a82f9a571f1cd023dfc0", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpressionAtEOF_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.diagnostics.txt index 2050eeea35..4e0bfb131d 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml(3,2): Error RZ9999: The explicit expression block is missing a closing ")" character. Make sure you have a matching ")" character for all the "(" characters within this block, and that none of the ")" characters are being interpreted as markup. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml(3,2): Error RZ1006: The explicit expression block is missing a closing ")" character. Make sure you have a matching ")" character for all the "(" characters within this block, and that none of the ")" characters are being interpreted as markup. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.ir.txt index a435fb6858..5f459014c8 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpressionAtEOF_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [18] ExplicitExpressionAtEOF.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.diagnostics.txt index ee9b4f9d6f..16ad2a09d5 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.diagnostics.txt @@ -1,2 +1,2 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,11): Error RZ9999: Encountered end tag "div" with no matching start tag. Are your start/end tags properly balanced? -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,7): Error RZ9999: The explicit expression block is missing a closing ")" character. Make sure you have a matching ")" character for all the "(" characters within this block, and that none of the ")" characters are being interpreted as markup. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,11): Error RZ1026: Encountered end tag "div" with no matching start tag. Are your start/end tags properly balanced? +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,7): Error RZ1006: The explicit expression block is missing a closing ")" character. Make sure you have a matching ")" character for all the "(" characters within this block, and that none of the ")" characters are being interpreted as markup. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.codegen.cs index 110345b36b..af26048758 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "1252c799cdeb86a71e4304f01ebaae540fa26894" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpressionWithMarkup_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"1252c799cdeb86a71e4304f01ebaae540fa26894", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpressionWithMarkup_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.diagnostics.txt index ee9b4f9d6f..16ad2a09d5 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.diagnostics.txt @@ -1,2 +1,2 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,11): Error RZ9999: Encountered end tag "div" with no matching start tag. Are your start/end tags properly balanced? -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,7): Error RZ9999: The explicit expression block is missing a closing ")" character. Make sure you have a matching ")" character for all the "(" characters within this block, and that none of the ")" characters are being interpreted as markup. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,11): Error RZ1026: Encountered end tag "div" with no matching start tag. Are your start/end tags properly balanced? +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,7): Error RZ1006: The explicit expression block is missing a closing ")" character. Make sure you have a matching ")" character for all the "(" characters within this block, and that none of the ")" characters are being interpreted as markup. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.ir.txt index b112ccd9bd..dde86a08b2 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpressionWithMarkup_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [5] ExplicitExpressionWithMarkup.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_Runtime.codegen.cs index 09073c2d96..ed1147c800 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "a897a227b26c531d644bdff988df46d3c8178346" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpression_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"a897a227b26c531d644bdff988df46d3c8178346", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpression_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_Runtime.ir.txt index 1d4d7afbba..c1867efbb6 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpression_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [8] ExplicitExpression.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_Runtime.codegen.cs index b603e0f752..7668b46128 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "8c7ae67489dbddec9f2dbef3c2b65def1149e507" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExpressionsInCode_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"8c7ae67489dbddec9f2dbef3c2b65def1149e507", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExpressionsInCode_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_Runtime.ir.txt index aa1cb230d8..d87e4b1d61 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExpressionsInCode_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [51] ExpressionsInCode.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_Runtime.codegen.cs index afbbbb4419..1a9e0dd74c 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "366e1cb1c026413435ec398a7d47c8c1acc373d8" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_FunctionsBlockMinimal_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"366e1cb1c026413435ec398a7d47c8c1acc373d8", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_FunctionsBlockMinimal_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_Runtime.ir.txt index be99b1fcf0..2d4242e8c4 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_FunctionsBlockMinimal_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [4] FunctionsBlockMinimal.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_Runtime.codegen.cs index cbfb302cb7..1ad1a373f5 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "94813053694a285515d791c48d703f1131881d0c" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_FunctionsBlock_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"94813053694a285515d791c48d703f1131881d0c", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_FunctionsBlock_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_Runtime.ir.txt index 5e1a08efbf..4b05dbcc3d 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_FunctionsBlock_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (19:3,0 [2] FunctionsBlock.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_Runtime.codegen.cs index bb860eeb2c..21bbadd378 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "5bd51d8947ca920e594be8d214b4ebee2888c90c" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HiddenSpansInCode_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"5bd51d8947ca920e594be8d214b4ebee2888c90c", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HiddenSpansInCode_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_Runtime.ir.txt index 7b24771c9f..92fc13fef7 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HiddenSpansInCode_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [6] HiddenSpansInCode.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_Runtime.codegen.cs index 3fd49516ac..7bd80ff77f 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "a07711bc1fd0478b3b8329a68ab2028ef93429df" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HtmlCommentWithQuote_Double_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"a07711bc1fd0478b3b8329a68ab2028ef93429df", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HtmlCommentWithQuote_Double_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_Runtime.ir.txt index 2514947c95..343985c189 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HtmlCommentWithQuote_Double_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [45] HtmlCommentWithQuote_Double.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_Runtime.codegen.cs index 6fe7a287ab..9c3354b3c1 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "2d9bb4407e7aac9563aaeac9f0534a48f54e3d44" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HtmlCommentWithQuote_Single_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"2d9bb4407e7aac9563aaeac9f0534a48f54e3d44", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HtmlCommentWithQuote_Single_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_Runtime.ir.txt index c63e151ad0..65aafb6fe7 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HtmlCommentWithQuote_Single_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [45] HtmlCommentWithQuote_Single.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.diagnostics.txt index 1fd198f0e7..e2a8c29095 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml(3,2): Error RZ9999: End-of-file was found after the "@" character. "@" must be followed by a valid code block. If you want to output an "@", escape it using the sequence: "@@" +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml(3,2): Error RZ1004: End-of-file was found after the "@" character. "@" must be followed by a valid code block. If you want to output an "@", escape it using the sequence: "@@" diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.codegen.cs index 98187d4e98..12759ba9cc 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "ecf286733e30e006a630f3a5fe87c21f45e4c807" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ImplicitExpressionAtEOF_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"ecf286733e30e006a630f3a5fe87c21f45e4c807", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ImplicitExpressionAtEOF_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.diagnostics.txt index 1fd198f0e7..e2a8c29095 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml(3,2): Error RZ9999: End-of-file was found after the "@" character. "@" must be followed by a valid code block. If you want to output an "@", escape it using the sequence: "@@" +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml(3,2): Error RZ1004: End-of-file was found after the "@" character. "@" must be followed by a valid code block. If you want to output an "@", escape it using the sequence: "@@" diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.ir.txt index acad1cd788..b2ac3e3520 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ImplicitExpressionAtEOF_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [18] ImplicitExpressionAtEOF.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_Runtime.codegen.cs index 0fd158c731..e202aca56f 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "77befd9645f3c2d9ab48b935faebf9f731f42abc" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ImplicitExpression_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"77befd9645f3c2d9ab48b935faebf9f731f42abc", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ImplicitExpression_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_Runtime.ir.txt index 8d54e46136..c3d0aaab02 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ImplicitExpression_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (1:0,1 [32] ImplicitExpression.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt index b9c22ace19..b01ced2ed2 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt @@ -1,27 +1,27 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,2): Error RZ9999: Directive 'addTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,14): Error RZ9999: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,2): Error RZ9999: Directive 'addTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,15): Error RZ9999: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,15): Error RZ9999: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,15): Error RZ9999: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,2): Error RZ9999: Directive 'removeTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,17): Error RZ9999: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,2): Error RZ9999: Directive 'removeTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,18): Error RZ9999: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(9,18): Error RZ9999: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(9,18): Error RZ9999: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(11,2): Error RZ9999: Directive 'tagHelperPrefix' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,2): Error RZ9999: Directive 'tagHelperPrefix' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,2): Error RZ1018: Directive 'addTagHelper' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,14): Error RZ1020: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,2): Error RZ1018: Directive 'addTagHelper' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,15): Error RZ1020: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,15): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,15): Error RZ1020: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,2): Error RZ1018: Directive 'removeTagHelper' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,17): Error RZ1020: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,2): Error RZ1018: Directive 'removeTagHelper' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,18): Error RZ1020: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(9,18): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(9,18): Error RZ1020: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(11,2): Error RZ1018: Directive 'tagHelperPrefix' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,2): Error RZ1018: Directive 'tagHelperPrefix' must have a value. TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,1): Error RZ2001: The 'tagHelperPrefix' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(13,18): Error RZ9999: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(13,18): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(13,1): Error RZ2001: The 'tagHelperPrefix' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(13,18): Error RZ9999: Invalid tag helper directive 'tagHelperPrefix' value. '"' is not allowed in prefix '"'. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,10): Error RZ9999: The 'inherits' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(16,1): Error RZ9999: The 'inherits' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(16,11): Error RZ9999: The 'inherits' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(19,1): Error RZ9999: Unexpected literal following the 'functions' directive. Expected '{'. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(21,1): Error RZ9999: Unexpected literal following the 'functions' directive. Expected '{'. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(21,9): Error RZ9999: The 'section' directive expects an identifier. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(22,10): Error RZ9999: The 'section' directive expects an identifier. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(24,10): Error RZ9999: The 'section' directive expects an identifier. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(25,12): Error RZ9999: The functions block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(13,18): Error RZ1020: Invalid tag helper directive 'tagHelperPrefix' value. '"' is not allowed in prefix '"'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,10): Error RZ1013: The 'inherits' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(16,1): Error RZ2001: The 'inherits' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(16,11): Error RZ1013: The 'inherits' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(19,1): Error RZ1017: Unexpected literal following the 'functions' directive. Expected '{'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(21,1): Error RZ1017: Unexpected literal following the 'functions' directive. Expected '{'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(21,9): Error RZ1015: The 'section' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(22,10): Error RZ1015: The 'section' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(24,10): Error RZ1015: The 'section' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(25,12): Error RZ1006: The functions block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs index 2aca243fd5..317dfab9e5 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "df5d66431db818236f9c26c6dd920838c22ddb82" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"df5d66431db818236f9c26c6dd920838c22ddb82", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt index b9c22ace19..b01ced2ed2 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt @@ -1,27 +1,27 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,2): Error RZ9999: Directive 'addTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,14): Error RZ9999: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,2): Error RZ9999: Directive 'addTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,15): Error RZ9999: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,15): Error RZ9999: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,15): Error RZ9999: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,2): Error RZ9999: Directive 'removeTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,17): Error RZ9999: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,2): Error RZ9999: Directive 'removeTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,18): Error RZ9999: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(9,18): Error RZ9999: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(9,18): Error RZ9999: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(11,2): Error RZ9999: Directive 'tagHelperPrefix' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,2): Error RZ9999: Directive 'tagHelperPrefix' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,2): Error RZ1018: Directive 'addTagHelper' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,14): Error RZ1020: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,2): Error RZ1018: Directive 'addTagHelper' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,15): Error RZ1020: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,15): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,15): Error RZ1020: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,2): Error RZ1018: Directive 'removeTagHelper' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,17): Error RZ1020: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,2): Error RZ1018: Directive 'removeTagHelper' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,18): Error RZ1020: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(9,18): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(9,18): Error RZ1020: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(11,2): Error RZ1018: Directive 'tagHelperPrefix' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,2): Error RZ1018: Directive 'tagHelperPrefix' must have a value. TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,1): Error RZ2001: The 'tagHelperPrefix' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(13,18): Error RZ9999: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(13,18): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(13,1): Error RZ2001: The 'tagHelperPrefix' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(13,18): Error RZ9999: Invalid tag helper directive 'tagHelperPrefix' value. '"' is not allowed in prefix '"'. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,10): Error RZ9999: The 'inherits' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(16,1): Error RZ9999: The 'inherits' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(16,11): Error RZ9999: The 'inherits' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(19,1): Error RZ9999: Unexpected literal following the 'functions' directive. Expected '{'. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(21,1): Error RZ9999: Unexpected literal following the 'functions' directive. Expected '{'. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(21,9): Error RZ9999: The 'section' directive expects an identifier. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(22,10): Error RZ9999: The 'section' directive expects an identifier. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(24,10): Error RZ9999: The 'section' directive expects an identifier. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(25,12): Error RZ9999: The functions block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(13,18): Error RZ1020: Invalid tag helper directive 'tagHelperPrefix' value. '"' is not allowed in prefix '"'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,10): Error RZ1013: The 'inherits' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(16,1): Error RZ2001: The 'inherits' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(16,11): Error RZ1013: The 'inherits' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(19,1): Error RZ1017: Unexpected literal following the 'functions' directive. Expected '{'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(21,1): Error RZ1017: Unexpected literal following the 'functions' directive. Expected '{'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(21,9): Error RZ1015: The 'section' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(22,10): Error RZ1015: The 'section' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(24,10): Error RZ1015: The 'section' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(25,12): Error RZ1006: The functions block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt index aad13cff1a..ecffead8c5 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (83:0,83 [4] IncompleteDirectives.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_DesignTime.diagnostics.txt index 96431ecdd6..10a2d590e2 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_DesignTime.diagnostics.txt @@ -1,2 +1,2 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper.cshtml(3,2): Error RZ9999: Missing close angle for tag helper 'p'. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper.cshtml(3,2): Error RZ9999: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper.cshtml(3,2): Error RZ1035: Missing close angle for tag helper 'p'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper.cshtml(3,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_Runtime.codegen.cs index 9ff13d0996..a83e98b757 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "2b8b22f00f74af242e046b0dd3ab40dc54d6bfd8" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteTagHelper_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"2b8b22f00f74af242e046b0dd3ab40dc54d6bfd8", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteTagHelper_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString(""), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_Runtime.diagnostics.txt index 96431ecdd6..10a2d590e2 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_Runtime.diagnostics.txt @@ -1,2 +1,2 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper.cshtml(3,2): Error RZ9999: Missing close angle for tag helper 'p'. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper.cshtml(3,2): Error RZ9999: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper.cshtml(3,2): Error RZ1035: Missing close angle for tag helper 'p'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper.cshtml(3,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_Runtime.ir.txt index b90f2c3d58..dfc5fa13b1 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteTagHelper_Runtime - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - class - - HtmlAttributeValueStyle.DoubleQuotes DefaultTagHelperRuntime - diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inherits_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inherits_Runtime.codegen.cs index b148ac5fc5..1598a627ce 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inherits_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inherits_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inherits.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "d5c565b0bb468550fca15010c0addc84e79c5297" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inherits_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inherits.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"d5c565b0bb468550fca15010c0addc84e79c5297", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inherits.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inherits_Runtime : foo.bar>.boz { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inherits_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inherits_Runtime.ir.txt index 37b754242a..e901fffac8 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inherits_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inherits_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inherits_Runtime - foo.bar>.boz - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (33:1,0 [2] Inherits.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_DesignTime.diagnostics.txt index 78599522c6..66af9b7600 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks.cshtml(1,14): Error RZ9999: Unexpected literal following the 'section' directive. Expected '{'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks.cshtml(1,14): Error RZ1017: Unexpected literal following the 'section' directive. Expected '{'. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_Runtime.codegen.cs index c2a28a3ec1..379ffda090 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "e827e93343a95c7254a19287b095dfba9390d29f" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InlineBlocks_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"e827e93343a95c7254a19287b095dfba9390d29f", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InlineBlocks_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_Runtime.diagnostics.txt index 78599522c6..66af9b7600 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_Runtime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks.cshtml(1,14): Error RZ9999: Unexpected literal following the 'section' directive. Expected '{'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks.cshtml(1,14): Error RZ1017: Unexpected literal following the 'section' directive. Expected '{'. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_Runtime.ir.txt index 30f475ca18..eb8fd5d9f6 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InlineBlocks_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync MalformedDirective - (0:0,0 [13] InlineBlocks.cshtml) - section diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_Runtime.codegen.cs index 3b11d9997a..29d4fd3dcc 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "9b521264e3e64710635c0f0490a368845d90da66" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Instrumented_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"9b521264e3e64710635c0f0490a368845d90da66", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Instrumented_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_Runtime.ir.txt index 5259662cfa..2fb8fdbe9b 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Instrumented_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [32] Instrumented.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_Runtime.codegen.cs index a93678cbb6..834f466573 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "cf059b36d7e93e260c1d5b852f7a59e6c99ae33d" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MarkupInCodeBlock_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"cf059b36d7e93e260c1d5b852f7a59e6c99ae33d", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MarkupInCodeBlock_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_Runtime.ir.txt index 9f46cfe6c7..a543cca51d 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MarkupInCodeBlock_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [38] MarkupInCodeBlock.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_Runtime.codegen.cs index ce9b852bf4..ee273d41e8 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "ab8c9a5af38d07138a55ae82942b4a97fe3c9025" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MinimizedTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"ab8c9a5af38d07138a55ae82942b4a97fe3c9025", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MinimizedTagHelpers_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("btn"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_Runtime.ir.txt index e27c841eb8..20205a9756 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MinimizedTagHelpers_Runtime - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - class - btn - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_1 - input-bound-required-string - hello - HtmlAttributeValueStyle.DoubleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_Runtime.codegen.cs index c6a8e7f124..06a3a3c037 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "2b9e8dcf7c08153c15ac84973938a7c0254f2369" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedCSharp_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"2b9e8dcf7c08153c15ac84973938a7c0254f2369", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedCSharp_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_Runtime.ir.txt index b814b88e6f..1c240ea1bd 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedCSharp_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [6] NestedCSharp.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_Runtime.codegen.cs index c6862dcdc9..64f2c350ee 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "a4eb7397719094ea9da5b7d6674d317314fa26b4" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedCodeBlocks_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"a4eb7397719094ea9da5b7d6674d317314fa26b4", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedCodeBlocks_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_Runtime.ir.txt index 354dcf1292..2c0030ec65 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedCodeBlocks_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (1:0,1 [15] NestedCodeBlocks.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_Runtime.codegen.cs index 31f4c1d8d3..f5a9f556c1 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "880f98e8cc874c7736b089ea69af2461a11eacb2" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedScriptTagTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"880f98e8cc874c7736b089ea69af2461a11eacb2", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedScriptTagTagHelpers_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "text", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_Runtime.ir.txt index 8202635abb..7041d3c6fc 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedScriptTagTagHelpers_Runtime - - PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - type - text - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - class - Hello World - HtmlAttributeValueStyle.DoubleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_Runtime.codegen.cs index 273ceb63fa..4d6202ca35 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "fc99ab53936074d66d80552f780e58d4edb223d6" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"fc99ab53936074d66d80552f780e58d4edb223d6", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedTagHelpers_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("value", "Hello", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_Runtime.ir.txt index c4d6a65257..f4c6001b80 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedTagHelpers_Runtime - - PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - value - Hello - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - type - text - HtmlAttributeValueStyle.SingleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_Runtime.codegen.cs index 78a2256f26..9ba267ed22 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "682929a2038f56f4737f1b7aa3c9eaa5488cc001" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NoLinePragmas_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"682929a2038f56f4737f1b7aa3c9eaa5488cc001", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NoLinePragmas_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_Runtime.ir.txt index 7c45b1a26c..133177b5c4 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NoLinePragmas_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [18] NoLinePragmas.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_Runtime.codegen.cs index 270cc5abfb..03296645f6 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "c8c4f34e0768aea12ef6ce8e3fe0e384ad023faf" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NullConditionalExpressions_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"c8c4f34e0768aea12ef6ce8e3fe0e384ad023faf", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NullConditionalExpressions_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_Runtime.ir.txt index 0cc5a8ac6e..8fd7d3dc26 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NullConditionalExpressions_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [6] NullConditionalExpressions.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.diagnostics.txt index 3d3db9befd..49f293ec33 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.diagnostics.txt @@ -1,3 +1,3 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(4,3): Error RZ9999: Encountered end tag "body" with no matching start tag. Are your start/end tags properly balanced? -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(5,3): Error RZ9999: Encountered end tag "html" with no matching start tag. Are your start/end tags properly balanced? -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(3,2): Error RZ9999: The if block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(4,3): Error RZ1026: Encountered end tag "body" with no matching start tag. Are your start/end tags properly balanced? +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(5,3): Error RZ1026: Encountered end tag "html" with no matching start tag. Are your start/end tags properly balanced? +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(3,2): Error RZ1006: The if block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.codegen.cs index 3c5f300875..d121325445 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "608d7aa10b6df6798d8259379837fa7ffb088ed6" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_OpenedIf_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"608d7aa10b6df6798d8259379837fa7ffb088ed6", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_OpenedIf_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.diagnostics.txt index 3d3db9befd..49f293ec33 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.diagnostics.txt @@ -1,3 +1,3 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(4,3): Error RZ9999: Encountered end tag "body" with no matching start tag. Are your start/end tags properly balanced? -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(5,3): Error RZ9999: Encountered end tag "html" with no matching start tag. Are your start/end tags properly balanced? -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(3,2): Error RZ9999: The if block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(4,3): Error RZ1026: Encountered end tag "body" with no matching start tag. Are your start/end tags properly balanced? +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(5,3): Error RZ1026: Encountered end tag "html" with no matching start tag. Are your start/end tags properly balanced? +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(3,2): Error RZ1006: The if block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.ir.txt index 47bbd0deea..24ee8b0ec7 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_OpenedIf_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [16] OpenedIf.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.diagnostics.txt index 2d6f4fb000..1a25d90e26 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.diagnostics.txt @@ -1,2 +1,2 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml(2,1): Error RZ9999: End of file was reached before the end of the block comment. All comments started with "/*" sequence must be terminated with a matching "*/" sequence. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml(1,2): Error RZ9999: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml(2,1): Error RZ1001: End of file was reached before the end of the block comment. All comments started with "/*" sequence must be terminated with a matching "*/" sequence. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.codegen.cs index c7d7962e05..55f7c0863f 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "99e6be6b384d3f247935d3cb15564542b7a82e43" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ParserError_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"99e6be6b384d3f247935d3cb15564542b7a82e43", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ParserError_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.diagnostics.txt index 2d6f4fb000..1a25d90e26 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.diagnostics.txt @@ -1,2 +1,2 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml(2,1): Error RZ9999: End of file was reached before the end of the block comment. All comments started with "/*" sequence must be terminated with a matching "*/" sequence. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml(1,2): Error RZ9999: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml(2,1): Error RZ1001: End of file was reached before the end of the block comment. All comments started with "/*" sequence must be terminated with a matching "*/" sequence. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.ir.txt index 219de0c125..8f60e461b4 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ParserError_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [31] ParserError.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_Runtime.codegen.cs index 9b37c7dd64..b8304fbc65 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "6e6edd0cad896f8dbf05be369b813477046ccd40" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PrefixedAttributeTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"6e6edd0cad896f8dbf05be369b813477046ccd40", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PrefixedAttributeTagHelpers_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", new global::Microsoft.AspNetCore.Html.HtmlString("checkbox"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_Runtime.ir.txt index b6df7d0360..892245a292 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PrefixedAttributeTagHelpers_Runtime - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - type - checkbox - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - type - password - HtmlAttributeValueStyle.DoubleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_Runtime.codegen.cs index 6a28ece18f..beef9c9cf4 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "45c16f152aef80d7de27c7df32dc522af5842197" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorComments_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"45c16f152aef80d7de27c7df32dc522af5842197", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorComments_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_Runtime.ir.txt index 74944e4a55..e05218677f 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorComments_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (36:0,36 [17] RazorComments.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs index 128b60701f..d5276e436e 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "ec9a74381c339244a887565526c11056ece494a3" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"ec9a74381c339244a887565526c11056ece494a3", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.ir.txt index bfe56628c3..be452577fe 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [44] Sections.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_Runtime.codegen.cs index dc69621e9e..afb4239f5b 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "248dc9c0c1ef35d3636cfb2fa7f5ac0f8a0b553a" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SimpleTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"248dc9c0c1ef35d3636cfb2fa7f5ac0f8a0b553a", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SimpleTagHelpers_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("value", "Hello", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.SingleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_Runtime.ir.txt index bd8c027f6d..818e754db8 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SimpleTagHelpers_Runtime - - PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - value - Hello - HtmlAttributeValueStyle.SingleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - type - text - HtmlAttributeValueStyle.SingleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_Runtime.codegen.cs index c9637b930c..3f3c71b734 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "8501407d5716c727ebc0ba157b04442cd2c302ff" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SimpleUnspacedIf_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"8501407d5716c727ebc0ba157b04442cd2c302ff", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SimpleUnspacedIf_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_Runtime.ir.txt index e985b716c0..d12d18e89b 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SimpleUnspacedIf_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (1:0,1 [14] SimpleUnspacedIf.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_Runtime.codegen.cs index f0a295667d..a9a6b7dcf6 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "1fcd2e2ee0b7146c8c0ec8a1721b4ffdc71e9f1e" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleTagHelperWithNewlineBeforeAttributes_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"1fcd2e2ee0b7146c8c0ec8a1721b4ffdc71e9f1e", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleTagHelperWithNewlineBeforeAttributes_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("Hello World"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_Runtime.ir.txt index fd4b3da51b..fb67e469d9 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleTagHelperWithNewlineBeforeAttributes_Runtime - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - class - Hello World - HtmlAttributeValueStyle.DoubleQuotes DefaultTagHelperRuntime - diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_Runtime.codegen.cs index 2f35981c40..3c867bb000 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "a46ef1b45affd451aae23202a87f93feb5c454f4" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleTagHelper_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"a46ef1b45affd451aae23202a87f93feb5c454f4", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleTagHelper_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("Hello World"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_Runtime.ir.txt index 669a0da2c8..89ef050a2c 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleTagHelper_Runtime - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - class - Hello World - HtmlAttributeValueStyle.DoubleQuotes DefaultTagHelperRuntime - diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_Runtime.codegen.cs index ba174de703..2f31e6d4bc 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "3c21118a6113e76e4f71d17e3ae081f13d451427" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_StringLiterals_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"3c21118a6113e76e4f71d17e3ae081f13d451427", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_StringLiterals_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_Runtime.ir.txt index ff5b980f15..33d3408bbe 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_StringLiterals_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [2013] StringLiterals.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_Runtime.codegen.cs index b58999afa1..544de2e533 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "10f840b503550891681c6569925ce1a183d07e75" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SymbolBoundAttributes_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"10f840b503550891681c6569925ce1a183d07e75", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SymbolBoundAttributes_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("[item]", new global::Microsoft.AspNetCore.Html.HtmlString("items"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_Runtime.ir.txt index eb9578becc..ee4dc7af83 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SymbolBoundAttributes_Runtime - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - [item] - items - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - [(item)] - items - HtmlAttributeValueStyle.DoubleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_Runtime.codegen.cs index 1d3fbf2f83..c616234186 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "97d0dc6305d8a47fd3d81a127119f47417862f1a" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersInSection_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"97d0dc6305d8a47fd3d81a127119f47417862f1a", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersInSection_Runtime { #line hidden diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_Runtime.ir.txt index ce67807512..0b89183f3e 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersInSection_Runtime - - DefaultTagHelperRuntime - FieldDeclaration - - private - global::TestNamespace.MyTagHelper - __TestNamespace_MyTagHelper diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_Runtime.codegen.cs index aea09e502d..3f948f363e 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "f7ed8b06f7ede1d7928dc05f2b2f081a3fda13aa" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithBoundAttributes_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"f7ed8b06f7ede1d7928dc05f2b2f081a3fda13aa", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithBoundAttributes_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", new global::Microsoft.AspNetCore.Html.HtmlString("text"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.SingleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_Runtime.ir.txt index 3080abaccb..c3d5ddf52e 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithBoundAttributes_Runtime - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - type - text - HtmlAttributeValueStyle.SingleQuotes DefaultTagHelperRuntime - diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_Runtime.codegen.cs index 9da2d505d3..9cd583768b 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "984b7fd00fa0286dd56ceda786fa7cf893520df6" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithPrefix_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"984b7fd00fa0286dd56ceda786fa7cf893520df6", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithPrefix_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", new global::Microsoft.AspNetCore.Html.HtmlString("text"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.SingleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_Runtime.ir.txt index be6d6f5006..6d6437abfc 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithPrefix_Runtime - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - type - text - HtmlAttributeValueStyle.SingleQuotes DefaultTagHelperRuntime - diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_Runtime.codegen.cs index f19b98782a..e32ab23204 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "f1ffadb1ad9c279ac40218b45a1688ac2f3ea857" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithTemplate_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"f1ffadb1ad9c279ac40218b45a1688ac2f3ea857", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithTemplate_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", new global::Microsoft.AspNetCore.Html.HtmlString("checkbox"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_Runtime.ir.txt index 9f0f34cf62..d53344f511 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithTemplate_Runtime - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - type - checkbox - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - checked - true - HtmlAttributeValueStyle.DoubleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_Runtime.codegen.cs index 7688fb821a..a992eb99bd 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "d02c1a0d63df91a5ffded6b9a62cfda3584cbd5f" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithWeirdlySpacedAttributes_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"d02c1a0d63df91a5ffded6b9a62cfda3584cbd5f", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithWeirdlySpacedAttributes_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("Hello World"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_Runtime.ir.txt index 8bdd5747a6..e6920b3067 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithWeirdlySpacedAttributes_Runtime - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - class - Hello World - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_1 - type - text - HtmlAttributeValueStyle.SingleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_Runtime.codegen.cs index 6f8c421068..b807c1364e 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "8a16b856f52a2ed469347984184b8ac48080234f" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Templates_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"8a16b856f52a2ed469347984184b8ac48080234f", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Templates_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_Runtime.ir.txt index 23fafbfe40..4416a51d48 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Templates_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (280:9,0 [2] Templates.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_DesignTime.diagnostics.txt index e966770db2..cc0379e358 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes.cshtml(7,12): Error RZ9999: "class" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes.cshtml(7,12): Error RZ1007: "class" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_Runtime.codegen.cs index 725a855e7f..190b9da31f 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "f3bafd9eaf3c9718228a830b5c71dc8536f1f7f2" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TransitionsInTagHelperAttributes_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"f3bafd9eaf3c9718228a830b5c71dc8536f1f7f2", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TransitionsInTagHelperAttributes_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("test"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_Runtime.diagnostics.txt index e966770db2..cc0379e358 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_Runtime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes.cshtml(7,12): Error RZ9999: "class" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes.cshtml(7,12): Error RZ1007: "class" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_Runtime.ir.txt index 78aaa1d48f..6a6678ed86 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TransitionsInTagHelperAttributes_Runtime - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - class - test - HtmlAttributeValueStyle.DoubleQuotes DefaultTagHelperRuntime - diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode_Runtime.codegen.cs index 42832a4d16..977030b04d 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "80cd1011b7b46797f36c184b68c352568ccc5060" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_UnfinishedExpressionInCode_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"80cd1011b7b46797f36c184b68c352568ccc5060", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_UnfinishedExpressionInCode_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode_Runtime.ir.txt index af1bffd6c9..a9958a1a62 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_UnfinishedExpressionInCode_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [2] UnfinishedExpressionInCode.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Usings_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Usings_Runtime.codegen.cs index 3bf81585f8..a1d0456d97 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Usings_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Usings_Runtime.codegen.cs @@ -1,6 +1,7 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Usings.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "f452adb7c255f6d9d6d2573c6add7cb28022b151" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Usings_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Usings.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden @@ -34,6 +35,7 @@ using static global::System.Text.Encoding; #line default #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"f452adb7c255f6d9d6d2573c6add7cb28022b151", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Usings.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Usings_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Usings_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Usings_Runtime.ir.txt index 5e496ebd41..bdb82e73ec 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Usings_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Usings_Runtime.ir.txt @@ -1,4 +1,5 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles UsingDirective - (1:0,1 [17] Usings.cshtml) - System.IO UsingDirective - (19:1,1 [34] Usings.cshtml) - Foo = System.Text.Encoding @@ -6,6 +7,7 @@ Document - UsingDirective - (71:4,1 [21] Usings.cshtml) - static System UsingDirective - (93:5,1 [29] Usings.cshtml) - static System.Console UsingDirective - (123:6,1 [43] Usings.cshtml) - static global::System.Text.Encoding + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Usings_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (68:3,0 [2] Usings.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/HtmlAttributeIntegrationTest/HtmlWithConditionalAttribute.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/HtmlAttributeIntegrationTest/HtmlWithConditionalAttribute.ir.txt index 9b753e743e..e5c8ff35aa 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/HtmlAttributeIntegrationTest/HtmlWithConditionalAttribute.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/HtmlAttributeIntegrationTest/HtmlWithConditionalAttribute.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Razor + RazorSourceChecksumAttribute - ClassDeclaration - - public - Template - - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [25] HtmlWithConditionalAttribute.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/HtmlAttributeIntegrationTest/HtmlWithDataDashAttribute.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/HtmlAttributeIntegrationTest/HtmlWithDataDashAttribute.ir.txt index 25a8f89a4d..3486809b58 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/HtmlAttributeIntegrationTest/HtmlWithDataDashAttribute.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/HtmlAttributeIntegrationTest/HtmlWithDataDashAttribute.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Razor + RazorSourceChecksumAttribute - ClassDeclaration - - public - Template - - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [36] HtmlWithDataDashAttribute.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithBaseType.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithBaseType.codegen.cs index 6961cd2e4d..38d08a7c75 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithBaseType.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithBaseType.codegen.cs @@ -1,9 +1,10 @@ -#pragma checksum "TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithBaseType.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "38aa8e26c5d2a85c61d8e93fe69dd326fe82671b" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Razor.Template), @"default", @"/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithBaseType.cshtml")] namespace Razor { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"38aa8e26c5d2a85c61d8e93fe69dd326fe82671b", @"/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithBaseType.cshtml")] public class Template : MyBaseType { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithConfigureClass.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithConfigureClass.codegen.cs index f4c0b6d245..2baca26a3f 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithConfigureClass.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithConfigureClass.codegen.cs @@ -1,9 +1,10 @@ -#pragma checksum "TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithConfigureClass.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "38aa8e26c5d2a85c61d8e93fe69dd326fe82671b" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Razor.MyClass), @"default", @"/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithConfigureClass.cshtml")] namespace Razor { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"38aa8e26c5d2a85c61d8e93fe69dd326fe82671b", @"/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithConfigureClass.cshtml")] protected internal class MyClass : CustomBaseType, global::System.IDisposable { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithDefaults.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithDefaults.codegen.cs index 30f1118650..0ca4f5d061 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithDefaults.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithDefaults.codegen.cs @@ -1,9 +1,10 @@ -#pragma checksum "TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithDefaults.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "38aa8e26c5d2a85c61d8e93fe69dd326fe82671b" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Razor.Template), @"default", @"/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithDefaults.cshtml")] namespace Razor { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"38aa8e26c5d2a85c61d8e93fe69dd326fe82671b", @"/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithDefaults.cshtml")] public class Template { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithSetNamespace.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithSetNamespace.codegen.cs index 7386ae0b19..8cff2ae67f 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithSetNamespace.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithSetNamespace.codegen.cs @@ -1,9 +1,10 @@ -#pragma checksum "TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithSetNamespace.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "38aa8e26c5d2a85c61d8e93fe69dd326fe82671b" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(MyApp.Razor.Views.Template), @"default", @"/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithSetNamespace.cshtml")] namespace MyApp.Razor.Views { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"38aa8e26c5d2a85c61d8e93fe69dd326fe82671b", @"/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithSetNamespace.cshtml")] public class Template { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/TagHelpersIntegrationTest/NestedTagHelpers.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/TagHelpersIntegrationTest/NestedTagHelpers.ir.txt index 021d34383a..ab0e72e99a 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/TagHelpersIntegrationTest/NestedTagHelpers.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/TagHelpersIntegrationTest/NestedTagHelpers.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Razor + RazorSourceChecksumAttribute - ClassDeclaration - - public - Template - - PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - value - Hello - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - type - text - HtmlAttributeValueStyle.SingleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/TagHelpersIntegrationTest/SimpleTagHelpers.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/TagHelpersIntegrationTest/SimpleTagHelpers.ir.txt index 12ebcf7df3..80661692b6 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/TagHelpersIntegrationTest/SimpleTagHelpers.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/TagHelpersIntegrationTest/SimpleTagHelpers.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Razor + RazorSourceChecksumAttribute - ClassDeclaration - - public - Template - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - value - Hello - HtmlAttributeValueStyle.SingleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - type - text - HtmlAttributeValueStyle.SingleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/TagHelpersIntegrationTest/TagHelpersWithBoundAttributes.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/TagHelpersIntegrationTest/TagHelpersWithBoundAttributes.ir.txt index 2dd09583c8..3a72431dd8 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/TagHelpersIntegrationTest/TagHelpersWithBoundAttributes.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/TagHelpersIntegrationTest/TagHelpersWithBoundAttributes.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Razor + RazorSourceChecksumAttribute - ClassDeclaration - - public - Template - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - type - text - HtmlAttributeValueStyle.SingleQuotes DefaultTagHelperRuntime - diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProject.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestRazorProject.cs similarity index 100% rename from test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProject.cs rename to test/Microsoft.AspNetCore.Razor.Language.Test/TestRazorProject.cs diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/VirtualRazorProjectFileSystemTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/VirtualRazorProjectFileSystemTest.cs new file mode 100644 index 0000000000..f4501b1321 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/VirtualRazorProjectFileSystemTest.cs @@ -0,0 +1,400 @@ +// 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 Xunit; +using DirectoryNode = Microsoft.AspNetCore.Razor.Language.VirtualRazorProjectFileSystem.DirectoryNode; +using FileNode = Microsoft.AspNetCore.Razor.Language.VirtualRazorProjectFileSystem.FileNode; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class VirtualRazorProjectFileSystemTest + { + [Fact] + public void GetItem_ReturnsNotFound_IfFileDoesNotExistInRoot() + { + // Arrange + var path = "/root-file.cshtml"; + var projectSystem = new VirtualRazorProjectFileSystem(); + + // Act + projectSystem.Add(new TestRazorProjectItem("/different-file.cshtml")); + var result = projectSystem.GetItem(path); + + // Assert + Assert.False(result.Exists); + } + + [Fact] + public void GetItem_ReturnsItemAddedToRoot() + { + // Arrange + var path = "/root-file.cshtml"; + var projectSystem = new VirtualRazorProjectFileSystem(); + var projectItem = new TestRazorProjectItem(path); + + // Act + projectSystem.Add(projectItem); + var actual = projectSystem.GetItem(path); + + // Assert + Assert.Same(projectItem, actual); + } + + [Theory] + [InlineData("/subDirectory/file.cshtml")] + [InlineData("/subDirectory/dir2/file.cshtml")] + [InlineData("/subDirectory/dir2/dir3/file.cshtml")] + public void GetItem_ReturnsItemAddedToNestedDirectory(string path) + { + // Arrange + var projectSystem = new VirtualRazorProjectFileSystem(); + var projectItem = new TestRazorProjectItem(path); + + // Act + projectSystem.Add(projectItem); + var actual = projectSystem.GetItem(path); + + // Assert + Assert.Same(projectItem, actual); + } + + [Fact] + public void GetItem_ReturnsNotFound_WhenNestedDirectoryDoesNotExist() + { + // Arrange + var projectSystem = new VirtualRazorProjectFileSystem(); + + // Act + var actual = projectSystem.GetItem("/subDirectory/dir3/file.cshtml"); + + // Assert + Assert.False(actual.Exists); + } + + [Fact] + public void GetItem_ReturnsNotFound_WhenNestedDirectoryDoesNotExist_AndPeerDirectoryExists() + { + // Arrange + var projectSystem = new VirtualRazorProjectFileSystem(); + var projectItem = new TestRazorProjectItem("/subDirectory/dir2/file.cshtml"); + + // Act + projectSystem.Add(projectItem); + var actual = projectSystem.GetItem("/subDirectory/dir3/file.cshtml"); + + // Assert + Assert.False(actual.Exists); + } + + [Fact] + public void GetItem_ReturnsNotFound_WhenFileDoesNotExistInNestedDirectory() + { + // Arrange + var projectSystem = new VirtualRazorProjectFileSystem(); + var projectItem = new TestRazorProjectItem("/subDirectory/dir2/file.cshtml"); + + // Act + projectSystem.Add(projectItem); + var actual = projectSystem.GetItem("/subDirectory/dir2/file2.cshtml"); + + // Assert + Assert.False(actual.Exists); + } + + [Fact] + public void EnumerateItems_AtRoot_ReturnsAllFiles() + { + // Arrange + var projectSystem = new VirtualRazorProjectFileSystem(); + var file1 = new TestRazorProjectItem("/subDirectory/dir2/file1.cshtml"); + var file2 = new TestRazorProjectItem("/file2.cshtml"); + var file3 = new TestRazorProjectItem("/dir3/file3.cshtml"); + var file4 = new TestRazorProjectItem("/subDirectory/file4.cshtml"); + projectSystem.Add(file1); + projectSystem.Add(file2); + projectSystem.Add(file3); + projectSystem.Add(file4); + + // Act + var result = projectSystem.EnumerateItems("/"); + + // Assert + Assert.Equal(new[] { file2, file4, file1, file3 }, result); + } + + [Fact] + public void EnumerateItems_AtSubDirectory_ReturnsAllFilesUnderDirectoryHierarchy() + { + // Arrange + var projectSystem = new VirtualRazorProjectFileSystem(); + var file1 = new TestRazorProjectItem("/subDirectory/dir2/file1.cshtml"); + var file2 = new TestRazorProjectItem("/file2.cshtml"); + var file3 = new TestRazorProjectItem("/dir3/file3.cshtml"); + var file4 = new TestRazorProjectItem("/subDirectory/file4.cshtml"); + projectSystem.Add(file1); + projectSystem.Add(file2); + projectSystem.Add(file3); + projectSystem.Add(file4); + + // Act + var result = projectSystem.EnumerateItems("/subDirectory"); + + // Assert + Assert.Equal(new[] { file4, file1 }, result); + } + + [Fact] + public void EnumerateItems_WithNoFilesInRoot_ReturnsEmptySequence() + { + // Arrange + var projectSystem = new VirtualRazorProjectFileSystem(); + + // Act + var result = projectSystem.EnumerateItems("/"); + + // Assert + Assert.Empty(result); + } + + [Fact] + public void EnumerateItems_ForNonExistentDirectory_ReturnsEmptySequence() + { + // Arrange + var projectSystem = new VirtualRazorProjectFileSystem(); + projectSystem.Add(new TestRazorProjectItem("/subDirectory/dir2/file1.cshtml")); + projectSystem.Add(new TestRazorProjectItem("/file2.cshtml")); + + // Act + var result = projectSystem.EnumerateItems("/dir3"); + + // Assert + Assert.Empty(result); + } + + [Fact] + public void GetHierarchicalItems_Works() + { + // Arrange + var projectSystem = new VirtualRazorProjectFileSystem(); + var viewImport1 = new TestRazorProjectItem("/_ViewImports.cshtml"); + var viewImport2 = new TestRazorProjectItem("/Views/Home/_ViewImports.cshtml"); + projectSystem.Add(viewImport1); + projectSystem.Add(viewImport2); + + // Act + var items = projectSystem.FindHierarchicalItems("/", "/Views/Home/Index.cshtml", "_ViewImports.cshtml"); + + // Assert + Assert.Collection( + items, + item => Assert.Same(viewImport2, item), + item => Assert.False(item.Exists), + item => Assert.Same(viewImport1, item)); + } + + [Fact] + public void DirectoryNode_GetDirectory_ReturnsRoot() + { + // Arrange + var root = new DirectoryNode("/"); + + // Act + var result = root.GetDirectory("/"); + + // Assert + Assert.Same(root, result); + } + + [Fact] + public void DirectoryNode_GetDirectory_ReturnsNull_IfDirectoryDoesNotExist() + { + // Arrange + var root = new DirectoryNode("/"); + + // Act + var result = root.GetDirectory("/does-not/exist"); + + // Assert + Assert.Null(result); + } + + [Fact] + public void DirectoryNode_AddFile_CanAddToRoot() + { + // Arrange + var root = new DirectoryNode("/"); + var projectItem = new TestRazorProjectItem("/File.txt"); + + // Act + root.AddFile(new FileNode("/File.txt", projectItem)); + + // Assert + Assert.Empty(root.Directories); + Assert.Collection( + root.Files, + file => Assert.Same(projectItem, file.ProjectItem)); + } + + [Fact] + public void DirectoryNode_AddFile_CanAddToNestedDirectory() + { + // Arrange + var root = new DirectoryNode("/"); + var projectItem = new TestRazorProjectItem("/Pages/Shared/_Layout.cshtml"); + + // Act + root.AddFile(new FileNode("/Pages/Shared/_Layout.cshtml", projectItem)); + + // Assert + Assert.Collection( + root.Directories, + directory => + { + Assert.Equal("/Pages/", directory.Path); + Assert.Empty(directory.Files); + + Assert.Collection( + directory.Directories, + subDirectory => + { + Assert.Equal("/Pages/Shared/", subDirectory.Path); + Assert.Collection( + subDirectory.Files, + file => Assert.Same(projectItem, file.ProjectItem)); + }); + }); + } + + [Fact] + public void DirectoryNode_AddMultipleFiles_ToSameDirectory() + { + // Arrange + var root = new DirectoryNode("/"); + var projectItem1 = new TestRazorProjectItem("/Pages/Shared/_Layout.cshtml"); + var projectItem2 = new TestRazorProjectItem("/Pages/Shared/_Partial.cshtml"); + + // Act + root.AddFile(new FileNode(projectItem1.FilePath, projectItem1)); + root.AddFile(new FileNode(projectItem2.FilePath, projectItem2)); + + // Assert + Assert.Collection( + root.Directories, + directory => + { + Assert.Equal("/Pages/", directory.Path); + Assert.Empty(directory.Files); + + Assert.Collection( + directory.Directories, + subDirectory => + { + Assert.Equal("/Pages/Shared/", subDirectory.Path); + Assert.Collection( + subDirectory.Files, + file => Assert.Same(projectItem1, file.ProjectItem), + file => Assert.Same(projectItem2, file.ProjectItem)); + }); + }); + } + + [Fact] + public void DirectoryNode_AddsFiles_ToSiblingDirectories() + { + // Arrange + var root = new DirectoryNode("/"); + var projectItem1 = new TestRazorProjectItem("/Pages/Products/Index.cshtml"); + var projectItem2 = new TestRazorProjectItem("/Pages/Accounts/About.cshtml"); + + // Act + root.AddFile(new FileNode(projectItem1.FilePath, projectItem1)); + root.AddFile(new FileNode(projectItem2.FilePath, projectItem2)); + + // Assert + Assert.Collection( + root.Directories, + directory => + { + Assert.Equal("/Pages/", directory.Path); + Assert.Empty(directory.Files); + + Assert.Collection( + directory.Directories, + subDirectory => + { + Assert.Equal("/Pages/Products/", subDirectory.Path); + Assert.Collection( + subDirectory.Files, + file => Assert.Same(projectItem1, file.ProjectItem)); + }, + subDirectory => + { + Assert.Equal("/Pages/Accounts/", subDirectory.Path); + Assert.Collection( + subDirectory.Files, + file => Assert.Same(projectItem2, file.ProjectItem)); + }); + }); + } + + [Fact] + public void DirectoryNode_GetItem_ReturnsItemAtRoot() + { + // Arrange + var root = new DirectoryNode("/"); + var projectItem = new TestRazorProjectItem("/_ViewStart.cshtml"); + root.AddFile(new FileNode(projectItem.FilePath, projectItem)); + + // Act + var result = root.GetItem(projectItem.FilePath); + + // Assert + Assert.Same(result, projectItem); + } + + [Fact] + public void DirectoryNode_GetItem_WhenFilePathSharesSameNameAsSiblingDirectory() + { + // Arrange + var root = new DirectoryNode("/"); + var projectItem1 = new TestRazorProjectItem("/Home.cshtml"); + var projectItem2 = new TestRazorProjectItem("/Home/About.cshtml"); + root.AddFile(new FileNode(projectItem1.FilePath, projectItem1)); + root.AddFile(new FileNode(projectItem2.FilePath, projectItem2)); + + // Act + var result = root.GetItem(projectItem1.FilePath); + + // Assert + Assert.Same(result, projectItem1); + } + + [Fact] + public void DirectoryNode_GetItem_WhenFileNameIsSameAsDirectoryName() + { + // Arrange + var projectItem1 = new TestRazorProjectItem("/Home/Home.cshtml"); + var projectItem2 = new TestRazorProjectItem("/Home/About.cshtml"); + var root = new DirectoryNode("/") + { + Directories = + { + new DirectoryNode("/Home/") + { + Files = + { + new FileNode(projectItem1.FilePath, projectItem1), + new FileNode(projectItem2.FilePath, projectItem2), + } + } + }, + }; + + // Act + var result = root.GetItem(projectItem1.FilePath); + + // Assert + Assert.Same(result, projectItem1); + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Performance/Configs/CoreConfig.cs b/test/Microsoft.AspNetCore.Razor.Performance/Configs/CoreConfig.cs deleted file mode 100644 index 9e93e361c0..0000000000 --- a/test/Microsoft.AspNetCore.Razor.Performance/Configs/CoreConfig.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. - -using BenchmarkDotNet.Columns; -using BenchmarkDotNet.Configs; -using BenchmarkDotNet.Diagnosers; -using BenchmarkDotNet.Engines; -using BenchmarkDotNet.Jobs; -using BenchmarkDotNet.Validators; - -namespace Microsoft.AspNetCore.Razor.Performance -{ - public class CoreConfig : ManualConfig - { - public CoreConfig() - { - Add(JitOptimizationsValidator.FailOnError); - Add(MemoryDiagnoser.Default); - Add(StatisticColumn.OperationsPerSecond); - - Add(Job.Default - .With(BenchmarkDotNet.Environments.Runtime.Core) - .WithRemoveOutliers(false) - .With(new GcMode() { Server = true }) - .With(RunStrategy.Throughput) - .WithLaunchCount(3) - .WithWarmupCount(5) - .WithTargetCount(10)); - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Razor.Performance/Microsoft.AspNetCore.Razor.Performance.csproj b/test/Microsoft.AspNetCore.Razor.Performance/Microsoft.AspNetCore.Razor.Performance.csproj deleted file mode 100644 index da0a1b14e0..0000000000 --- a/test/Microsoft.AspNetCore.Razor.Performance/Microsoft.AspNetCore.Razor.Performance.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - netcoreapp2.0 - Exe - true - true - false - - - - - - - - - - - diff --git a/test/Microsoft.AspNetCore.Razor.Performance/Program.cs b/test/Microsoft.AspNetCore.Razor.Performance/Program.cs deleted file mode 100644 index 9191a1098c..0000000000 --- a/test/Microsoft.AspNetCore.Razor.Performance/Program.cs +++ /dev/null @@ -1,17 +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; -using System.Reflection; -using BenchmarkDotNet.Running; - -namespace Microsoft.AspNetCore.Razor.Performance -{ - public class Program - { - public static void Main(string[] args) - { - BenchmarkSwitcher.FromAssembly(typeof(Program).GetTypeInfo().Assembly).Run(args); - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/IntegrationTestBase.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/IntegrationTestBase.cs index 7b9fc7bd66..23b723bc49 100644 --- a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/IntegrationTestBase.cs +++ b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/IntegrationTestBase.cs @@ -79,6 +79,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests var source = TestRazorSourceDocument.CreateResource(sourceFileName, GetType(), normalizeNewLines: true); var imports = new List(); + var importIdentifiers = new List(); while (true) { var importsFileName = Path.ChangeExtension(normalizedFileName + "_Imports" + imports.Count.ToString(), ".cshtml"); @@ -87,6 +88,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests break; } + importIdentifiers.Add(normalizedFileName + "_Imports" + imports.Count.ToString()); imports.Add(TestRazorSourceDocument.CreateResource(importsFileName, GetType(), normalizeNewLines: true)); } @@ -227,45 +229,5 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests Assert.Equal(baseline, actual); } - - protected class ApiSetsIRTestAdapter : IntermediateNodePassBase, IRazorOptimizationPass - { - protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) - { - var walker = new ApiSetsIRWalker(); - walker.Visit(documentNode); - } - - private class ApiSetsIRWalker : IntermediateNodeWalker - { - public override void VisitClassDeclaration(ClassDeclarationIntermediateNode node) - { - node.ClassName = FileName.Replace('/', '_'); - - node.Modifiers.Clear(); - node.Modifiers.Add("public"); - - VisitDefault(node); - } - - public override void VisitNamespaceDeclaration(NamespaceDeclarationIntermediateNode node) - { - node.Content = "Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles"; - - VisitDefault(node); - } - - public override void VisitMethodDeclaration(MethodDeclarationIntermediateNode node) - { - node.Modifiers.Clear(); - node.Modifiers.Add("public"); - node.Modifiers.Add("async"); - node.MethodName = "ExecuteAsync"; - node.ReturnType = typeof(Task).FullName; - - VisitDefault(node); - } - } - } } } diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/ParserTestBase.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/ParserTestBase.cs index f91e4c65aa..1f9ec8a407 100644 --- a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/ParserTestBase.cs +++ b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/ParserTestBase.cs @@ -46,7 +46,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { directives = directives ?? Array.Empty(); - var source = TestRazorSourceDocument.Create(document, fileName: null); + var source = TestRazorSourceDocument.Create(document, filePath: null); var options = CreateParserOptions(directives, designTime); var context = new ParserContext(source, options); @@ -60,7 +60,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy markupParser.ParseDocument(); var root = context.Builder.Build(); - var diagnostics = context.ErrorSink.Errors?.Select(error => RazorDiagnostic.Create(error)); + var diagnostics = context.ErrorSink.Errors; var codeDocument = RazorCodeDocument.Create(source); @@ -77,7 +77,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { directives = directives ?? Array.Empty(); - var source = TestRazorSourceDocument.Create(document, fileName: null); + var source = TestRazorSourceDocument.Create(document, filePath: null); var options = CreateParserOptions(directives, designTime); var context = new ParserContext(source, options); @@ -90,7 +90,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy parser.ParseBlock(); var root = context.Builder.Build(); - var diagnostics = context.ErrorSink.Errors?.Select(error => RazorDiagnostic.Create(error)); + var diagnostics = context.ErrorSink.Errors; return RazorSyntaxTree.Create(root, source, diagnostics, options); } @@ -107,7 +107,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { directives = directives ?? Array.Empty(); - var source = TestRazorSourceDocument.Create(document, fileName: null); + var source = TestRazorSourceDocument.Create(document, filePath: null); var options = CreateParserOptions(directives, designTime); var context = new ParserContext(source, options); @@ -120,7 +120,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy parser.ParseBlock(); var root = context.Builder.Build(); - var diagnostics = context.ErrorSink.Errors?.Select(error => RazorDiagnostic.Create(error)); + var diagnostics = context.ErrorSink.Errors; return RazorSyntaxTree.Create(root, source, diagnostics, options); } @@ -134,20 +134,20 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy internal virtual void ParseBlockTest(string document) { - ParseBlockTest(document, null, false, new RazorError[0]); + ParseBlockTest(document, null, false, new RazorDiagnostic[0]); } internal virtual void ParseBlockTest(string document, bool designTime) { - ParseBlockTest(document, null, designTime, new RazorError[0]); + ParseBlockTest(document, null, designTime, new RazorDiagnostic[0]); } - internal virtual void ParseBlockTest(string document, params RazorError[] expectedErrors) + internal virtual void ParseBlockTest(string document, params RazorDiagnostic[] expectedErrors) { ParseBlockTest(document, false, expectedErrors); } - internal virtual void ParseBlockTest(string document, bool designTime, params RazorError[] expectedErrors) + internal virtual void ParseBlockTest(string document, bool designTime, params RazorDiagnostic[] expectedErrors) { ParseBlockTest(document, null, designTime, expectedErrors); } @@ -167,22 +167,22 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy ParseBlockTest(document, expectedRoot, designTime, null); } - internal virtual void ParseBlockTest(string document, Block expectedRoot, params RazorError[] expectedErrors) + internal virtual void ParseBlockTest(string document, Block expectedRoot, params RazorDiagnostic[] expectedErrors) { ParseBlockTest(document, expectedRoot, false, expectedErrors); } - internal virtual void ParseBlockTest(string document, IEnumerable directives, Block expectedRoot, params RazorError[] expectedErrors) + internal virtual void ParseBlockTest(string document, IEnumerable directives, Block expectedRoot, params RazorDiagnostic[] expectedErrors) { ParseBlockTest(document, directives, expectedRoot, false, expectedErrors); } - internal virtual void ParseBlockTest(string document, Block expected, bool designTime, params RazorError[] expectedErrors) + internal virtual void ParseBlockTest(string document, Block expected, bool designTime, params RazorDiagnostic[] expectedErrors) { ParseBlockTest(document, null, expected, designTime, expectedErrors); } - internal virtual void ParseBlockTest(string document, IEnumerable directives, Block expected, bool designTime, params RazorError[] expectedErrors) + internal virtual void ParseBlockTest(string document, IEnumerable directives, Block expected, bool designTime, params RazorDiagnostic[] expectedErrors) { var result = ParseBlock(document, directives, designTime); @@ -199,7 +199,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (!ReferenceEquals(expected, IgnoreOutput)) { - EvaluateResults(result, expected, expectedErrors?.Select(error => RazorDiagnostic.Create(error)).ToList()); + EvaluateResults(result, expected, expectedErrors); } } @@ -213,22 +213,22 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy SingleSpanBlockTest(document, spanContent, blockKind, spanType, acceptedCharacters, expectedErrors: null); } - internal virtual void SingleSpanBlockTest(string document, BlockKindInternal blockKind, SpanKindInternal spanType, params RazorError[] expectedError) + internal virtual void SingleSpanBlockTest(string document, BlockKindInternal blockKind, SpanKindInternal spanType, params RazorDiagnostic[] expectedError) { SingleSpanBlockTest(document, document, blockKind, spanType, expectedError); } - internal virtual void SingleSpanBlockTest(string document, string spanContent, BlockKindInternal blockKind, SpanKindInternal spanType, params RazorError[] expectedErrors) + internal virtual void SingleSpanBlockTest(string document, string spanContent, BlockKindInternal blockKind, SpanKindInternal spanType, params RazorDiagnostic[] expectedErrors) { - SingleSpanBlockTest(document, spanContent, blockKind, spanType, AcceptedCharactersInternal.Any, expectedErrors ?? new RazorError[0]); + SingleSpanBlockTest(document, spanContent, blockKind, spanType, AcceptedCharactersInternal.Any, expectedErrors ?? new RazorDiagnostic[0]); } - internal virtual void SingleSpanBlockTest(string document, BlockKindInternal blockKind, SpanKindInternal spanType, AcceptedCharactersInternal acceptedCharacters, params RazorError[] expectedError) + internal virtual void SingleSpanBlockTest(string document, BlockKindInternal blockKind, SpanKindInternal spanType, AcceptedCharactersInternal acceptedCharacters, params RazorDiagnostic[] expectedError) { SingleSpanBlockTest(document, document, blockKind, spanType, acceptedCharacters, expectedError); } - internal virtual void SingleSpanBlockTest(string document, string spanContent, BlockKindInternal blockKind, SpanKindInternal spanType, AcceptedCharactersInternal acceptedCharacters, params RazorError[] expectedErrors) + internal virtual void SingleSpanBlockTest(string document, string spanContent, BlockKindInternal blockKind, SpanKindInternal spanType, AcceptedCharactersInternal acceptedCharacters, params RazorDiagnostic[] expectedErrors) { var result = ParseBlock(document, designTime: false); @@ -249,7 +249,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (!ReferenceEquals(expected, IgnoreOutput)) { - EvaluateResults(result, expected, expectedErrors?.Select(error => RazorDiagnostic.Create(error)).ToList()); + EvaluateResults(result, expected, expectedErrors); } } @@ -263,12 +263,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy ParseDocumentTest(document, expectedRoot, false, null); } - internal virtual void ParseDocumentTest(string document, Block expectedRoot, params RazorError[] expectedErrors) + internal virtual void ParseDocumentTest(string document, Block expectedRoot, params RazorDiagnostic[] expectedErrors) { ParseDocumentTest(document, expectedRoot, false, expectedErrors); } - internal virtual void ParseDocumentTest(string document, IEnumerable directives, Block expected, params RazorError[] expectedErrors) + internal virtual void ParseDocumentTest(string document, IEnumerable directives, Block expected, params RazorDiagnostic[] expectedErrors) { ParseDocumentTest(document, directives, expected, false, expectedErrors); } @@ -283,12 +283,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy ParseDocumentTest(document, expectedRoot, designTime, null); } - internal virtual void ParseDocumentTest(string document, Block expected, bool designTime, params RazorError[] expectedErrors) + internal virtual void ParseDocumentTest(string document, Block expected, bool designTime, params RazorDiagnostic[] expectedErrors) { ParseDocumentTest(document, null, expected, designTime, expectedErrors); } - internal virtual void ParseDocumentTest(string document, IEnumerable directives, Block expected, bool designTime, params RazorError[] expectedErrors) + internal virtual void ParseDocumentTest(string document, IEnumerable directives, Block expected, bool designTime, params RazorDiagnostic[] expectedErrors) { var result = ParseDocument(document, directives, designTime); @@ -305,7 +305,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (!ReferenceEquals(expected, IgnoreOutput)) { - EvaluateResults(result, expected, expectedErrors?.Select(error => RazorDiagnostic.Create(error)).ToList()); + EvaluateResults(result, expected, expectedErrors); } } diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/TestSpanBuilder.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/TestSpanBuilder.cs index 5b933b1749..ed7b3aadde 100644 --- a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/TestSpanBuilder.cs +++ b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/TestSpanBuilder.cs @@ -339,9 +339,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy string directiveText, string typePattern = null, string assemblyName = null, - params RazorError[] legacyErrors) + params RazorDiagnostic[] errors) { - var diagnostics = legacyErrors.Select(error => RazorDiagnostic.Create(error)).ToList(); + var diagnostics = errors.ToList(); return _self .With(new AddTagHelperChunkGenerator(lookupText, directiveText, typePattern, assemblyName, diagnostics)) .Accepts(AcceptedCharactersInternal.AnyExceptNewline); @@ -352,17 +352,17 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy string directiveText, string typePattern = null, string assemblyName = null, - params RazorError[] legacyErrors) + params RazorDiagnostic[] errors) { - var diagnostics = legacyErrors.Select(error => RazorDiagnostic.Create(error)).ToList(); + var diagnostics = errors.ToList(); return _self .With(new RemoveTagHelperChunkGenerator(lookupText, directiveText, typePattern, assemblyName, diagnostics)) .Accepts(AcceptedCharactersInternal.AnyExceptNewline); } - public SpanConstructor AsTagHelperPrefixDirective(string prefix, string directiveText, params RazorError[] legacyErrors) + public SpanConstructor AsTagHelperPrefixDirective(string prefix, string directiveText, params RazorDiagnostic[] errors) { - var diagnostics = legacyErrors.Select(error => RazorDiagnostic.Create(error)).ToList(); + var diagnostics = errors.ToList(); return _self .With(new TagHelperPrefixDirectiveChunkGenerator(prefix, directiveText, diagnostics)) .Accepts(AcceptedCharactersInternal.AnyExceptNewline); diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/RazorEngineBuilderExtensions.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/RazorEngineBuilderExtensions.cs index 7bdd79b889..2b0531baa3 100644 --- a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/RazorEngineBuilderExtensions.cs +++ b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/RazorEngineBuilderExtensions.cs @@ -3,6 +3,9 @@ using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.Language.IntegrationTests; +using Microsoft.AspNetCore.Razor.Language.Intermediate; namespace Microsoft.AspNetCore.Razor.Language { @@ -25,5 +28,42 @@ namespace Microsoft.AspNetCore.Razor.Language feature.TagHelpers.AddRange(tagHelpers); return builder; } + + public static IRazorEngineBuilder ConfigureDocumentClassifier(this IRazorEngineBuilder builder) + { + var feature = builder.Features.OfType().FirstOrDefault(); + if (feature == null) + { + feature = new DefaultDocumentClassifierPassFeature(); + builder.Features.Add(feature); + } + + feature.ConfigureNamespace.Clear(); + feature.ConfigureClass.Clear(); + feature.ConfigureMethod.Clear(); + + feature.ConfigureNamespace.Add((RazorCodeDocument codeDocument, NamespaceDeclarationIntermediateNode node) => + { + node.Content = "Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles"; + }); + + feature.ConfigureClass.Add((RazorCodeDocument codeDocument, ClassDeclarationIntermediateNode node) => + { + node.ClassName = IntegrationTestBase.FileName.Replace('/', '_'); + node.Modifiers.Clear(); + node.Modifiers.Add("public"); + }); + + feature.ConfigureMethod.Add((RazorCodeDocument codeDocument, MethodDeclarationIntermediateNode node) => + { + node.Modifiers.Clear(); + node.Modifiers.Add("public"); + node.Modifiers.Add("async"); + node.MethodName = "ExecuteAsync"; + node.ReturnType = typeof(Task).FullName; + }); + + return builder; + } } } diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/RazorProjectEngineBuilderExtensions.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/RazorProjectEngineBuilderExtensions.cs new file mode 100644 index 0000000000..bcea84e918 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/RazorProjectEngineBuilderExtensions.cs @@ -0,0 +1,70 @@ +// 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.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.Language.IntegrationTests; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public static class RazorProjectEngineBuilderExtensions + { + public static RazorProjectEngineBuilder AddTagHelpers(this RazorProjectEngineBuilder builder, params TagHelperDescriptor[] tagHelpers) + { + return AddTagHelpers(builder, (IEnumerable)tagHelpers); + } + + public static RazorProjectEngineBuilder AddTagHelpers(this RazorProjectEngineBuilder builder, IEnumerable tagHelpers) + { + var feature = (TestTagHelperFeature)builder.Features.OfType().FirstOrDefault(); + if (feature == null) + { + feature = new TestTagHelperFeature(); + builder.Features.Add(feature); + } + + feature.TagHelpers.AddRange(tagHelpers); + return builder; + } + + public static RazorProjectEngineBuilder ConfigureDocumentClassifier(this RazorProjectEngineBuilder builder) + { + var feature = builder.Features.OfType().FirstOrDefault(); + if (feature == null) + { + feature = new DefaultDocumentClassifierPassFeature(); + builder.Features.Add(feature); + } + + feature.ConfigureNamespace.Clear(); + feature.ConfigureClass.Clear(); + feature.ConfigureMethod.Clear(); + + feature.ConfigureNamespace.Add((RazorCodeDocument codeDocument, NamespaceDeclarationIntermediateNode node) => + { + node.Content = "Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles"; + }); + + feature.ConfigureClass.Add((RazorCodeDocument codeDocument, ClassDeclarationIntermediateNode node) => + { + node.ClassName = IntegrationTestBase.FileName.Replace('/', '_'); + node.Modifiers.Clear(); + node.Modifiers.Add("public"); + }); + + feature.ConfigureMethod.Add((RazorCodeDocument codeDocument, MethodDeclarationIntermediateNode node) => + { + node.Modifiers.Clear(); + node.Modifiers.Add("public"); + node.Modifiers.Add("async"); + node.MethodName = "ExecuteAsync"; + node.ReturnType = typeof(Task).FullName; + }); + + return builder; + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProjectFileSystem.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProjectFileSystem.cs new file mode 100644 index 0000000000..f16fff0274 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProjectFileSystem.cs @@ -0,0 +1,41 @@ +// 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.Collections.Generic; +using System.Linq; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal class TestRazorProjectFileSystem : DefaultRazorProjectFileSystem + { + public new static RazorProjectFileSystem Empty = new TestRazorProjectFileSystem(); + + private readonly Dictionary _lookup; + + public TestRazorProjectFileSystem() + : this(new RazorProjectItem[0]) + { + } + + public TestRazorProjectFileSystem(IList items) : base("/") + { + _lookup = items.ToDictionary(item => item.FilePath); + } + + public override IEnumerable EnumerateItems(string basePath) + { + throw new NotImplementedException(); + } + + public override RazorProjectItem GetItem(string path) + { + if (!_lookup.TryGetValue(path, out var value)) + { + value = new NotFoundProjectItem("", path); + } + + return value; + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProjectItem.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProjectItem.cs index 3e0bd1e44f..d4f03fbf0d 100644 --- a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProjectItem.cs +++ b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProjectItem.cs @@ -9,12 +9,14 @@ namespace Microsoft.AspNetCore.Razor.Language public class TestRazorProjectItem : RazorProjectItem { public TestRazorProjectItem( - string path, + string filePath, string physicalPath = null, + string relativePhysicalPath = null, string basePath = "/") { - FilePath = path; + FilePath = filePath; PhysicalPath = physicalPath; + RelativePhysicalPath = relativePhysicalPath; BasePath = basePath; } @@ -24,7 +26,9 @@ namespace Microsoft.AspNetCore.Razor.Language public override string PhysicalPath { get; } - public override bool Exists => true; + public override string RelativePhysicalPath { get; } + + public override bool Exists { get; } = true; public string Content { get; set; } = "Default content"; diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorSourceDocument.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorSourceDocument.cs index 57a5fb196e..e731b03594 100644 --- a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorSourceDocument.cs +++ b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorSourceDocument.cs @@ -11,12 +11,35 @@ namespace Microsoft.AspNetCore.Razor.Language { public static class TestRazorSourceDocument { - public static RazorSourceDocument CreateResource(string path, Type type, Encoding encoding = null, bool normalizeNewLines = false) + public static RazorSourceDocument CreateResource(string resourcePath, Type type, Encoding encoding = null, bool normalizeNewLines = false) { - return CreateResource(path, type.GetTypeInfo().Assembly, encoding, normalizeNewLines); + return CreateResource(resourcePath, type.GetTypeInfo().Assembly, encoding, normalizeNewLines); } - public static RazorSourceDocument CreateResource(string path, Assembly assembly, Encoding encoding = null, bool normalizeNewLines = false) + public static RazorSourceDocument CreateResource(string resourcePath, Assembly assembly, Encoding encoding = null, bool normalizeNewLines = false) + { + var file = TestFile.Create(resourcePath, assembly); + + using (var input = file.OpenRead()) + using (var reader = new StreamReader(input)) + { + var content = reader.ReadToEnd(); + if (normalizeNewLines) + { + content = NormalizeNewLines(content); + } + + var properties = new RazorSourceDocumentProperties(resourcePath, resourcePath); + return new StringSourceDocument(content, encoding ?? Encoding.UTF8, properties); + } + } + + public static RazorSourceDocument CreateResource( + string path, + Assembly assembly, + Encoding encoding, + RazorSourceDocumentProperties properties, + bool normalizeNewLines = false) { var file = TestFile.Create(path, assembly); @@ -28,8 +51,8 @@ namespace Microsoft.AspNetCore.Razor.Language { content = NormalizeNewLines(content); } - - return new StringSourceDocument(content, encoding ?? Encoding.UTF8, path); + + return new StringSourceDocument(content, encoding ?? Encoding.UTF8, properties); } } @@ -52,14 +75,34 @@ namespace Microsoft.AspNetCore.Razor.Language return stream; } - public static RazorSourceDocument Create(string content = "Hello, world!", Encoding encoding = null, bool normalizeNewLines = false, string fileName = "test.cshtml") + public static RazorSourceDocument Create( + string content = "Hello, world!", + Encoding encoding = null, + bool normalizeNewLines = false, + string filePath = "test.cshtml", + string relativePath = "test.cshtml") { if (normalizeNewLines) { content = NormalizeNewLines(content); } - return new StringSourceDocument(content, encoding ?? Encoding.UTF8, fileName); + var properties = new RazorSourceDocumentProperties(filePath, relativePath); + return new StringSourceDocument(content, encoding ?? Encoding.UTF8, properties); + } + + public static RazorSourceDocument Create( + string content, + RazorSourceDocumentProperties properties, + Encoding encoding = null, + bool normalizeNewLines = false) + { + if (normalizeNewLines) + { + content = NormalizeNewLines(content); + } + + return new StringSourceDocument(content, encoding ?? Encoding.UTF8, properties); } private static string NormalizeNewLines(string content) diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Properties/AssemblyInfo.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Properties/AssemblyInfo.cs index 3a2cadef34..576c4e4e44 100644 --- a/test/Microsoft.AspNetCore.Razor.Test.Common/Properties/AssemblyInfo.cs +++ b/test/Microsoft.AspNetCore.Razor.Test.Common/Properties/AssemblyInfo.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.Runtime.CompilerServices; +[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.Razor.Extensions.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [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")] diff --git a/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X.csproj b/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X.csproj index 0fe0b6a3fc..1562a234c3 100644 --- a/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X.csproj +++ b/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X.csproj @@ -1,7 +1,7 @@  - $(StandardTestTfms) + netcoreapp2.1;netcoreapp2.0;net461 true diff --git a/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Mvc.Razor/RazorPage.cs b/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Mvc.Razor/RazorPage.cs index 7666a63722..2b7b7450cd 100644 --- a/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Mvc.Razor/RazorPage.cs +++ b/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Mvc.Razor/RazorPage.cs @@ -1,6 +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.Threading.Tasks; +using Microsoft.AspNetCore.Html; + namespace Microsoft.AspNetCore.Mvc.Razor { public abstract class RazorPage : RazorPageBase @@ -16,5 +19,30 @@ namespace Microsoft.AspNetCore.Mvc.Razor public override void EnsureRenderedBodyOrSections() { } + + protected virtual IHtmlContent RenderBody() + { + return null; + } + + public HtmlString RenderSection(string name) + { + return null; + } + + public HtmlString RenderSection(string name, bool required) + { + return null; + } + + public Task RenderSectionAsync(string name) + { + return null; + } + + public Task RenderSectionAsync(string name, bool required) + { + return null; + } } } diff --git a/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Test.MvcShim.csproj b/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Test.MvcShim.csproj index 0fe0b6a3fc..1562a234c3 100644 --- a/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Test.MvcShim.csproj +++ b/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Test.MvcShim.csproj @@ -1,7 +1,7 @@  - $(StandardTestTfms) + netcoreapp2.1;netcoreapp2.0;net461 true diff --git a/test/Microsoft.AspNetCore.Razor.Test/Microsoft.AspNetCore.Razor.Test.csproj b/test/Microsoft.AspNetCore.Razor.Test/Microsoft.AspNetCore.Razor.Test.csproj new file mode 100644 index 0000000000..b178b1b2c2 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Test/Microsoft.AspNetCore.Razor.Test.csproj @@ -0,0 +1,29 @@ + + + + $(StandardTestTfms) + $(DefaultItemExcludes);TestFiles\**\* + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/Microsoft.AspNetCore.Razor.Runtime.Test/TagHelpers/DefaultTagHelperContentTest.cs b/test/Microsoft.AspNetCore.Razor.Test/TagHelpers/DefaultTagHelperContentTest.cs similarity index 100% rename from test/Microsoft.AspNetCore.Razor.Runtime.Test/TagHelpers/DefaultTagHelperContentTest.cs rename to test/Microsoft.AspNetCore.Razor.Test/TagHelpers/DefaultTagHelperContentTest.cs diff --git a/test/Microsoft.AspNetCore.Razor.Runtime.Test/TagHelpers/NullHtmlEncoderTest.cs b/test/Microsoft.AspNetCore.Razor.Test/TagHelpers/NullHtmlEncoderTest.cs similarity index 100% rename from test/Microsoft.AspNetCore.Razor.Runtime.Test/TagHelpers/NullHtmlEncoderTest.cs rename to test/Microsoft.AspNetCore.Razor.Test/TagHelpers/NullHtmlEncoderTest.cs diff --git a/test/Microsoft.AspNetCore.Razor.Runtime.Test/TagHelpers/ReadOnlyTagHelperAttributeListTest.cs b/test/Microsoft.AspNetCore.Razor.Test/TagHelpers/ReadOnlyTagHelperAttributeListTest.cs similarity index 100% rename from test/Microsoft.AspNetCore.Razor.Runtime.Test/TagHelpers/ReadOnlyTagHelperAttributeListTest.cs rename to test/Microsoft.AspNetCore.Razor.Test/TagHelpers/ReadOnlyTagHelperAttributeListTest.cs diff --git a/test/Microsoft.AspNetCore.Razor.Runtime.Test/TagHelpers/TagHelperAttributeListTest.cs b/test/Microsoft.AspNetCore.Razor.Test/TagHelpers/TagHelperAttributeListTest.cs similarity index 100% rename from test/Microsoft.AspNetCore.Razor.Runtime.Test/TagHelpers/TagHelperAttributeListTest.cs rename to test/Microsoft.AspNetCore.Razor.Test/TagHelpers/TagHelperAttributeListTest.cs diff --git a/test/Microsoft.AspNetCore.Razor.Runtime.Test/TagHelpers/TagHelperContextTest.cs b/test/Microsoft.AspNetCore.Razor.Test/TagHelpers/TagHelperContextTest.cs similarity index 100% rename from test/Microsoft.AspNetCore.Razor.Runtime.Test/TagHelpers/TagHelperContextTest.cs rename to test/Microsoft.AspNetCore.Razor.Test/TagHelpers/TagHelperContextTest.cs diff --git a/test/Microsoft.AspNetCore.Razor.Runtime.Test/TagHelpers/TagHelperOutputTest.cs b/test/Microsoft.AspNetCore.Razor.Test/TagHelpers/TagHelperOutputTest.cs similarity index 96% rename from test/Microsoft.AspNetCore.Razor.Runtime.Test/TagHelpers/TagHelperOutputTest.cs rename to test/Microsoft.AspNetCore.Razor.Test/TagHelpers/TagHelperOutputTest.cs index 9d203102bd..df33c776a6 100644 --- a/test/Microsoft.AspNetCore.Razor.Runtime.Test/TagHelpers/TagHelperOutputTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Test/TagHelpers/TagHelperOutputTest.cs @@ -7,7 +7,6 @@ using System.IO; using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNetCore.Html; -using Microsoft.AspNetCore.Razor.Runtime.TagHelpers; using Microsoft.AspNetCore.Razor.TagHelpers.Testing; using Microsoft.Extensions.WebEncoders.Testing; using Xunit; @@ -1037,15 +1036,6 @@ namespace Microsoft.AspNetCore.Razor.TagHelpers { // Arrange var writer = new StringWriter(); - var tagHelperExecutionContext = new TagHelperExecutionContext( - tagName: output.TagName, - tagMode: output.TagMode, - items: new Dictionary(), - uniqueId: string.Empty, - executeChildContentAsync: () => Task.FromResult(result: true), - startTagHelperWritingScope: _ => { }, - endTagHelperWritingScope: () => new DefaultTagHelperContent()); - tagHelperExecutionContext.Output = output; var testEncoder = new HtmlTestEncoder(); // Act @@ -1067,16 +1057,6 @@ namespace Microsoft.AspNetCore.Razor.TagHelpers var buffer = new HtmlContentBuilder(); - var tagHelperExecutionContext = new TagHelperExecutionContext( - tagName: output.TagName, - tagMode: output.TagMode, - items: new Dictionary(), - uniqueId: string.Empty, - executeChildContentAsync: () => Task.FromResult(result: true), - startTagHelperWritingScope: _ => { }, - endTagHelperWritingScope: () => new DefaultTagHelperContent()); - tagHelperExecutionContext.Output = output; - // Act ((IHtmlContentContainer)output).CopyTo(buffer); @@ -1097,16 +1077,6 @@ namespace Microsoft.AspNetCore.Razor.TagHelpers var buffer = new HtmlContentBuilder(); - var tagHelperExecutionContext = new TagHelperExecutionContext( - tagName: output.TagName, - tagMode: output.TagMode, - items: new Dictionary(), - uniqueId: string.Empty, - executeChildContentAsync: () => Task.FromResult(result: true), - startTagHelperWritingScope: _ => { }, - endTagHelperWritingScope: () => new DefaultTagHelperContent()); - tagHelperExecutionContext.Output = output; - // Act ((IHtmlContentContainer)output).MoveTo(buffer); diff --git a/test/Microsoft.AspNetCore.Razor.Test/xunit.runner.json b/test/Microsoft.AspNetCore.Razor.Test/xunit.runner.json new file mode 100644 index 0000000000..d042e7bc20 Binary files /dev/null and b/test/Microsoft.AspNetCore.Razor.Test/xunit.runner.json differ diff --git a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common.csproj b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common.csproj new file mode 100644 index 0000000000..c32bd85577 --- /dev/null +++ b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common.csproj @@ -0,0 +1,16 @@ + + + + net46;$(StandardTestTfms) + + + + + + + + + + + + diff --git a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/TestRazorLanguageServices.cs b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/TestRazorLanguageServices.cs new file mode 100644 index 0000000000..fe33148ab0 --- /dev/null +++ b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/TestRazorLanguageServices.cs @@ -0,0 +1,48 @@ +// 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.Collections.Generic; +using System.Linq; +using Microsoft.CodeAnalysis.Razor; + +namespace Microsoft.CodeAnalysis.Host +{ + internal class TestRazorLanguageServices : HostLanguageServices + { + private readonly HostWorkspaceServices _workspaceServices; + private readonly IEnumerable _languageServices; + + public TestRazorLanguageServices(HostWorkspaceServices workspaceServices, IEnumerable languageServices) + { + if (workspaceServices == null) + { + throw new ArgumentNullException(nameof(workspaceServices)); + } + + if (languageServices == null) + { + throw new ArgumentNullException(nameof(languageServices)); + } + + _workspaceServices = workspaceServices; + _languageServices = languageServices; + } + + public override HostWorkspaceServices WorkspaceServices => _workspaceServices; + + public override string Language => RazorLanguage.Name; + + public override TLanguageService GetService() + { + var service = _languageServices.OfType().FirstOrDefault(); + + if (service == null) + { + throw new InvalidOperationException($"Test Razor language services not configured properly, missing language service '{typeof(TLanguageService).FullName}'."); + } + + return service; + } + } +} diff --git a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/TestServices.cs b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/TestServices.cs new file mode 100644 index 0000000000..a9e53de621 --- /dev/null +++ b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/TestServices.cs @@ -0,0 +1,47 @@ +// 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.Collections.Generic; +using System.Linq; + +namespace Microsoft.CodeAnalysis.Host +{ + public class TestServices : HostServices + { + private readonly IEnumerable _workspaceServices; + private readonly IEnumerable _razorLanguageServices; + + private TestServices(IEnumerable workspaceServices, IEnumerable razorLanguageServices) + { + if (workspaceServices == null) + { + throw new ArgumentNullException(nameof(workspaceServices)); + } + + if (razorLanguageServices == null) + { + throw new ArgumentNullException(nameof(razorLanguageServices)); + } + + _workspaceServices = workspaceServices; + _razorLanguageServices = razorLanguageServices; + } + + protected override HostWorkspaceServices CreateWorkspaceServices(Workspace workspace) + { + if (workspace == null) + { + throw new ArgumentNullException(nameof(workspace)); + } + + return new TestWorkspaceServices(this, _workspaceServices, _razorLanguageServices, workspace); + } + + public static HostServices Create(IEnumerable razorLanguageServices) + => Create(Enumerable.Empty(), razorLanguageServices); + + public static HostServices Create(IEnumerable workspaceServices, IEnumerable razorLanguageServices) + => new TestServices(workspaceServices, razorLanguageServices); + } +} diff --git a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/TestWorkspace.cs b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/TestWorkspace.cs new file mode 100644 index 0000000000..02dcab53d5 --- /dev/null +++ b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/TestWorkspace.cs @@ -0,0 +1,26 @@ +// 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 Microsoft.CodeAnalysis.Host; + +namespace Microsoft.CodeAnalysis +{ + public static class TestWorkspace + { + private static readonly object WorkspaceLock = new object(); + + public static Workspace Create(Action configure = null) => Create(services: null, configure: configure); + + public static Workspace Create(HostServices services, Action configure = null) + { + lock (WorkspaceLock) + { + var workspace = services == null ? new AdhocWorkspace() : new AdhocWorkspace(services); + configure?.Invoke(workspace); + + return workspace; + } + } + } +} diff --git a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/TestWorkspaceServices.cs b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/TestWorkspaceServices.cs new file mode 100644 index 0000000000..66d8f42f27 --- /dev/null +++ b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/TestWorkspaceServices.cs @@ -0,0 +1,85 @@ +// 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.Collections.Generic; +using System.Linq; +using Microsoft.CodeAnalysis.Razor; + +namespace Microsoft.CodeAnalysis.Host +{ + internal class TestWorkspaceServices : HostWorkspaceServices + { + private static readonly Workspace DefaultWorkspace = TestWorkspace.Create(); + + private readonly HostServices _hostServices; + private readonly IEnumerable _workspaceServices; + private readonly TestRazorLanguageServices _razorLanguageServices; + private readonly Workspace _workspace; + + public TestWorkspaceServices( + HostServices hostServices, + IEnumerable workspaceServices, + IEnumerable razorLanguageServices, + Workspace workspace) + { + if (hostServices == null) + { + throw new ArgumentNullException(nameof(hostServices)); + } + + if (workspaceServices == null) + { + throw new ArgumentNullException(nameof(workspaceServices)); + } + + if (razorLanguageServices == null) + { + throw new ArgumentNullException(nameof(razorLanguageServices)); + } + + if (workspace == null) + { + throw new ArgumentNullException(nameof(workspace)); + } + + _hostServices = hostServices; + _workspaceServices = workspaceServices; + _razorLanguageServices = new TestRazorLanguageServices(this, razorLanguageServices); + _workspace = workspace; + } + + public override HostServices HostServices => _hostServices; + + public override Workspace Workspace => _workspace; + + public override TWorkspaceService GetService() + { + var service = _workspaceServices.OfType().FirstOrDefault(); + + if (service == null) + { + // Fallback to default host services to resolve roslyn specific features. + service = DefaultWorkspace.Services.GetService(); + } + + return service; + } + + public override HostLanguageServices GetLanguageServices(string languageName) + { + if (languageName != RazorLanguage.Name) + { + throw new InvalidOperationException($"Test services do not support language service '{languageName}'. The only language services supported are '{RazorLanguage.Name}'."); + } + + return _razorLanguageServices; + } + + public override IEnumerable SupportedLanguages => new[] { RazorLanguage.Name }; + + public override bool IsSupported(string languageName) => languageName == RazorLanguage.Name; + + public override IEnumerable FindLanguageServices(MetadataFilter filter) => throw new NotImplementedException(); + } +} diff --git a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.csproj b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.csproj index bb5f05b323..d1ad2a9fab 100644 --- a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.csproj +++ b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.csproj @@ -13,7 +13,7 @@ - + diff --git a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/DefaultProjectSnapshotManagerTest.cs b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/DefaultProjectSnapshotManagerTest.cs index 53e4b476c0..eda57ab8ba 100644 --- a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/DefaultProjectSnapshotManagerTest.cs +++ b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/DefaultProjectSnapshotManagerTest.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { public DefaultProjectSnapshotManagerTest() { - Workspace = new AdhocWorkspace(); + Workspace = TestWorkspace.Create(); ProjectManager = new TestProjectSnapshotManager(Enumerable.Empty(), Workspace); } @@ -209,6 +209,38 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem Assert.False(ProjectManager.WorkerStarted); } + [Fact] + public void ProjectBuildComplete_KnownProject_NotifiesBackgroundWorker() + { + // Arrange + var project = Workspace.CurrentSolution.AddProject("Test", "Test", LanguageNames.CSharp); + ProjectManager.ProjectAdded(project); + ProjectManager.Reset(); + + // Act + ProjectManager.ProjectBuildComplete(project); + + // Assert + Assert.False(ProjectManager.ListenersNotified); + Assert.True(ProjectManager.WorkerStarted); + } + + [Fact] + public void ProjectBuildComplete_IgnoresUnknownProject() + { + // Arrange + var project = Workspace.CurrentSolution.AddProject("Test", "Test", LanguageNames.CSharp); + + // Act + ProjectManager.ProjectBuildComplete(project); + + // Assert + Assert.Empty(ProjectManager.Projects); + + Assert.False(ProjectManager.ListenersNotified); + Assert.False(ProjectManager.WorkerStarted); + } + [Fact] public void ProjectRemoved_RemovesProject_NotifiesListeners_DoesNotStartBackgroundWorker() { diff --git a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/DefaultProjectSnapshotTest.cs b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/DefaultProjectSnapshotTest.cs new file mode 100644 index 0000000000..2a72f46a6c --- /dev/null +++ b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/DefaultProjectSnapshotTest.cs @@ -0,0 +1,67 @@ +// 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.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.Language; +using Moq; +using Xunit; + +namespace Microsoft.CodeAnalysis.Razor.ProjectSystem +{ + public class DefaultProjectSnapshotTest + { + [Fact] + public void WithProjectChange_WithProject_CreatesSnapshot_UpdatesUnderlyingProject() + { + // Arrange + var underlyingProject = GetProject("Test1"); + var original = new DefaultProjectSnapshot(underlyingProject); + + var anotherProject = GetProject("Test1"); + + // Act + var snapshot = original.WithProjectChange(anotherProject); + + // Assert + Assert.Same(anotherProject, snapshot.UnderlyingProject); + Assert.Equal(original.ComputedVersion, snapshot.ComputedVersion); + Assert.Equal(original.Configuration, snapshot.Configuration); + } + + [Fact] + public void WithProjectChange_WithProject_CreatesSnapshot_UpdatesValues() + { + // Arrange + var underlyingProject = GetProject("Test1"); + var original = new DefaultProjectSnapshot(underlyingProject); + + var anotherProject = GetProject("Test1"); + var update = new ProjectSnapshotUpdateContext(anotherProject) + { + Configuration = Mock.Of(), + }; + + // Act + var snapshot = original.WithProjectChange(update); + + // Assert + Assert.Same(original.UnderlyingProject, snapshot.UnderlyingProject); + Assert.Equal(update.UnderlyingProject.Version, snapshot.ComputedVersion); + Assert.Same(update.Configuration, snapshot.Configuration); + } + + private Project GetProject(string name) + { + Project project = null; + TestWorkspace.Create(workspace => + { + project = workspace.AddProject(name, LanguageNames.CSharp); + }); + return project; + } + } +} diff --git a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/WorkspaceProjectSnapshotChangeTriggerTest.cs b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/WorkspaceProjectSnapshotChangeTriggerTest.cs index c458b5388c..293f6e8bf0 100644 --- a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/WorkspaceProjectSnapshotChangeTriggerTest.cs +++ b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/WorkspaceProjectSnapshotChangeTriggerTest.cs @@ -14,15 +14,31 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { public WorkspaceProjectSnapshotChangeTriggerTest() { - Workspace = new AdhocWorkspace(); - EmptySolution = Workspace.CurrentSolution.GetIsolatedSolution(); + Solution emptySolution = null; + Project project1 = null; + Project project2 = null; + Project project3 = null; + Solution solutionWithTwoProjects = null; + Solution solutionWithOneProject = null; - ProjectNumberOne = Workspace.CurrentSolution.AddProject("One", "One", LanguageNames.CSharp); - ProjectNumberTwo = ProjectNumberOne.Solution.AddProject("Two", "Two", LanguageNames.CSharp); - SolutionWithTwoProjects = ProjectNumberTwo.Solution; + Workspace = TestWorkspace.Create(ws => + { + emptySolution = ws.CurrentSolution.GetIsolatedSolution(); + project1 = ws.CurrentSolution.AddProject("One", "One", LanguageNames.CSharp); + project2 = project1.Solution.AddProject("Two", "Two", LanguageNames.CSharp); + solutionWithTwoProjects = project2.Solution; + + project3 = emptySolution.GetIsolatedSolution().AddProject("Three", "Three", LanguageNames.CSharp); + solutionWithOneProject = project3.Solution; + }); + + EmptySolution = emptySolution; + ProjectNumberOne = project1; + ProjectNumberTwo = project2; + ProjectNumberThree = project3; + SolutionWithTwoProjects = solutionWithTwoProjects; + SolutionWithOneProject = solutionWithOneProject; - ProjectNumberThree = EmptySolution.GetIsolatedSolution().AddProject("Three", "Three", LanguageNames.CSharp); - SolutionWithOneProject = ProjectNumberThree.Solution; } private Solution EmptySolution { get; } diff --git a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Editor/DefaultEditorSettingsManagerInternalTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultEditorSettingsManagerTest.cs similarity index 78% rename from test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Editor/DefaultEditorSettingsManagerInternalTest.cs rename to test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultEditorSettingsManagerTest.cs index d0a85604eb..750e40f60b 100644 --- a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Editor/DefaultEditorSettingsManagerInternalTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultEditorSettingsManagerTest.cs @@ -1,17 +1,18 @@ // 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.CodeAnalysis.Razor.Editor; using Xunit; -namespace Microsoft.CodeAnalysis.Razor.Editor +namespace Microsoft.VisualStudio.Editor.Razor { - public class DefaultEditorSettingsManagerInternalTest + public class DefaultEditorSettingsManagerTest : ForegroundDispatcherTestBase { [Fact] public void InitialSettingsAreDefault() { // Act - var manager = new DefaultEditorSettingsManagerInternal(); + var manager = new DefaultEditorSettingsManager(Dispatcher); // Assert Assert.Equal(EditorSettings.Default, manager.Current); @@ -21,7 +22,7 @@ namespace Microsoft.CodeAnalysis.Razor.Editor public void Update_TriggersChangedIfEditorSettingsAreDifferent() { // Arrange - var manager = new DefaultEditorSettingsManagerInternal(); + var manager = new DefaultEditorSettingsManager(Dispatcher); var called = false; manager.Changed += (caller, args) => { @@ -41,7 +42,7 @@ namespace Microsoft.CodeAnalysis.Razor.Editor public void Update_DoesNotTriggerChangedIfEditorSettingsAreSame() { // Arrange - var manager = new DefaultEditorSettingsManagerInternal(); + var manager = new DefaultEditorSettingsManager(Dispatcher); var called = false; manager.Changed += (caller, args) => { @@ -57,4 +58,4 @@ namespace Microsoft.CodeAnalysis.Razor.Editor Assert.Same(originalSettings, manager.Current); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTemplateEngineFactoryServiceTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultProjectEngineFactoryServiceTest.cs similarity index 85% rename from test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTemplateEngineFactoryServiceTest.cs rename to test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultProjectEngineFactoryServiceTest.cs index adeee1685c..74ede949ac 100644 --- a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTemplateEngineFactoryServiceTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultProjectEngineFactoryServiceTest.cs @@ -14,14 +14,19 @@ using MvcLatest = Microsoft.AspNetCore.Mvc.Razor.Extensions; namespace Microsoft.VisualStudio.Editor.Razor { - public class DefaultTemplateEngineFactoryServiceTest + public class DefaultProjectEngineFactoryServiceTest { - public DefaultTemplateEngineFactoryServiceTest() + public DefaultProjectEngineFactoryServiceTest() { - Workspace = new AdhocWorkspace(); + Project project = null; - var info = ProjectInfo.Create(ProjectId.CreateNewId("Test"), VersionStamp.Default, "Test", "Test", LanguageNames.CSharp, filePath: "/TestPath/SomePath/Test.csproj"); - Project = Workspace.CurrentSolution.AddProject(info).GetProject(info.Id); + Workspace = TestWorkspace.Create(workspace => + { + var info = ProjectInfo.Create(ProjectId.CreateNewId("Test"), VersionStamp.Default, "Test", "Test", LanguageNames.CSharp, filePath: "/TestPath/SomePath/Test.csproj"); + project = workspace.CurrentSolution.AddProject(info).GetProject(info.Id); + }); + + Project = project; } // We don't actually look at the project, we rely on the ProjectStateManager @@ -30,7 +35,7 @@ namespace Microsoft.VisualStudio.Editor.Razor public Workspace Workspace { get; } [Fact] - public void Create_CreatesDesignTimeTemplateEngine_ForLatest() + public void Create_CreatesTemplateEngine_ForLatest() { // Arrange var projectManager = new TestProjectSnapshotManager(Workspace); @@ -44,13 +49,12 @@ namespace Microsoft.VisualStudio.Editor.Razor new ProjectExtensibilityAssembly(new AssemblyIdentity("Microsoft.AspNetCore.Razor", new Version("2.0.0.0")))), }); - var factoryService = new DefaultTemplateEngineFactoryService(projectManager); + var factoryService = new DefaultProjectEngineFactoryService(projectManager); // Act var engine = factoryService.Create("/TestPath/SomePath/", b => { b.Features.Add(new MyCoolNewFeature()); - Assert.True(b.DesignTime); }); // Assert @@ -60,7 +64,7 @@ namespace Microsoft.VisualStudio.Editor.Razor } [Fact] - public void Create_CreatesDesignTimeTemplateEngine_ForVersion1_1() + public void Create_CreatesTemplateEngine_ForVersion1_1() { // Arrange var projectManager = new TestProjectSnapshotManager(Workspace); @@ -74,13 +78,12 @@ namespace Microsoft.VisualStudio.Editor.Razor new ProjectExtensibilityAssembly(new AssemblyIdentity("Microsoft.AspNetCore.Razor", new Version("1.1.3.0")))), }); - var factoryService = new DefaultTemplateEngineFactoryService(projectManager); + var factoryService = new DefaultProjectEngineFactoryService(projectManager); // Act var engine = factoryService.Create("/TestPath/SomePath/", b => { b.Features.Add(new MyCoolNewFeature()); - Assert.True(b.DesignTime); }); // Assert @@ -104,7 +107,7 @@ namespace Microsoft.VisualStudio.Editor.Razor new ProjectExtensibilityAssembly(new AssemblyIdentity("Microsoft.AspNetCore.Razor", new Version("1.0.0.0")))), }); - var factoryService = new DefaultTemplateEngineFactoryService(projectManager); + var factoryService = new DefaultProjectEngineFactoryService(projectManager); // Act var engine = factoryService.Create("/TestPath/SomePath/", b => @@ -133,13 +136,12 @@ namespace Microsoft.VisualStudio.Editor.Razor new ProjectExtensibilityAssembly(new AssemblyIdentity("Microsoft.AspNetCore.Razor", new Version("3.0.0.0")))), }); - var factoryService = new DefaultTemplateEngineFactoryService(projectManager); + var factoryService = new DefaultProjectEngineFactoryService(projectManager); // Act var engine = factoryService.Create("/TestPath/SomePath/", b => { b.Features.Add(new MyCoolNewFeature()); - Assert.True(b.DesignTime); }); // Assert @@ -154,13 +156,12 @@ namespace Microsoft.VisualStudio.Editor.Razor // Arrange var projectManager = new TestProjectSnapshotManager(Workspace); - var factoryService = new DefaultTemplateEngineFactoryService(projectManager); + var factoryService = new DefaultProjectEngineFactoryService(projectManager); // Act var engine = factoryService.Create("/TestPath/DifferentPath/", b => { b.Features.Add(new MyCoolNewFeature()); - Assert.True(b.DesignTime); }); // Assert @@ -176,13 +177,12 @@ namespace Microsoft.VisualStudio.Editor.Razor var projectManager = new TestProjectSnapshotManager(Workspace); projectManager.ProjectAdded(Project); - var factoryService = new DefaultTemplateEngineFactoryService(projectManager); + var factoryService = new DefaultProjectEngineFactoryService(projectManager); // Act var engine = factoryService.Create("/TestPath/DifferentPath/", b => { b.Features.Add(new MyCoolNewFeature()); - Assert.True(b.DesignTime); }); // Assert @@ -209,4 +209,4 @@ namespace Microsoft.VisualStudio.Editor.Razor } } } -} +} \ No newline at end of file diff --git a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTagHelperCompletionServiceTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTagHelperCompletionServiceTest.cs index 1422e44815..f885a7d290 100644 --- a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTagHelperCompletionServiceTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTagHelperCompletionServiceTest.cs @@ -995,7 +995,7 @@ namespace Microsoft.VisualStudio.Editor.Razor private static DefaultTagHelperCompletionService CreateTagHelperCompletionFactsService() { - var tagHelperFactsService = new DefaultTagHelperFactsServiceInternal(); + var tagHelperFactsService = new DefaultTagHelperFactsService(); var completionFactService = new DefaultTagHelperCompletionService(tagHelperFactsService); return completionFactService; @@ -1069,4 +1069,4 @@ namespace Microsoft.VisualStudio.Editor.Razor return completionContext; } } -} +} \ No newline at end of file diff --git a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/DefaultTagHelperFactsServiceInternalTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTagHelperFactsServiceTest.cs similarity index 94% rename from test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/DefaultTagHelperFactsServiceInternalTest.cs rename to test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTagHelperFactsServiceTest.cs index 5001398a36..2a73fa8830 100644 --- a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/DefaultTagHelperFactsServiceInternalTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTagHelperFactsServiceTest.cs @@ -6,9 +6,9 @@ using System.Linq; using Microsoft.AspNetCore.Razor.Language; using Xunit; -namespace Microsoft.CodeAnalysis.Razor +namespace Microsoft.VisualStudio.Editor.Razor { - public class DefaultTagHelperFactsServiceInternalTest + public class DefaultTagHelperFactsServiceTest { // Purposefully not thoroughly testing DefaultTagHelperFactsService.GetTagHelperBinding because it's a pass through // into TagHelperDescriptorProvider.GetTagHelperBinding. @@ -24,7 +24,7 @@ namespace Microsoft.CodeAnalysis.Razor .Build() }; var documentContext = TagHelperDocumentContext.Create(string.Empty, documentDescriptors); - var service = new DefaultTagHelperFactsServiceInternal(); + var service = new DefaultTagHelperFactsService(); // Act var binding = service.GetTagHelperBinding(documentContext, "!a", Enumerable.Empty>(), parentTag: null, parentIsTagHelper: false); @@ -66,7 +66,7 @@ namespace Microsoft.CodeAnalysis.Razor .Build(), }; var documentContext = TagHelperDocumentContext.Create(string.Empty, documentDescriptors); - var service = new DefaultTagHelperFactsServiceInternal(); + var service = new DefaultTagHelperFactsService(); var attributes = new[] { new KeyValuePair("asp-for", "Name") @@ -108,7 +108,7 @@ namespace Microsoft.CodeAnalysis.Razor documentDescriptors[0].BoundAttributes.Last() }; var documentContext = TagHelperDocumentContext.Create(string.Empty, documentDescriptors); - var service = new DefaultTagHelperFactsServiceInternal(); + var service = new DefaultTagHelperFactsService(); var binding = service.GetTagHelperBinding(documentContext, "a", Enumerable.Empty>(), parentTag: null, parentIsTagHelper: false); // Act @@ -143,7 +143,7 @@ namespace Microsoft.CodeAnalysis.Razor documentDescriptors[0].BoundAttributes.First() }; var documentContext = TagHelperDocumentContext.Create(string.Empty, documentDescriptors); - var service = new DefaultTagHelperFactsServiceInternal(); + var service = new DefaultTagHelperFactsService(); var binding = service.GetTagHelperBinding(documentContext, "input", Enumerable.Empty>(), parentTag: null, parentIsTagHelper: false); // Act @@ -164,7 +164,7 @@ namespace Microsoft.CodeAnalysis.Razor .Build() }; var documentContext = TagHelperDocumentContext.Create(string.Empty, documentDescriptors); - var service = new DefaultTagHelperFactsServiceInternal(); + var service = new DefaultTagHelperFactsService(); // Act var descriptors = service.GetTagHelpersGivenTag(documentContext, "!strong", parentTag: null); @@ -184,7 +184,7 @@ namespace Microsoft.CodeAnalysis.Razor .Build() }; var documentContext = TagHelperDocumentContext.Create(string.Empty, documentDescriptors); - var service = new DefaultTagHelperFactsServiceInternal(); + var service = new DefaultTagHelperFactsService(); // Act var descriptors = service.GetTagHelpersGivenTag(documentContext, "strong", "p"); @@ -217,7 +217,7 @@ namespace Microsoft.CodeAnalysis.Razor .Build() }; var documentContext = TagHelperDocumentContext.Create(string.Empty, documentDescriptors); - var service = new DefaultTagHelperFactsServiceInternal(); + var service = new DefaultTagHelperFactsService(); // Act var descriptors = service.GetTagHelpersGivenTag(documentContext, "a", "div"); @@ -244,7 +244,7 @@ namespace Microsoft.CodeAnalysis.Razor .Build() }; var documentContext = TagHelperDocumentContext.Create("th", documentDescriptors); - var service = new DefaultTagHelperFactsServiceInternal(); + var service = new DefaultTagHelperFactsService(); // Act var descriptors = service.GetTagHelpersGivenTag(documentContext, "thstrong", "div"); @@ -277,7 +277,7 @@ namespace Microsoft.CodeAnalysis.Razor .Build() }; var documentContext = TagHelperDocumentContext.Create(string.Empty, documentDescriptors); - var service = new DefaultTagHelperFactsServiceInternal(); + var service = new DefaultTagHelperFactsService(); // Act var descriptors = service.GetTagHelpersGivenTag(documentContext, "strong", "div"); @@ -297,7 +297,7 @@ namespace Microsoft.CodeAnalysis.Razor .Build() }; var documentContext = TagHelperDocumentContext.Create(string.Empty, documentDescriptors); - var service = new DefaultTagHelperFactsServiceInternal(); + var service = new DefaultTagHelperFactsService(); // Act var descriptors = service.GetTagHelpersGivenParent(documentContext, parentTag: null /* root */); @@ -322,7 +322,7 @@ namespace Microsoft.CodeAnalysis.Razor .Build() }; var documentContext = TagHelperDocumentContext.Create(string.Empty, documentDescriptors); - var service = new DefaultTagHelperFactsServiceInternal(); + var service = new DefaultTagHelperFactsService(); // Act var descriptors = service.GetTagHelpersGivenParent(documentContext, parentTag: null /* root */); @@ -343,7 +343,7 @@ namespace Microsoft.CodeAnalysis.Razor .Build() }; var documentContext = TagHelperDocumentContext.Create(string.Empty, documentDescriptors); - var service = new DefaultTagHelperFactsServiceInternal(); + var service = new DefaultTagHelperFactsService(); // Act var descriptors = service.GetTagHelpersGivenParent(documentContext, "p"); @@ -376,7 +376,7 @@ namespace Microsoft.CodeAnalysis.Razor .Build() }; var documentContext = TagHelperDocumentContext.Create(string.Empty, documentDescriptors); - var service = new DefaultTagHelperFactsServiceInternal(); + var service = new DefaultTagHelperFactsService(); // Act var descriptors = service.GetTagHelpersGivenParent(documentContext, "div"); @@ -385,4 +385,4 @@ namespace Microsoft.CodeAnalysis.Razor Assert.Equal(expectedDescriptors, descriptors, TagHelperDescriptorComparer.CaseSensitive); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTextBufferProviderTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTextBufferProviderTest.cs index 939f4e5e79..752a11ddd4 100644 --- a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTextBufferProviderTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTextBufferProviderTest.cs @@ -3,6 +3,7 @@ using System; using System.Collections.ObjectModel; +using System.Diagnostics; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Razor; using Microsoft.CodeAnalysis.Text; @@ -92,13 +93,16 @@ namespace Microsoft.VisualStudio.Editor.Razor private static Document CreateDocumentWithoutText() { - var project = ProjectInfo - .Create(ProjectId.CreateNewId(), VersionStamp.Default, "TestProject", "TestAssembly", LanguageNames.CSharp) - .WithFilePath("/TestProject.csproj"); - var workspace = new AdhocWorkspace(); - workspace.AddProject(project); - var documentInfo = DocumentInfo.Create(DocumentId.CreateNewId(project.Id), "Test.cshtml"); - var document = workspace.AddDocument(documentInfo); + Document document = null; + TestWorkspace.Create(workspace => + { + var project = ProjectInfo + .Create(ProjectId.CreateNewId(), VersionStamp.Default, "TestProject", "TestAssembly", LanguageNames.CSharp) + .WithFilePath("/TestProject.csproj"); + workspace.AddProject(project); + var documentInfo = DocumentInfo.Create(DocumentId.CreateNewId(project.Id), "Test.cshtml"); + document = workspace.AddDocument(documentInfo); + }); return document; } @@ -114,28 +118,36 @@ namespace Microsoft.VisualStudio.Editor.Razor private static ITextBuffer CreateTextBuffer() { var textBuffer = new Mock(); - textBuffer.Setup(buffer => buffer.Properties) + textBuffer + .Setup(buffer => buffer.Properties) .Returns(new PropertyCollection()); var textImage = new Mock(); var textVersion = new Mock(); var textBufferSnapshot = new Mock(); - textBufferSnapshot.Setup(snapshot => snapshot.TextImage) + textBufferSnapshot + .Setup(snapshot => snapshot.TextImage) .Returns(textImage.Object); - textBufferSnapshot.Setup(snapshot => snapshot.Length) + textBufferSnapshot + .Setup(snapshot => snapshot.Length) .Returns(0); - textBufferSnapshot.Setup(snapshot => snapshot.Version) + textBufferSnapshot + .Setup(snapshot => snapshot.Version) .Returns(textVersion.Object); - textBufferSnapshot.Setup(snapshot => snapshot.TextBuffer) + textBufferSnapshot + .Setup(snapshot => snapshot.TextBuffer) .Returns(() => textBuffer.Object); - textBuffer.Setup(buffer => buffer.CurrentSnapshot) + textBuffer + .Setup(buffer => buffer.CurrentSnapshot) .Returns(() => textBufferSnapshot.Object); var contentType = new Mock(); - contentType.Setup(type => type.IsOfType(It.IsAny())) + contentType + .Setup(type => type.IsOfType(It.IsAny())) .Returns(val => val == RazorLanguage.ContentType); - textBuffer.Setup(buffer => buffer.ContentType) + textBuffer + .Setup(buffer => buffer.ContentType) .Returns(contentType.Object); return textBuffer.Object; @@ -144,13 +156,15 @@ namespace Microsoft.VisualStudio.Editor.Razor private static IBufferGraphFactoryService CreateBufferGraphService(ITextBuffer buffer) { var bufferGraph = new Mock(); - bufferGraph.Setup(graph => graph.GetTextBuffers(It.IsAny>())) + bufferGraph + .Setup(graph => graph.GetTextBuffers(It.IsAny>())) .Returns>(predicate => predicate(buffer) ? new Collection() { buffer } : new Collection()); var bufferGraphService = new Mock(); - bufferGraphService.Setup(service => service.CreateBufferGraph(buffer)) + bufferGraphService + .Setup(service => service.CreateBufferGraph(buffer)) .Returns(bufferGraph.Object); return bufferGraphService.Object; } } -} +} \ No newline at end of file diff --git a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserIntegrationTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserIntegrationTest.cs index 3117f5b585..cbf27bfa29 100644 --- a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserIntegrationTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserIntegrationTest.cs @@ -526,34 +526,34 @@ namespace Microsoft.VisualStudio.Editor.Razor return new TestParserManager(parser); } - private static RazorTemplateEngineFactoryService CreateTemplateEngineFactory( + private static RazorProjectEngineFactoryService CreateTemplateEngineFactory( string path = TestLinePragmaFileName, IEnumerable tagHelpers = null) { - var engine = RazorEngine.CreateDesignTime(builder => - { - RazorExtensions.Register(builder); - - if (tagHelpers != null) - { - builder.AddTagHelpers(tagHelpers); - } - }); - // GetImports on RazorTemplateEngine will at least check that the item exists, so we need to pretend // that it does. var items = new List(); items.Add(new TestRazorProjectItem(path)); + var fileSystem = new TestRazorProjectFileSystem(items); - var project = new TestRazorProject(items); + var engine = RazorProjectEngine.Create(RazorConfiguration.Default, fileSystem, b => + { + RazorExtensions.Register(b); - var templateEngine = new RazorTemplateEngine(engine, project); - templateEngine.Options.DefaultImports = RazorSourceDocument.Create("@addTagHelper *, Test", "_TestImports.cshtml"); + if (tagHelpers != null) + { + b.AddTagHelpers(tagHelpers); + } - var templateEngineFactory = Mock.Of( - service => service.Create(It.IsAny(), It.IsAny>()) == templateEngine); + b.AddDefaultImports(new TestRazorProjectItem("_TestImports.cshtml") { Content = "@addTagHelper *, Test" }); + }); - return templateEngineFactory; + var factory = new Mock(); + factory + .Setup(f => f.Create(It.IsAny(), It.IsAny>())) + .Returns(engine); + + return factory.Object; } private async Task RunTypeKeywordTestAsync(string keyword) @@ -711,37 +711,9 @@ namespace Microsoft.VisualStudio.Editor.Razor } } - private class TestCompletionBroker : ICompletionBroker + private class TestCompletionBroker : VisualStudioCompletionBroker { - public ICompletionSession CreateCompletionSession(ITextView textView, ITrackingPoint triggerPoint, bool trackCaret) - { - throw new NotImplementedException(); - } - - public void DismissAllSessions(ITextView textView) - { - throw new NotImplementedException(); - } - - public ReadOnlyCollection GetSessions(ITextView textView) - { - throw new NotImplementedException(); - } - - public bool IsCompletionActive(ITextView textView) - { - return false; - } - - public ICompletionSession TriggerCompletion(ITextView textView) - { - throw new NotImplementedException(); - } - - public ICompletionSession TriggerCompletion(ITextView textView, ITrackingPoint triggerPoint, bool trackCaret) - { - throw new NotImplementedException(); - } + public override bool IsCompletionActive(ITextView textView) => false; } } } \ No newline at end of file diff --git a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserTest.cs index ecb42b2067..601796ad30 100644 --- a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserTest.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Linq; using System.Threading; using Microsoft.AspNetCore.Razor.Language; using Microsoft.CodeAnalysis.Razor; @@ -16,6 +15,15 @@ namespace Microsoft.VisualStudio.Editor.Razor { public class DefaultVisualStudioRazorParserTest : ForegroundDispatcherTestBase { + public DefaultVisualStudioRazorParserTest() + { + var engine = RazorProjectEngine.Create(RazorConfiguration.Default, RazorProjectFileSystem.Empty); + ProjectEngineFactory = Mock.Of( + f => f.Create(It.IsAny(), It.IsAny>()) == engine); + } + + private RazorProjectEngineFactoryService ProjectEngineFactory { get; } + private static VisualStudioDocumentTracker CreateDocumentTracker(bool isSupportedProject = true) { var documentTracker = Mock.Of(tracker => @@ -34,9 +42,9 @@ namespace Microsoft.VisualStudio.Editor.Razor var parser = new DefaultVisualStudioRazorParser( Dispatcher, CreateDocumentTracker(), - Mock.Of(), + Mock.Of(), new DefaultErrorReporter(), - Mock.Of()); + Mock.Of()); parser.Dispose(); // Act & Assert @@ -50,9 +58,9 @@ namespace Microsoft.VisualStudio.Editor.Razor var parser = new DefaultVisualStudioRazorParser( Dispatcher, CreateDocumentTracker(), - Mock.Of(), + ProjectEngineFactory, new DefaultErrorReporter(), - Mock.Of()); + Mock.Of()); parser.Dispose(); // Act & Assert @@ -66,9 +74,9 @@ namespace Microsoft.VisualStudio.Editor.Razor var parser = new DefaultVisualStudioRazorParser( Dispatcher, CreateDocumentTracker(), - Mock.Of(), + ProjectEngineFactory, new DefaultErrorReporter(), - Mock.Of()); + Mock.Of()); parser.Dispose(); // Act & Assert @@ -82,9 +90,9 @@ namespace Microsoft.VisualStudio.Editor.Razor using (var parser = new DefaultVisualStudioRazorParser( Dispatcher, CreateDocumentTracker(), - Mock.Of(), + ProjectEngineFactory, new DefaultErrorReporter(), - Mock.Of())) + Mock.Of())) { var called = false; parser.DocumentStructureChanged += (sender, e) => called = true; @@ -110,9 +118,9 @@ namespace Microsoft.VisualStudio.Editor.Razor using (var parser = new DefaultVisualStudioRazorParser( Dispatcher, documentTracker, - Mock.Of(), + ProjectEngineFactory, new DefaultErrorReporter(), - Mock.Of())) + Mock.Of())) { var called = false; parser.DocumentStructureChanged += (sender, e) => called = true; @@ -139,9 +147,9 @@ namespace Microsoft.VisualStudio.Editor.Razor using (var parser = new DefaultVisualStudioRazorParser( Dispatcher, CreateDocumentTracker(), - Mock.Of(), + ProjectEngineFactory, new DefaultErrorReporter(), - Mock.Of()) + Mock.Of()) { BlockBackgroundIdleWork = new ManualResetEventSlim(), IdleDelay = TimeSpan.FromSeconds(5) @@ -169,9 +177,9 @@ namespace Microsoft.VisualStudio.Editor.Razor using (var parser = new DefaultVisualStudioRazorParser( Dispatcher, CreateDocumentTracker(), - Mock.Of(), + ProjectEngineFactory, new DefaultErrorReporter(), - Mock.Of()) + Mock.Of()) { BlockBackgroundIdleWork = new ManualResetEventSlim(), IdleDelay = TimeSpan.FromSeconds(5) @@ -198,9 +206,9 @@ namespace Microsoft.VisualStudio.Editor.Razor using (var parser = new DefaultVisualStudioRazorParser( Dispatcher, CreateDocumentTracker(), - Mock.Of(), + ProjectEngineFactory, new DefaultErrorReporter(), - Mock.Of())) + Mock.Of())) { parser.StartParser(); @@ -222,9 +230,9 @@ namespace Microsoft.VisualStudio.Editor.Razor using (var parser = new DefaultVisualStudioRazorParser( Dispatcher, documentTracker, - Mock.Of(), + ProjectEngineFactory, new DefaultErrorReporter(), - Mock.Of())) + Mock.Of())) { // Act parser.StartParser(); @@ -242,9 +250,9 @@ namespace Microsoft.VisualStudio.Editor.Razor using (var parser = new DefaultVisualStudioRazorParser( Dispatcher, CreateDocumentTracker(isSupportedProject: true), - Mock.Of(), + ProjectEngineFactory, new DefaultErrorReporter(), - Mock.Of())) + Mock.Of())) { // Act var result = parser.TryReinitializeParser(); @@ -261,9 +269,9 @@ namespace Microsoft.VisualStudio.Editor.Razor using (var parser = new DefaultVisualStudioRazorParser( Dispatcher, CreateDocumentTracker(isSupportedProject: false), - Mock.Of(), + ProjectEngineFactory, new DefaultErrorReporter(), - Mock.Of())) + Mock.Of())) { // Act var result = parser.TryReinitializeParser(); diff --git a/test/Microsoft.VisualStudio.Editor.Razor.Test/Microsoft.VisualStudio.Editor.Razor.Test.csproj b/test/Microsoft.VisualStudio.Editor.Razor.Test/Microsoft.VisualStudio.Editor.Razor.Test.csproj index 7e010cf2a9..6f4876aec0 100644 --- a/test/Microsoft.VisualStudio.Editor.Razor.Test/Microsoft.VisualStudio.Editor.Razor.Test.csproj +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/Microsoft.VisualStudio.Editor.Razor.Test.csproj @@ -9,6 +9,7 @@ + diff --git a/test/Microsoft.VisualStudio.Editor.Razor.Test/RazorDirectiveCompletionProviderTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/RazorDirectiveCompletionProviderTest.cs index c30b573b2a..1e5f5627ce 100644 --- a/test/Microsoft.VisualStudio.Editor.Razor.Test/RazorDirectiveCompletionProviderTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/RazorDirectiveCompletionProviderTest.cs @@ -108,13 +108,16 @@ namespace Microsoft.VisualStudio.Editor.Razor public async Task ProvideCompletionAsync_DoesNotProvideCompletionsForDocumentWithoutPath() { // Arrange - var project = ProjectInfo + Document document = null; + TestWorkspace.Create(workspace => + { + var project = ProjectInfo .Create(ProjectId.CreateNewId(), VersionStamp.Default, "TestProject", "TestAssembly", LanguageNames.CSharp) .WithFilePath("/TestProject.csproj"); - var workspace = new AdhocWorkspace(); - workspace.AddProject(project); - var documentInfo = DocumentInfo.Create(DocumentId.CreateNewId(project.Id), "Test.cshtml"); - var document = workspace.AddDocument(documentInfo); + workspace.AddProject(project); + var documentInfo = DocumentInfo.Create(DocumentId.CreateNewId(project.Id), "Test.cshtml"); + document = workspace.AddDocument(documentInfo); + }); var codeDocumentProvider = new Mock(MockBehavior.Strict); var completionProvider = new FailOnGetCompletionsProvider(new Lazy(() => codeDocumentProvider.Object)); @@ -325,14 +328,17 @@ namespace Microsoft.VisualStudio.Editor.Razor private static Document CreateDocument() { - var project = ProjectInfo + Document document = null; + TestWorkspace.Create(workspace => + { + var project = ProjectInfo .Create(ProjectId.CreateNewId(), VersionStamp.Default, "TestProject", "TestAssembly", LanguageNames.CSharp) .WithFilePath("/TestProject.csproj"); - var workspace = new AdhocWorkspace(); - workspace.AddProject(project); - var documentInfo = DocumentInfo.Create(DocumentId.CreateNewId(project.Id), "Test.cshtml"); - var document = workspace.AddDocument(documentInfo); - document = document.WithFilePath("Test.cshtml"); + workspace.AddProject(project); + var documentInfo = DocumentInfo.Create(DocumentId.CreateNewId(project.Id), "Test.cshtml"); + document = workspace.AddDocument(documentInfo); + document = document.WithFilePath("Test.cshtml"); + }); return document; } @@ -369,4 +375,4 @@ namespace Microsoft.VisualStudio.Editor.Razor } } } -} +} \ No newline at end of file diff --git a/test/Microsoft.VisualStudio.Editor.Razor.Test/RazorSyntaxTreePartialParserTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/RazorSyntaxTreePartialParserTest.cs index 544f74a91d..8f48be572a 100644 --- a/test/Microsoft.VisualStudio.Editor.Razor.Test/RazorSyntaxTreePartialParserTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/RazorSyntaxTreePartialParserTest.cs @@ -597,7 +597,7 @@ namespace Microsoft.VisualStudio.Editor.Razor var items = new List(); items.Add(new TestRazorProjectItem(path)); - var project = new TestRazorProject(items); + var project = new TestRazorProjectFileSystem(items); var templateEngine = new RazorTemplateEngine(engine, project); templateEngine.Options.DefaultImports = RazorSourceDocument.Create("@addTagHelper *, Test", "_TestImports.cshtml"); diff --git a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/DefaultVisualStudioWorkspaceAccessorTest.cs b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/DefaultVisualStudioWorkspaceAccessorTest.cs new file mode 100644 index 0000000000..033a825a8a --- /dev/null +++ b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/DefaultVisualStudioWorkspaceAccessorTest.cs @@ -0,0 +1,150 @@ +// 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.Collections.ObjectModel; +using Microsoft.CodeAnalysis; +using Microsoft.VisualStudio.Editor.Razor; +using Microsoft.VisualStudio.Text; +using Microsoft.VisualStudio.Text.Projection; +using Moq; +using Xunit; + +namespace Microsoft.VisualStudio.LanguageServices.Razor +{ + public class DefaultVisualStudioWorkspaceAccessorTest + { + [Fact] + public void TryGetWorkspace_CanGetWorkspaceFromProjectionBuffersOnly() + { + // Arrange + var textBuffer = Mock.Of(); + var workspaceAccessor = new TestWorkspaceAccessor(true, false); + + // Act + var result = workspaceAccessor.TryGetWorkspace(textBuffer, out var workspace); + + // Assert + Assert.True(result); + } + + [Fact] + public void TryGetWorkspace_CanGetWorkspaceFromBuffersInHierarchyOnly() + { + // Arrange + var textBuffer = Mock.Of(); + var workspaceAccessor = new TestWorkspaceAccessor(false, true); + + // Act + var result = workspaceAccessor.TryGetWorkspace(textBuffer, out var workspace); + + // Assert + Assert.True(result); + } + + [Fact] + public void TryGetWorkspace_CanGetWorkspaceFromBuffersInHierarchyOrProjectionBuffers() + { + // Arrange + var textBuffer = Mock.Of(); + var workspaceAccessor = new TestWorkspaceAccessor(true, true); + + // Act + var result = workspaceAccessor.TryGetWorkspace(textBuffer, out var workspace); + + // Assert + Assert.True(result); + } + + [Fact] + public void TryGetWorkspaceFromProjectionBuffer_NoProjectionBuffer_ReturnsFalse() + { + // Arrange + var bufferGraph = new Mock(); + bufferGraph.Setup(graph => graph.GetTextBuffers(It.IsAny>())) + .Returns>(predicate => new Collection()); + var bufferGraphService = new Mock(); + bufferGraphService.Setup(service => service.CreateBufferGraph(It.IsAny())) + .Returns(bufferGraph.Object); + var workspaceAccessor = new DefaultVisualStudioWorkspaceAccessor(bufferGraphService.Object, Mock.Of(), TestWorkspace.Create()); + var textBuffer = Mock.Of(); + + // Act + var result = workspaceAccessor.TryGetWorkspaceFromProjectionBuffer(textBuffer, out var workspace); + + // Assert + Assert.False(result); + } + + [Fact] + public void TryGetWorkspaceFromHostProject_NoHostProject_ReturnsFalse() + { + // Arrange + var workspaceAccessor = new DefaultVisualStudioWorkspaceAccessor(Mock.Of(), Mock.Of(), TestWorkspace.Create()); + var textBuffer = Mock.Of(); + + // Act + var result = workspaceAccessor.TryGetWorkspaceFromHostProject(textBuffer, out var workspace); + + // Assert + Assert.False(result); + } + + [Fact] + public void TryGetWorkspaceFromHostProject_HasHostProject_ReturnsTrueWithDefaultWorkspace() + { + // Arrange + var textBuffer = Mock.Of(); + var projectService = Mock.Of(service => service.GetHostProject(textBuffer) == new object()); + var defaultWorkspace = TestWorkspace.Create(); + var workspaceAccessor = new DefaultVisualStudioWorkspaceAccessor(Mock.Of(), projectService, defaultWorkspace); + + // Act + var result = workspaceAccessor.TryGetWorkspaceFromHostProject(textBuffer, out var workspace); + + // Assert + Assert.True(result); + Assert.Same(defaultWorkspace, workspace); + } + + private class TestWorkspaceAccessor : DefaultVisualStudioWorkspaceAccessor + { + private readonly bool _canGetWorkspaceFromProjectionBuffer; + private readonly bool _canGetWorkspaceFromHostProject; + + internal TestWorkspaceAccessor(bool canGetWorkspaceFromProjectionBuffer, bool canGetWorkspaceFromHostProject) : + base( + Mock.Of(), + Mock.Of(), + TestWorkspace.Create()) + { + _canGetWorkspaceFromProjectionBuffer = canGetWorkspaceFromProjectionBuffer; + _canGetWorkspaceFromHostProject = canGetWorkspaceFromHostProject; + } + + internal override bool TryGetWorkspaceFromProjectionBuffer(ITextBuffer textBuffer, out Workspace workspace) + { + if (_canGetWorkspaceFromProjectionBuffer) + { + workspace = TestWorkspace.Create(); + return true; + } + + workspace = null; + return false; + } + + internal override bool TryGetWorkspaceFromHostProject(ITextBuffer textBuffer, out Workspace workspace) + { + if (_canGetWorkspaceFromHostProject) + { + workspace = TestWorkspace.Create(); + return true; + } + + workspace = null; + return false; + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Editor/DefaultRazorEditorFactoryServiceTest.cs b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Editor/DefaultRazorEditorFactoryServiceTest.cs index f92620cec7..8bff7a066a 100644 --- a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Editor/DefaultRazorEditorFactoryServiceTest.cs +++ b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Editor/DefaultRazorEditorFactoryServiceTest.cs @@ -1,14 +1,15 @@ // 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.CodeAnalysis; +using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Razor; -using Microsoft.VisualStudio.Editor.Razor; using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Utilities; using Moq; using Xunit; -namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor +namespace Microsoft.VisualStudio.Editor.Razor { public class DefaultRazorEditorFactoryServiceTest { @@ -48,7 +49,25 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor } [Fact] - public void EnsureTextBufferInitialized_StoresTracker() + public void TryInitializeTextBuffer_WorkspaceAccessorCanNotAccessWorkspace_ReturnsFalse() + { + // Arrange + Workspace workspace = null; + var workspaceAccessor = new Mock(); + workspaceAccessor.Setup(provider => provider.TryGetWorkspace(It.IsAny(), out workspace)) + .Returns(false); + var factoryService = new DefaultRazorEditorFactoryService(workspaceAccessor.Object); + var textBuffer = Mock.Of(b => b.ContentType == RazorContentType && b.Properties == new PropertyCollection()); + + // Act + var result = factoryService.TryInitializeTextBuffer(textBuffer); + + // Assert + Assert.False(result); + } + + [Fact] + public void TryInitializeTextBuffer_StoresTracker_ReturnsTrue() { // Arrange var expectedDocumentTracker = Mock.Of(); @@ -56,29 +75,31 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor var textBuffer = Mock.Of(b => b.ContentType == RazorContentType && b.Properties == new PropertyCollection()); // Act - factoryService.EnsureTextBufferInitialized(textBuffer); + var result = factoryService.TryInitializeTextBuffer(textBuffer); // Assert + Assert.True(result); Assert.True(textBuffer.Properties.TryGetProperty(typeof(VisualStudioDocumentTracker), out VisualStudioDocumentTracker documentTracker)); Assert.Same(expectedDocumentTracker, documentTracker); } [Fact] - public void EnsureTextBufferInitialized_OnlyStoresTrackerOnTextBufferOnce() + public void TryInitializeTextBuffer_OnlyStoresTrackerOnTextBufferOnce_ReturnsTrue() { // Arrange var factoryService = CreateFactoryService(); var textBuffer = Mock.Of(b => b.ContentType == RazorContentType && b.Properties == new PropertyCollection()); - factoryService.EnsureTextBufferInitialized(textBuffer); + factoryService.TryInitializeTextBuffer(textBuffer); var expectedDocumentTracker = textBuffer.Properties[typeof(VisualStudioDocumentTracker)]; // Create a second factory service so it generates a different tracker factoryService = CreateFactoryService(); // Act - factoryService.EnsureTextBufferInitialized(textBuffer); + var result = factoryService.TryInitializeTextBuffer(textBuffer); // Assert + Assert.True(result); Assert.True(textBuffer.Properties.TryGetProperty(typeof(VisualStudioDocumentTracker), out VisualStudioDocumentTracker documentTracker)); Assert.Same(expectedDocumentTracker, documentTracker); } @@ -115,7 +136,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor } [Fact] - public void EnsureTextBufferInitialized_StoresParser() + public void TryInitializeTextBuffer_StoresParser_ReturnsTrue() { // Arrange var expectedParser = Mock.Of(); @@ -123,29 +144,31 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor var textBuffer = Mock.Of(b => b.ContentType == RazorContentType && b.Properties == new PropertyCollection()); // Act - factoryService.EnsureTextBufferInitialized(textBuffer); + var result = factoryService.TryInitializeTextBuffer(textBuffer); // Assert + Assert.True(result); Assert.True(textBuffer.Properties.TryGetProperty(typeof(VisualStudioRazorParser), out VisualStudioRazorParser parser)); Assert.Same(expectedParser, parser); } [Fact] - public void EnsureTextBufferInitialized_OnlyStoresParserOnTextBufferOnce() + public void TryInitializeTextBuffer_OnlyStoresParserOnTextBufferOnce_ReturnsTrue() { // Arrange var factoryService = CreateFactoryService(); var textBuffer = Mock.Of(b => b.ContentType == RazorContentType && b.Properties == new PropertyCollection()); - factoryService.EnsureTextBufferInitialized(textBuffer); + factoryService.TryInitializeTextBuffer(textBuffer); var expectedParser = textBuffer.Properties[typeof(VisualStudioRazorParser)]; // Create a second factory service so it generates a different parser factoryService = CreateFactoryService(); // Act - factoryService.EnsureTextBufferInitialized(textBuffer); + var result = factoryService.TryInitializeTextBuffer(textBuffer); // Assert + Assert.True(result); Assert.True(textBuffer.Properties.TryGetProperty(typeof(VisualStudioRazorParser), out VisualStudioRazorParser parser)); Assert.Same(expectedParser, parser); } @@ -182,7 +205,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor } [Fact] - public void EnsureTextBufferInitialized_StoresSmartIndenter() + public void TryInitializeTextBuffer_StoresSmartIndenter_ReturnsTrue() { // Arrange var expectedSmartIndenter = Mock.Of(); @@ -190,29 +213,31 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor var textBuffer = Mock.Of(b => b.ContentType == RazorContentType && b.Properties == new PropertyCollection()); // Act - factoryService.EnsureTextBufferInitialized(textBuffer); + var result = factoryService.TryInitializeTextBuffer(textBuffer); // Assert + Assert.True(result); Assert.True(textBuffer.Properties.TryGetProperty(typeof(BraceSmartIndenter), out BraceSmartIndenter smartIndenter)); Assert.Same(expectedSmartIndenter, smartIndenter); } [Fact] - public void EnsureTextBufferInitialized_OnlyStoresSmartIndenterOnTextBufferOnce() + public void TryInitializeTextBuffer_OnlyStoresSmartIndenterOnTextBufferOnce_ReturnsTrue() { // Arrange var factoryService = CreateFactoryService(); var textBuffer = Mock.Of(b => b.ContentType == RazorContentType && b.Properties == new PropertyCollection()); - factoryService.EnsureTextBufferInitialized(textBuffer); + factoryService.TryInitializeTextBuffer(textBuffer); var expectedSmartIndenter = textBuffer.Properties[typeof(BraceSmartIndenter)]; // Create a second factory service so it generates a different smart indenter factoryService = CreateFactoryService(); // Act - factoryService.EnsureTextBufferInitialized(textBuffer); + var result = factoryService.TryInitializeTextBuffer(textBuffer); // Assert + Assert.True(result); Assert.True(textBuffer.Properties.TryGetProperty(typeof(BraceSmartIndenter), out BraceSmartIndenter smartIndenter)); Assert.Same(expectedSmartIndenter, smartIndenter); } @@ -229,9 +254,22 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor var documentTrackerFactory = Mock.Of(f => f.Create(It.IsAny()) == documentTracker); var parserFactory = Mock.Of(f => f.Create(It.IsAny()) == parser); var smartIndenterFactory = Mock.Of(f => f.Create(It.IsAny()) == smartIndenter); - var factoryService = new DefaultRazorEditorFactoryService(documentTrackerFactory, parserFactory, smartIndenterFactory); + + var services = TestServices.Create(new ILanguageService[] + { + documentTrackerFactory, + parserFactory, + smartIndenterFactory + }); + + var workspace = TestWorkspace.Create(services); + var workspaceAccessor = new Mock(); + workspaceAccessor.Setup(p => p.TryGetWorkspace(It.IsAny(), out workspace)) + .Returns(true); + + var factoryService = new DefaultRazorEditorFactoryService(workspaceAccessor.Object); return factoryService; } } -} +} \ No newline at end of file diff --git a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Editor/DefaultVisualStudioDocumentTrackerTest.cs b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Editor/DefaultVisualStudioDocumentTrackerTest.cs index 9a6e4552fe..3185ec2a1c 100644 --- a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Editor/DefaultVisualStudioDocumentTrackerTest.cs +++ b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Editor/DefaultVisualStudioDocumentTrackerTest.cs @@ -6,6 +6,7 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Razor; using Microsoft.CodeAnalysis.Razor.Editor; using Microsoft.CodeAnalysis.Razor.ProjectSystem; +using Microsoft.VisualStudio.Editor.Razor; using Microsoft.VisualStudio.Shell.Interop; using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text.Editor; @@ -26,13 +27,13 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor private ProjectSnapshotManager ProjectManager => Mock.Of(p => p.Projects == new List()); private TextBufferProjectService ProjectService => Mock.Of( - s => s.GetHierarchy(It.IsAny()) == Mock.Of() && + s => s.GetHostProject(It.IsAny()) == Mock.Of() && s.IsSupportedProject(It.IsAny()) == true && s.GetProjectPath(It.IsAny()) == "C:/Some/Path/TestProject.csproj"); - private EditorSettingsManagerInternal EditorSettingsManager => new DefaultEditorSettingsManagerInternal(); + private EditorSettingsManager EditorSettingsManager => new DefaultEditorSettingsManager(Mock.Of()); - private Workspace Workspace => new AdhocWorkspace(); + private Workspace Workspace => TestWorkspace.Create(); [Fact] public void EditorSettingsManager_Changed_TriggersContextChanged() diff --git a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Editor/RazorTextViewConnectionListenerTest.cs b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Editor/RazorTextViewConnectionListenerTest.cs index 2b727a2139..2cae9c17b1 100644 --- a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Editor/RazorTextViewConnectionListenerTest.cs +++ b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Editor/RazorTextViewConnectionListenerTest.cs @@ -22,13 +22,13 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor private ProjectSnapshotManager ProjectManager { get; } = Mock.Of(p => p.Projects == new List()); private TextBufferProjectService ProjectService { get; } = Mock.Of( - s => s.GetHierarchy(It.IsAny()) == Mock.Of() && + s => s.GetHostProject(It.IsAny()) == Mock.Of() && s.IsSupportedProject(It.IsAny()) == true && s.GetProjectPath(It.IsAny()) == "C:/Some/Path/TestProject.csproj"); - private EditorSettingsManagerInternal EditorSettingsManager => new DefaultEditorSettingsManagerInternal(); + private EditorSettingsManager EditorSettingsManager => new DefaultEditorSettingsManager(Mock.Of()); - private Workspace Workspace { get; } = new AdhocWorkspace(); + private Workspace Workspace { get; } = TestWorkspace.Create(); private IContentType RazorContentType { get; } = Mock.Of(c => c.IsOfType(RazorLanguage.ContentType) == true); diff --git a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Microsoft.VisualStudio.LanguageServices.Razor.Test.csproj b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Microsoft.VisualStudio.LanguageServices.Razor.Test.csproj index d182c95d31..09ab7e7662 100644 --- a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Microsoft.VisualStudio.LanguageServices.Razor.Test.csproj +++ b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Microsoft.VisualStudio.LanguageServices.Razor.Test.csproj @@ -21,6 +21,7 @@ + diff --git a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectSystem/DefaultProjectSnapshotWorkerTest.cs b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectSystem/DefaultProjectSnapshotWorkerTest.cs deleted file mode 100644 index 1ab2f64753..0000000000 --- a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectSystem/DefaultProjectSnapshotWorkerTest.cs +++ /dev/null @@ -1,53 +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.Threading; -using System.Threading.Tasks; -using Moq; -using Xunit; - -namespace Microsoft.CodeAnalysis.Razor.ProjectSystem -{ - public class DefaultProjectSnapshotWorkerTest : ForegroundDispatcherTestBase - { - public DefaultProjectSnapshotWorkerTest() - { - Project = new AdhocWorkspace().AddProject("Test1", LanguageNames.CSharp); - - CompletionSource = new TaskCompletionSource(); - ConfigurationFactory = Mock.Of(f => f.GetConfigurationAsync(It.IsAny(), default(CancellationToken)) == CompletionSource.Task); - } - - private Project Project { get; } - - private ProjectExtensibilityConfigurationFactory ConfigurationFactory { get; } - - private TaskCompletionSource CompletionSource { get; } - - [ForegroundFact] - public async Task ProcessUpdateAsync_DoesntBlockForegroundThread() - { - // Arrange - var worker = new DefaultProjectSnapshotWorker(Dispatcher, ConfigurationFactory); - - var context = new ProjectSnapshotUpdateContext(Project); - - var configuration = Mock.Of(); - - // Act 1 -- We want to verify that this doesn't block the main thread - var task = worker.ProcessUpdateAsync(context); - - // Assert 1 - // - // We haven't let the background task proceed yet, so this is still null. - Assert.Null(context.Configuration); - - // Act 2 - Ok let's go - CompletionSource.SetResult(configuration); - await task; - - // Assert 2 - Assert.Same(configuration, context.Configuration); - } - } -} diff --git a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectSystem/ProjectSnapshotWorkerQueueTest.cs b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectSystem/ProjectSnapshotWorkerQueueTest.cs index 7dc947f44e..f4129b8bd6 100644 --- a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectSystem/ProjectSnapshotWorkerQueueTest.cs +++ b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectSystem/ProjectSnapshotWorkerQueueTest.cs @@ -16,10 +16,17 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { public ProjectSnapshotWorkerQueueTest() { - Workspace = new AdhocWorkspace(); + Project project1 = null; + Project project2 = null; - Project1 = Workspace.CurrentSolution.AddProject("Test1", "Test1", LanguageNames.CSharp); - Project2 = Workspace.CurrentSolution.AddProject("Test2", "Test2", LanguageNames.CSharp); + Workspace = TestWorkspace.Create(workspace => + { + project1 = workspace.CurrentSolution.AddProject("Test1", "Test1", LanguageNames.CSharp); + project2 = workspace.CurrentSolution.AddProject("Test2", "Test2", LanguageNames.CSharp); + }); + + Project1 = project1; + Project2 = project2; } public Project Project1 { get; } diff --git a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TagHelperDescriptorSerializationTest.cs b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TagHelperDescriptorSerializationTest.cs index cb2d82a79a..4e37727804 100644 --- a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TagHelperDescriptorSerializationTest.cs +++ b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TagHelperDescriptorSerializationTest.cs @@ -88,8 +88,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor builder.AllowChildTag("allowed-child-one") .AddMetadata("foo", "bar") .AddDiagnostic(RazorDiagnostic.Create( - new RazorDiagnosticDescriptor("id", () => "Test Message 1", RazorDiagnosticSeverity.Error), new SourceSpan(null, 10, 20, 30, 40))) - .AddDiagnostic(RazorDiagnostic.Create(new RazorError("Test Message 2", 10, 20, 30, 40))); + new RazorDiagnosticDescriptor("id", () => "Test Message", RazorDiagnosticSeverity.Error), new SourceSpan(null, 10, 20, 30, 40))); }); // Act @@ -186,4 +185,4 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor return descriptor; } } -} +} \ No newline at end of file diff --git a/test/RazorPageGenerator.Test/RazorPageGeneratorTest.cs b/test/RazorPageGenerator.Test/RazorPageGeneratorTest.cs index 81465d9541..613df16b0c 100644 --- a/test/RazorPageGenerator.Test/RazorPageGeneratorTest.cs +++ b/test/RazorPageGenerator.Test/RazorPageGeneratorTest.cs @@ -35,9 +35,10 @@ namespace RazorPageGenerator.Test { // Arrange var projectDirectory = TestProject.GetProjectDirectory(GetType()); - var razorEngine = Program.CreateRazorEngine("Microsoft.AspNetCore.TestGenerated"); + var projectEngine = Program.CreateProjectEngine("Microsoft.AspNetCore.TestGenerated", projectDirectory); + // Act - var results = Program.MainCore(razorEngine, projectDirectory); + var results = Program.MainCore(projectEngine, projectDirectory); // Assert Assert.Collection(results, diff --git a/tooling/Microsoft.VisualStudio.RazorExtension/Microsoft.VisualStudio.RazorExtension.csproj b/tooling/Microsoft.VisualStudio.RazorExtension/Microsoft.VisualStudio.RazorExtension.csproj index 8dd9db4535..bcfa2e6662 100644 --- a/tooling/Microsoft.VisualStudio.RazorExtension/Microsoft.VisualStudio.RazorExtension.csproj +++ b/tooling/Microsoft.VisualStudio.RazorExtension/Microsoft.VisualStudio.RazorExtension.csproj @@ -42,10 +42,10 @@ v4.6 true true - true + false true true - false + true true @@ -263,6 +263,11 @@ + + + + +