diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Views/Shared/_Layout.cshtml b/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Views/Shared/_Layout.cshtml
index 560ffb88ce24..79f34bc21167 100644
--- a/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Views/Shared/_Layout.cshtml
+++ b/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Views/Shared/_Layout.cshtml
@@ -6,6 +6,7 @@
@ViewData["Title"] - Company.WebApplication1
+
diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Views/Shared/_Layout.cshtml.css b/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Views/Shared/_Layout.cshtml.css
new file mode 100644
index 000000000000..557867a54f99
--- /dev/null
+++ b/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Views/Shared/_Layout.cshtml.css
@@ -0,0 +1,51 @@
+/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
+for details on configuring this project to bundle and minify static web assets. */
+
+a.navbar-brand {
+ white-space: normal;
+ text-align: center;
+ word-break: break-all;
+}
+
+/* Provide sufficient contrast against white background */
+a {
+ color: #0366d6;
+}
+
+.btn-primary {
+ color: #fff;
+ background-color: #1b6ec2;
+ border-color: #1861ac;
+}
+
+.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
+ color: #fff;
+ background-color: #1b6ec2;
+ border-color: #1861ac;
+}
+
+.border-top {
+ border-top: 1px solid #e5e5e5;
+}
+.border-bottom {
+ border-bottom: 1px solid #e5e5e5;
+}
+
+.box-shadow {
+ box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
+}
+
+button.accept-policy {
+ font-size: 1rem;
+ line-height: inherit;
+}
+
+/* Sticky footer styles
+-------------------------------------------------- */
+.footer {
+ position: absolute;
+ bottom: 0;
+ width: 100%;
+ white-space: nowrap;
+ line-height: 60px; /* Vertically center the text there */
+}
\ No newline at end of file
diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/wwwroot/css/site.css b/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/wwwroot/css/site.css
index e679a8ea7fb5..3b1e20a04d53 100644
--- a/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/wwwroot/css/site.css
+++ b/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/wwwroot/css/site.css
@@ -1,71 +1,21 @@
-/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
-for details on configuring this project to bundle and minify static web assets. */
-
-a.navbar-brand {
- white-space: normal;
- text-align: center;
- word-break: break-all;
-}
-
-/* Provide sufficient contrast against white background */
-a {
- color: #0366d6;
-}
-
-.btn-primary {
- color: #fff;
- background-color: #1b6ec2;
- border-color: #1861ac;
-}
-
-.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
- color: #fff;
- background-color: #1b6ec2;
- border-color: #1861ac;
-}
-
-/* Sticky footer styles
--------------------------------------------------- */
html {
- font-size: 14px;
-}
-@media (min-width: 768px) {
+ font-size: 14px;
+ }
+ @media (min-width: 768px) {
+ html {
+ font-size: 16px;
+ }
+ }
+
+ /* Sticky footer styles
+ -------------------------------------------------- */
html {
- font-size: 16px;
+ position: relative;
+ min-height: 100%;
}
-}
-
-.border-top {
- border-top: 1px solid #e5e5e5;
-}
-.border-bottom {
- border-bottom: 1px solid #e5e5e5;
-}
-
-.box-shadow {
- box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
-}
-
-button.accept-policy {
- font-size: 1rem;
- line-height: inherit;
-}
-
-/* Sticky footer styles
--------------------------------------------------- */
-html {
- position: relative;
- min-height: 100%;
-}
-
-body {
- /* Margin bottom by footer height */
- margin-bottom: 60px;
-}
-.footer {
- position: absolute;
- bottom: 0;
- width: 100%;
- white-space: nowrap;
- line-height: 60px; /* Vertically center the text there */
-}
+
+ body {
+ /* Margin bottom by footer height */
+ margin-bottom: 60px;
+ }
+
\ No newline at end of file
diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-FSharp/Views/Shared/_Layout.cshtml b/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-FSharp/Views/Shared/_Layout.cshtml
index b326cdff079a..00e46209a640 100644
--- a/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-FSharp/Views/Shared/_Layout.cshtml
+++ b/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-FSharp/Views/Shared/_Layout.cshtml
@@ -7,6 +7,7 @@
+
diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-FSharp/Views/Shared/_Layout.cshtml.css b/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-FSharp/Views/Shared/_Layout.cshtml.css
new file mode 100644
index 000000000000..08f5018416a9
--- /dev/null
+++ b/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-FSharp/Views/Shared/_Layout.cshtml.css
@@ -0,0 +1,52 @@
+/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
+for details on configuring this project to bundle and minify static web assets. */
+
+a.navbar-brand {
+ white-space: normal;
+ text-align: center;
+ word-break: break-all;
+ }
+
+ /* Provide sufficient contrast against white background */
+ a {
+ color: #0366d6;
+ }
+
+ .btn-primary {
+ color: #fff;
+ background-color: #1b6ec2;
+ border-color: #1861ac;
+ }
+
+ .nav-pills .nav-link.active, .nav-pills .show > .nav-link {
+ color: #fff;
+ background-color: #1b6ec2;
+ border-color: #1861ac;
+ }
+
+ .border-top {
+ border-top: 1px solid #e5e5e5;
+ }
+ .border-bottom {
+ border-bottom: 1px solid #e5e5e5;
+ }
+
+ .box-shadow {
+ box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
+ }
+
+ button.accept-policy {
+ font-size: 1rem;
+ line-height: inherit;
+ }
+
+ /* Sticky footer styles
+ -------------------------------------------------- */
+ .footer {
+ position: absolute;
+ bottom: 0;
+ width: 100%;
+ white-space: nowrap;
+ line-height: 60px; /* Vertically center the text there */
+ }
+
\ No newline at end of file
diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-FSharp/wwwroot/css/site.css b/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-FSharp/wwwroot/css/site.css
index e679a8ea7fb5..3b1e20a04d53 100644
--- a/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-FSharp/wwwroot/css/site.css
+++ b/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-FSharp/wwwroot/css/site.css
@@ -1,71 +1,21 @@
-/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
-for details on configuring this project to bundle and minify static web assets. */
-
-a.navbar-brand {
- white-space: normal;
- text-align: center;
- word-break: break-all;
-}
-
-/* Provide sufficient contrast against white background */
-a {
- color: #0366d6;
-}
-
-.btn-primary {
- color: #fff;
- background-color: #1b6ec2;
- border-color: #1861ac;
-}
-
-.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
- color: #fff;
- background-color: #1b6ec2;
- border-color: #1861ac;
-}
-
-/* Sticky footer styles
--------------------------------------------------- */
html {
- font-size: 14px;
-}
-@media (min-width: 768px) {
+ font-size: 14px;
+ }
+ @media (min-width: 768px) {
+ html {
+ font-size: 16px;
+ }
+ }
+
+ /* Sticky footer styles
+ -------------------------------------------------- */
html {
- font-size: 16px;
+ position: relative;
+ min-height: 100%;
}
-}
-
-.border-top {
- border-top: 1px solid #e5e5e5;
-}
-.border-bottom {
- border-bottom: 1px solid #e5e5e5;
-}
-
-.box-shadow {
- box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
-}
-
-button.accept-policy {
- font-size: 1rem;
- line-height: inherit;
-}
-
-/* Sticky footer styles
--------------------------------------------------- */
-html {
- position: relative;
- min-height: 100%;
-}
-
-body {
- /* Margin bottom by footer height */
- margin-bottom: 60px;
-}
-.footer {
- position: absolute;
- bottom: 0;
- width: 100%;
- white-space: nowrap;
- line-height: 60px; /* Vertically center the text there */
-}
+
+ body {
+ /* Margin bottom by footer height */
+ margin-bottom: 60px;
+ }
+
\ No newline at end of file
diff --git a/src/ProjectTemplates/test/MvcTemplateTest.cs b/src/ProjectTemplates/test/MvcTemplateTest.cs
index 1718059effa9..a10f67180af7 100644
--- a/src/ProjectTemplates/test/MvcTemplateTest.cs
+++ b/src/ProjectTemplates/test/MvcTemplateTest.cs
@@ -45,6 +45,9 @@ public ITestOutputHelper Output
private async Task MvcTemplateCore(string languageOverride)
{
+ // Additional arguments are needed. See: https://github.com/dotnet/aspnetcore/issues/24278
+ Environment.SetEnvironmentVariable("EnableDefaultScopedCssItems", "true");
+
var project = await ProjectFactory.GetOrCreateProject("mvcnoauth" + (languageOverride == "F#" ? "fsharp" : "csharp"), Output);
var createResult = await project.RunDotNetNewAsync("mvc", language: languageOverride);
@@ -121,6 +124,9 @@ private async Task MvcTemplateCore(string languageOverride)
[SkipOnHelix("Cert failure, https://github.com/dotnet/aspnetcore/issues/28090", Queues = "All.OSX;" + HelixConstants.Windows10Arm64 + HelixConstants.DebianArm64)]
public async Task MvcTemplate_IndividualAuth(bool useLocalDB)
{
+ // Additional arguments are needed. See: https://github.com/dotnet/aspnetcore/issues/24278
+ Environment.SetEnvironmentVariable("EnableDefaultScopedCssItems", "true");
+
var project = await ProjectFactory.GetOrCreateProject("mvcindividual" + (useLocalDB ? "uld" : ""), Output);
var createResult = await project.RunDotNetNewAsync("mvc", auth: "Individual", useLocalDB: useLocalDB);
diff --git a/src/ProjectTemplates/test/template-baselines.json b/src/ProjectTemplates/test/template-baselines.json
index 9e36b3eed22e..100b5a1f6be4 100644
--- a/src/ProjectTemplates/test/template-baselines.json
+++ b/src/ProjectTemplates/test/template-baselines.json
@@ -484,6 +484,7 @@
"Views/Home/Privacy.cshtml",
"Views/Shared/Error.cshtml",
"Views/Shared/_Layout.cshtml",
+ "Views/Shared/_Layout.cshtml.css",
"Views/Shared/_LoginPartial.cshtml",
"Views/Shared/_ValidationScriptsPartial.cshtml",
"wwwroot/favicon.ico",
@@ -542,6 +543,7 @@
"Views/Home/Privacy.cshtml",
"Views/Shared/Error.cshtml",
"Views/Shared/_Layout.cshtml",
+ "Views/Shared/_Layout.cshtml.css",
"Views/Shared/_ValidationScriptsPartial.cshtml",
"wwwroot/favicon.ico",
"wwwroot/css/site.css",
@@ -599,6 +601,7 @@
"Views/Home/Privacy.cshtml",
"Views/Shared/Error.cshtml",
"Views/Shared/_Layout.cshtml",
+ "Views/Shared/_Layout.cshtml.css",
"Views/Shared/_LoginPartial.cshtml",
"Views/Shared/_ValidationScriptsPartial.cshtml",
"wwwroot/favicon.ico",
@@ -657,6 +660,7 @@
"Views/Home/Privacy.cshtml",
"Views/Shared/Error.cshtml",
"Views/Shared/_Layout.cshtml",
+ "Views/Shared/_Layout.cshtml.css",
"Views/Shared/_LoginPartial.cshtml",
"Views/Shared/_ValidationScriptsPartial.cshtml",
"wwwroot/favicon.ico",
@@ -715,6 +719,7 @@
"Views/Home/Privacy.cshtml",
"Views/Shared/Error.cshtml",
"Views/Shared/_Layout.cshtml",
+ "Views/Shared/_Layout.cshtml.css",
"Views/Shared/_ValidationScriptsPartial.cshtml",
"wwwroot/favicon.ico",
"wwwroot/css/site.css",
@@ -772,6 +777,7 @@
"Views/Home/Privacy.cshtml",
"Views/Shared/Error.cshtml",
"Views/Shared/_Layout.cshtml",
+ "Views/Shared/_Layout.cshtml.css",
"Views/Shared/_LoginPartial.cshtml",
"Views/Shared/_ValidationScriptsPartial.cshtml",
"wwwroot/favicon.ico",
@@ -830,6 +836,7 @@
"Views/Home/Privacy.cshtml",
"Views/Shared/Error.cshtml",
"Views/Shared/_Layout.cshtml",
+ "Views/Shared/_Layout.cshtml.css",
"Views/Shared/_ValidationScriptsPartial.cshtml",
"wwwroot/favicon.ico",
"wwwroot/css/site.css",
diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/IntegrationTests/CodeGenerationIntegrationTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/IntegrationTests/CodeGenerationIntegrationTest.cs
index 49d5f463f7c2..9c5f7543a7fe 100644
--- a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/IntegrationTests/CodeGenerationIntegrationTest.cs
+++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/IntegrationTests/CodeGenerationIntegrationTest.cs
@@ -609,6 +609,45 @@ public class FormTagHelper : {typeof(TagHelper).FullName}
CompileToAssembly(generated);
}
+ [Fact]
+ public void RazorView_Layout_WithCssScope()
+ {
+ // Arrange
+ AddCSharpSyntaxTree($@"
+[{typeof(HtmlTargetElementAttribute).FullName}({"\"all\""})]
+public class AllTagHelper : {typeof(TagHelper).FullName}
+{{
+ public string Bar {{ get; set; }}
+}}
+[{typeof(HtmlTargetElementAttribute).FullName}({"\"form\""})]
+public class FormTagHelper : {typeof(TagHelper).FullName}
+{{
+}}
+");
+
+ // Act
+ // This test case attempts to use all syntaxes that might interact with auto-generated attributes
+ var generated = CompileToCSharp(@"
+
+
+
+
+
+ @ViewData[""Title""] - Test layout component
+
+
+ This is a body.
+
+
+", cssScope: "TestCssScope");
+
+ // Assert
+ var intermediate = generated.CodeDocument.GetDocumentIntermediateNode();
+ var csharp = generated.CodeDocument.GetCSharpDocument();
+ AssertDocumentNodeMatchesBaseline(intermediate);
+ AssertCSharpDocumentMatchesBaseline(csharp);
+ CompileToAssembly(generated);
+ }
#endregion
#region DesignTime
diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorView_Layout_WithCssScope.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorView_Layout_WithCssScope.codegen.cs
new file mode 100644
index 000000000000..282f05793985
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorView_Layout_WithCssScope.codegen.cs
@@ -0,0 +1,44 @@
+#pragma checksum "TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "aa3144e1672369f198372f95e6bbee5ac485c5c3"
+//
+#pragma warning disable 1591
+[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/test.cshtml")]
+namespace AspNetCore
+{
+ #line hidden
+ 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;
+ [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"aa3144e1672369f198372f95e6bbee5ac485c5c3", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/test.cshtml")]
+ public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage
+ {
+ #pragma warning disable 1998
+ public async override global::System.Threading.Tasks.Task ExecuteAsync()
+ {
+ WriteLiteral("\r\n\r\n\r\n\r\n \r\n \r\n ");
+#nullable restore
+#line 7 "TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml"
+ Write(ViewData["Title"]);
+
+#line default
+#line hidden
+#nullable disable
+ WriteLiteral(" - Test layout component \r\n\r\n\r\n This is a body.
\r\n\r\n\r\n");
+ }
+ #pragma warning restore 1998
+ [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
+ public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; }
+ [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
+ public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; }
+ [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
+ public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; }
+ [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; }
+ }
+}
+#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorView_Layout_WithCssScope.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorView_Layout_WithCssScope.ir.txt
new file mode 100644
index 000000000000..c7db330e79b4
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorView_Layout_WithCssScope.ir.txt
@@ -0,0 +1,68 @@
+Document -
+ RazorCompiledItemAttribute -
+ NamespaceDeclaration - - AspNetCore
+ UsingDirective - (1:0,1 [14] ) - System
+ UsingDirective - (16:1,1 [34] ) - System.Collections.Generic
+ UsingDirective - (51:2,1 [19] ) - System.Linq
+ UsingDirective - (71:3,1 [30] ) - System.Threading.Tasks
+ 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
+ RazorSourceChecksumAttribute -
+ ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage -
+ MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
+ HtmlContent - (0:0,0 [164] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml)
+ LazyIntermediateToken - (0:0,0 [2] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html - \n
+ LazyIntermediateToken - (2:1,0 [17] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html - \n
+ LazyIntermediateToken - (19:2,0 [5] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html -
+ LazyIntermediateToken - (35:2,16 [2] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html - \n
+ LazyIntermediateToken - (37:3,0 [5] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html -
+ LazyIntermediateToken - (43:3,6 [6] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html - \n
+ LazyIntermediateToken - (49:4,4 [5] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html -
+ LazyIntermediateToken - (73:4,28 [6] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html - \n
+ LazyIntermediateToken - (79:5,4 [5] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html -
+ LazyIntermediateToken - (151:5,76 [6] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html - \n
+ LazyIntermediateToken - (157:6,4 [6] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html -
+ CSharpExpression - (165:6,12 [17] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml)
+ LazyIntermediateToken - (165:6,12 [17] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - CSharp - ViewData["Title"]
+ HtmlContent - (182:6,29 [97] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml)
+ LazyIntermediateToken - (182:6,29 [24] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html - \-Test layout component
+ LazyIntermediateToken - (206:6,53 [8] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html -
+ LazyIntermediateToken - (214:6,61 [2] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html - \n
+ LazyIntermediateToken - (216:7,0 [7] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html -
+ LazyIntermediateToken - (223:7,7 [2] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html - \n
+ LazyIntermediateToken - (225:8,0 [5] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html -
+ LazyIntermediateToken - (231:8,6 [6] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html - \n
+ LazyIntermediateToken - (237:9,4 [2] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html -
+ LazyIntermediateToken - (240:9,7 [15] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html - This is a body.
+ LazyIntermediateToken - (255:9,22 [4] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html -
+ LazyIntermediateToken - (259:9,26 [2] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html - \n
+ LazyIntermediateToken - (261:10,0 [7] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html -
+ LazyIntermediateToken - (268:10,7 [2] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html - \n
+ LazyIntermediateToken - (270:11,0 [7] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html -
+ LazyIntermediateToken - (277:11,7 [2] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html - \n
+ Inject -
+ Inject -
+ Inject -
+ Inject -
+ Inject -
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Extensions/ViewCssScopePass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Extensions/ViewCssScopePass.cs
index c17844a438bb..ae20b386c243 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Extensions/ViewCssScopePass.cs
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Extensions/ViewCssScopePass.cs
@@ -42,7 +42,8 @@ private void ProcessElement(HtmlContentIntermediateNode node, string cssScope)
if (child is IntermediateToken token && token.IsHtml)
{
var content = token.Content;
- if (content.StartsWith("<", StringComparison.Ordinal) && !content.StartsWith("", StringComparison.Ordinal))
+ var isValidToken = content.StartsWith("<", StringComparison.Ordinal) && !content.StartsWith("", StringComparison.Ordinal) && !content.StartsWith("