diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ModelDirectiveTest.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ModelDirectiveTest.cs index ab15b757961..7fc3fdf339e 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ModelDirectiveTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ModelDirectiveTest.cs @@ -46,7 +46,7 @@ @model Type2 var documentNode = processor.GetDocumentNode(); // Act - var result = ModelDirective.GetModelType(documentNode); + var result = ModelDirective.GetModelType(documentNode).Content; // Assert Assert.Equal("Type1", result); @@ -61,7 +61,7 @@ public void ModelDirective_GetModelType_DefaultsToDynamic() var documentNode = processor.GetDocumentNode(); // Act - var result = ModelDirective.GetModelType(documentNode); + var result = ModelDirective.GetModelType(documentNode).Content; // Assert Assert.Equal("dynamic", result); diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ModelDirectiveTest.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ModelDirectiveTest.cs index 6fa08cf7a50..7e5c1e7625e 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ModelDirectiveTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ModelDirectiveTest.cs @@ -46,7 +46,7 @@ @model Type2 var documentNode = processor.GetDocumentNode(); // Act - var result = ModelDirective.GetModelType(documentNode); + var result = ModelDirective.GetModelType(documentNode).Content; // Assert Assert.Equal("Type1", result); @@ -61,7 +61,7 @@ public void ModelDirective_GetModelType_DefaultsToDynamic() var documentNode = processor.GetDocumentNode(); // Act - var result = ModelDirective.GetModelType(documentNode); + var result = ModelDirective.GetModelType(documentNode).Content; // Assert Assert.Equal("dynamic", result); diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/IntegrationTests/CodeGenerationIntegrationTest.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/IntegrationTests/CodeGenerationIntegrationTest.cs index 4470b4d319d..f436401ccb5 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/IntegrationTests/CodeGenerationIntegrationTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/IntegrationTests/CodeGenerationIntegrationTest.cs @@ -442,6 +442,7 @@ public void RazorPagesWithRouteTemplate_Runtime() // Assert AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertSourceMappingsMatchBaseline(compiled.CodeDocument); AssertLinePragmas(compiled.CodeDocument, designTime: false); } diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ModelDirectiveTest.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ModelDirectiveTest.cs index 666627479c9..b8139297f51 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ModelDirectiveTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ModelDirectiveTest.cs @@ -43,7 +43,7 @@ @model Type2 var documentNode = processor.GetDocumentNode(); // Act - var result = ModelDirective.GetModelType(documentNode); + var result = ModelDirective.GetModelType(documentNode).Content; // Assert Assert.Equal("Type1", result); @@ -58,7 +58,7 @@ public void ModelDirective_GetModelType_DefaultsToDynamic() var documentNode = processor.GetDocumentNode(); // Act - var result = ModelDirective.GetModelType(documentNode); + var result = ModelDirective.GetModelType(documentNode).Content; // Assert Assert.Equal("dynamic", result); diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs index 20999cb1add..5d0b69ac2e8 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs @@ -81,9 +81,7 @@ internal sealed class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_I #nullable restore public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData!; #nullable disable - #nullable restore -public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives Model => ViewData.Model!; -#nullable disable + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives Model => ViewData.Model; } } #pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt index 41a10f5292e..8e6bf008009 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt @@ -60,5 +60,4 @@ Inject - CSharpCode - IntermediateToken - - CSharp - #nullable restore\npublic global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData!;\n#nullable disable - CSharpCode - - IntermediateToken - - CSharp - #nullable restore\npublic TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives Model => ViewData.Model!;\n#nullable disable + PropertyDeclaration - - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives - Model - ViewData.Model diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsDirective_RazorPages_Runtime.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsDirective_RazorPages_Runtime.codegen.cs index e37f62182b4..f17d699f5a2 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsDirective_RazorPages_Runtime.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsDirective_RazorPages_Runtime.codegen.cs @@ -57,9 +57,7 @@ internal sealed class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_t #nullable restore public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData!; #nullable disable - #nullable restore -public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test Model => ViewData.Model!; -#nullable disable + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test Model => ViewData.Model; } } #pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsDirective_RazorPages_Runtime.ir.txt b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsDirective_RazorPages_Runtime.ir.txt index 516a00a7e2a..ec31c5ab0b8 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsDirective_RazorPages_Runtime.ir.txt +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsDirective_RazorPages_Runtime.ir.txt @@ -20,5 +20,4 @@ Inject - CSharpCode - IntermediateToken - - CSharp - #nullable restore\npublic global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData!;\n#nullable disable - CSharpCode - - IntermediateToken - - CSharp - #nullable restore\npublic TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test Model => ViewData.Model!;\n#nullable disable + PropertyDeclaration - - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test - Model - ViewData.Model diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.codegen.cs index 4e1109a53a2..901d760941f 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.codegen.cs @@ -79,9 +79,15 @@ internal sealed class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_I #nullable restore public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData!; #nullable disable - #nullable restore -public MyModel Model => ViewData.Model!; + public +#nullable restore +#line (2,8)-(2,15) "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml" +MyModel + +#line default +#line hidden #nullable disable + Model => ViewData.Model; } } #pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.ir.txt b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.ir.txt index e7cc91dcb2c..e167c5d1598 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.ir.txt +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.ir.txt @@ -21,5 +21,4 @@ Inject - CSharpCode - IntermediateToken - - CSharp - #nullable restore\npublic global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData!;\n#nullable disable - CSharpCode - - IntermediateToken - - CSharp - #nullable restore\npublic MyModel Model => ViewData.Model!;\n#nullable disable + PropertyDeclaration - - MyModel - Model - ViewData.Model diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.codegen.cs index 1fd1127e0d6..b28d711c049 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.codegen.cs @@ -50,9 +50,7 @@ internal sealed class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_M #nullable restore public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData!; #nullable disable - #nullable restore -public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective Model => ViewData.Model!; -#nullable disable + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective Model => ViewData.Model; } } #pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.ir.txt b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.ir.txt index 6c6d17fcac8..fb820fb106a 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.ir.txt +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.ir.txt @@ -32,5 +32,4 @@ Inject - CSharpCode - IntermediateToken - - CSharp - #nullable restore\npublic global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData!;\n#nullable disable - CSharpCode - - IntermediateToken - - CSharp - #nullable restore\npublic TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective Model => ViewData.Model!;\n#nullable disable + PropertyDeclaration - - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective - Model - ViewData.Model diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.codegen.cs index 60084b62428..6dea5639dfc 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.codegen.cs @@ -50,9 +50,7 @@ internal sealed class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_P #nullable restore public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData!; #nullable disable - #nullable restore -public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace Model => ViewData.Model!; -#nullable disable + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace Model => ViewData.Model; } } #pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.ir.txt b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.ir.txt index ddd4d92f4a1..77710f47d04 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.ir.txt +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.ir.txt @@ -26,5 +26,4 @@ Inject - CSharpCode - IntermediateToken - - CSharp - #nullable restore\npublic global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData!;\n#nullable disable - CSharpCode - - IntermediateToken - - CSharp - #nullable restore\npublic TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace Model => ViewData.Model!;\n#nullable disable + PropertyDeclaration - - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace - Model - ViewData.Model diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_Runtime.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_Runtime.codegen.cs index d842ee826ae..5fd06561858 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_Runtime.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_Runtime.codegen.cs @@ -50,9 +50,7 @@ internal sealed class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_R #nullable restore public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData!; #nullable disable - #nullable restore -public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPageWithNoLeadingPageDirective Model => ViewData.Model!; -#nullable disable + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPageWithNoLeadingPageDirective Model => ViewData.Model; } } #pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_Runtime.ir.txt b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_Runtime.ir.txt index 23b1c3cd03c..9eddd43d1db 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_Runtime.ir.txt +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_Runtime.ir.txt @@ -26,5 +26,4 @@ Inject - CSharpCode - IntermediateToken - - CSharp - #nullable restore\npublic global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData!;\n#nullable disable - CSharpCode - - IntermediateToken - - CSharp - #nullable restore\npublic TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPageWithNoLeadingPageDirective Model => ViewData.Model!;\n#nullable disable + PropertyDeclaration - - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPageWithNoLeadingPageDirective - Model - ViewData.Model diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithCssScope.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithCssScope.codegen.cs index 234c5d8d637..7ae1d29600d 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithCssScope.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithCssScope.codegen.cs @@ -115,9 +115,7 @@ internal sealed class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_t #nullable restore public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData!; #nullable disable - #nullable restore -public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test Model => ViewData.Model!; -#nullable disable + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test Model => ViewData.Model; } } #pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithCssScope.ir.txt b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithCssScope.ir.txt index 3f31496efc8..686f4bc0aa0 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithCssScope.ir.txt +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithCssScope.ir.txt @@ -80,5 +80,4 @@ Inject - CSharpCode - IntermediateToken - - CSharp - #nullable restore\npublic global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData!;\n#nullable disable - CSharpCode - - IntermediateToken - - CSharp - #nullable restore\npublic TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test Model => ViewData.Model!;\n#nullable disable + PropertyDeclaration - - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test - Model - ViewData.Model diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithNonNullableModel_LangNew_Runtime.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithNonNullableModel_LangNew_Runtime.codegen.cs index 2521469e138..da6c83eaf22 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithNonNullableModel_LangNew_Runtime.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithNonNullableModel_LangNew_Runtime.codegen.cs @@ -76,9 +76,15 @@ internal sealed class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_t #nullable restore public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData!; #nullable disable - #nullable restore -public TestModel Model => ViewData.Model!; + public +#nullable restore +#line (3,8)-(3,17) "TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml" +TestModel + +#line default +#line hidden #nullable disable + Model => ViewData.Model; } } #pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithNonNullableModel_LangNew_Runtime.ir.txt b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithNonNullableModel_LangNew_Runtime.ir.txt index 994c560a814..36c69a1902d 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithNonNullableModel_LangNew_Runtime.ir.txt +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithNonNullableModel_LangNew_Runtime.ir.txt @@ -36,5 +36,4 @@ Inject - CSharpCode - IntermediateToken - - CSharp - #nullable restore\npublic global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData!;\n#nullable disable - CSharpCode - - IntermediateToken - - CSharp - #nullable restore\npublic TestModel Model => ViewData.Model!;\n#nullable disable + PropertyDeclaration - - TestModel - Model - ViewData.Model diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithNonNullableModel_LangNew_Runtime.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithNonNullableModel_LangNew_Runtime.mappings.txt index deb9091fe50..269616879ec 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithNonNullableModel_LangNew_Runtime.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithNonNullableModel_LangNew_Runtime.mappings.txt @@ -13,3 +13,8 @@ Source Location: (78:6,5 [14] TestFiles\IntegrationTests\CodeGenerationIntegrati Generated Location: (2328:46,0 [14] ) |Model?.Address| +Source Location: (36:2,7 [9] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) +|TestModel| +Generated Location: (4123:81,0 [9] ) +|TestModel| + diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithNullableModel_LangNew_Runtime.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithNullableModel_LangNew_Runtime.codegen.cs index 516f45030bc..1e343e62698 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithNullableModel_LangNew_Runtime.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithNullableModel_LangNew_Runtime.codegen.cs @@ -76,9 +76,15 @@ internal sealed class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_t #nullable restore public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData!; #nullable disable - #nullable restore -public TestModel? Model => ViewData.Model!; + public +#nullable restore +#line (3,8)-(3,18) "TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml" +TestModel? + +#line default +#line hidden #nullable disable + Model => ViewData.Model; } } #pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithNullableModel_LangNew_Runtime.ir.txt b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithNullableModel_LangNew_Runtime.ir.txt index 67090281469..52935eb5b22 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithNullableModel_LangNew_Runtime.ir.txt +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithNullableModel_LangNew_Runtime.ir.txt @@ -36,5 +36,4 @@ Inject - CSharpCode - IntermediateToken - - CSharp - #nullable restore\npublic global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData!;\n#nullable disable - CSharpCode - - IntermediateToken - - CSharp - #nullable restore\npublic TestModel? Model => ViewData.Model!;\n#nullable disable + PropertyDeclaration - - TestModel? - Model - ViewData.Model diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithNullableModel_LangNew_Runtime.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithNullableModel_LangNew_Runtime.mappings.txt index a7f88d1179b..203d9ef285d 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithNullableModel_LangNew_Runtime.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithNullableModel_LangNew_Runtime.mappings.txt @@ -13,3 +13,8 @@ Source Location: (79:6,5 [14] TestFiles\IntegrationTests\CodeGenerationIntegrati Generated Location: (2328:46,0 [14] ) |Model?.Address| +Source Location: (36:2,7 [10] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) +|TestModel?| +Generated Location: (4126:81,0 [10] ) +|TestModel?| + diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_Runtime.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_Runtime.codegen.cs index 241473d7df9..93764b556ae 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_Runtime.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_Runtime.codegen.cs @@ -90,9 +90,15 @@ public class NewModel : PageModel #nullable restore public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData!; #nullable disable - #nullable restore -public NewModel Model => ViewData.Model!; + public +#nullable restore +#line (3,8)-(3,16) "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml" +NewModel + +#line default +#line hidden #nullable disable + Model => ViewData.Model; } } #pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_Runtime.ir.txt b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_Runtime.ir.txt index fa61c8a7cb2..6e99227b03d 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_Runtime.ir.txt +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_Runtime.ir.txt @@ -38,5 +38,4 @@ Inject - CSharpCode - IntermediateToken - - CSharp - #nullable restore\npublic global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData!;\n#nullable disable - CSharpCode - - IntermediateToken - - CSharp - #nullable restore\npublic NewModel Model => ViewData.Model!;\n#nullable disable + PropertyDeclaration - - NewModel - Model - ViewData.Model diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_Runtime.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_Runtime.mappings.txt new file mode 100644 index 00000000000..bd066a4f129 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_Runtime.mappings.txt @@ -0,0 +1,40 @@ +Source Location: (36:3,1 [41] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml) +|using Microsoft.AspNetCore.Mvc.RazorPages| +Generated Location: (1098:16,0 [41] ) +|using Microsoft.AspNetCore.Mvc.RazorPages| + +Source Location: (6:0,6 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml) +|"/About"| +Generated Location: (1464:26,0 [8] ) +|"/About"| + +Source Location: (6:0,6 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml) +|"/About"| +Generated Location: (1464:26,0 [8] ) +|"/About"| + +Source Location: (213:12,18 [10] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml) +|Model.Name| +Generated Location: (2690:48,0 [10] ) +|Model.Name| + +Source Location: (93:5,12 [97] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml) +| + public class NewModel : PageModel + { + public string Name { get; set; } + } +| +Generated Location: (2991:59,0 [97] ) +| + public class NewModel : PageModel + { + public string Name { get; set; } + } +| + +Source Location: (25:2,7 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml) +|NewModel| +Generated Location: (4788:95,0 [8] ) +|NewModel| + diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.codegen.cs index 72a0f8198b0..8ef87331775 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.codegen.cs @@ -187,9 +187,7 @@ public class Customer #nullable restore public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData!; #nullable disable - #nullable restore -public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel Model => ViewData.Model!; -#nullable disable + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel Model => ViewData.Model; } } #pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.ir.txt b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.ir.txt index 03efb641386..82fc3c6ef0f 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.ir.txt +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.ir.txt @@ -115,5 +115,4 @@ Inject - CSharpCode - IntermediateToken - - CSharp - #nullable restore\npublic global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData!;\n#nullable disable - CSharpCode - - IntermediateToken - - CSharp - #nullable restore\npublic TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel Model => ViewData.Model!;\n#nullable disable + PropertyDeclaration - - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel - Model - ViewData.Model diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.codegen.cs index bf446dbfaa8..ecd22bc5000 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.codegen.cs @@ -190,9 +190,15 @@ public class Customer #nullable restore public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData!; #nullable disable - #nullable restore -public NewModel Model => ViewData.Model!; + public +#nullable restore +#line (3,8)-(3,16) "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml" +NewModel + +#line default +#line hidden #nullable disable + Model => ViewData.Model; } } #pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.ir.txt b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.ir.txt index c1b6a5175e1..09358198925 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.ir.txt +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.ir.txt @@ -116,5 +116,4 @@ Inject - CSharpCode - IntermediateToken - - CSharp - #nullable restore\npublic global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData!;\n#nullable disable - CSharpCode - - IntermediateToken - - CSharp - #nullable restore\npublic NewModel Model => ViewData.Model!;\n#nullable disable + PropertyDeclaration - - NewModel - Model - ViewData.Model diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/CodeGeneration/DefaultDocumentWriterTest.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/CodeGeneration/DefaultDocumentWriterTest.cs index 99e87b2acb2..f21ba1c6465 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/CodeGeneration/DefaultDocumentWriterTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/CodeGeneration/DefaultDocumentWriterTest.cs @@ -433,7 +433,8 @@ public void WriteDocument_WritesProperty() "virtual", }, PropertyName = "Foo", - PropertyType = "string", + PropertyType = IntermediateToken.CreateCSharpToken("string"), + PropertyExpression = "default" }); var codeDocument = TestRazorCodeDocument.CreateEmpty(); @@ -452,7 +453,7 @@ public void WriteDocument_WritesProperty() #pragma checksum "test.cshtml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "f1945cd6c19e56b3c1c78943ef5ec18116907a4ca1efc40a57d48ab1db7adfc5" // #pragma warning disable 1591 - internal virtual string Foo { get; set; } + internal virtual string Foo => default; #pragma warning restore 1591 """, diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/CodeGeneration/CodeWriterExtensions.cs b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/CodeGeneration/CodeWriterExtensions.cs index 3e87ef8f930..84e3aeab45d 100644 --- a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/CodeGeneration/CodeWriterExtensions.cs +++ b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/CodeGeneration/CodeWriterExtensions.cs @@ -337,32 +337,23 @@ public static CodeWriter WriteMethodInvocation(this CodeWriter writer, string me .WriteEndMethodInvocation(endLine); } - public static CodeWriter WriteAutoPropertyDeclaration(this CodeWriter writer, IList modifiers, string typeName, string propertyName, SourceSpan? typeSpan = null, SourceSpan? propertySpan = null, CodeRenderingContext context = null, bool privateSetter = false, bool defaultValue = false) + public static CodeWriter WritePropertyDeclaration(this CodeWriter writer, IList modifiers, IntermediateToken type, string propertyName, string propertyExpression, CodeRenderingContext context) { - if (modifiers == null) - { - throw new ArgumentNullException(nameof(modifiers)); - } + WritePropertyDeclarationPreamble(writer, modifiers, type.Content, propertyName, type.Source, propertySpan: null, context); + writer.Write(" => "); + writer.Write(propertyExpression); + writer.WriteLine(";"); + return writer; + } - if (typeName == null) - { - throw new ArgumentNullException(nameof(typeName)); - } + public static CodeWriter WriteAutoPropertyDeclaration(this CodeWriter writer, IList modifiers, string typeName, string propertyName, SourceSpan? typeSpan = null, SourceSpan? propertySpan = null, CodeRenderingContext context = null, bool privateSetter = false, bool defaultValue = false) + { + ArgHelper.ThrowIfNull(modifiers); + ArgHelper.ThrowIfNull(typeName); + ArgHelper.ThrowIfNull(propertyName); - if (propertyName == null) - { - throw new ArgumentNullException(nameof(propertyName)); - } + WritePropertyDeclarationPreamble(writer, modifiers, typeName, propertyName, typeSpan, propertySpan, context); - for (var i = 0; i < modifiers.Count; i++) - { - writer.Write(modifiers[i]); - writer.Write(" "); - } - - WriteToken(writer, typeName, typeSpan, context); - writer.Write(" "); - WriteToken(writer, propertyName, propertySpan, context); writer.Write(" { get;"); if (privateSetter) { @@ -377,6 +368,19 @@ public static CodeWriter WriteAutoPropertyDeclaration(this CodeWriter writer, IL } return writer; + } + + private static void WritePropertyDeclarationPreamble(CodeWriter writer, IList modifiers, string typeName, string propertyName, SourceSpan? typeSpan, SourceSpan? propertySpan, CodeRenderingContext context) + { + for (var i = 0; i < modifiers.Count; i++) + { + writer.Write(modifiers[i]); + writer.Write(" "); + } + + WriteToken(writer, typeName, typeSpan, context); + writer.Write(" "); + WriteToken(writer, propertyName, propertySpan, context); static void WriteToken(CodeWriter writer, string content, SourceSpan? span, CodeRenderingContext context) { diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/CodeGeneration/DefaultDocumentWriter.cs b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/CodeGeneration/DefaultDocumentWriter.cs index 101e9198763..ab2a84284ab 100644 --- a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/CodeGeneration/DefaultDocumentWriter.cs +++ b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/CodeGeneration/DefaultDocumentWriter.cs @@ -200,7 +200,7 @@ public override void VisitFieldDeclaration(FieldDeclarationIntermediateNode node public override void VisitPropertyDeclaration(PropertyDeclarationIntermediateNode node) { - CodeWriter.WriteAutoPropertyDeclaration(node.Modifiers, node.PropertyType, node.PropertyName); + CodeWriter.WritePropertyDeclaration(node.Modifiers, node.PropertyType, node.PropertyName, node.PropertyExpression, _context); } public override void VisitExtension(ExtensionIntermediateNode node) diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Intermediate/PropertyDeclarationIntermediateNode.cs b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Intermediate/PropertyDeclarationIntermediateNode.cs index 3fdc7164975..da0c4ab8e65 100644 --- a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Intermediate/PropertyDeclarationIntermediateNode.cs +++ b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Intermediate/PropertyDeclarationIntermediateNode.cs @@ -16,7 +16,9 @@ public sealed class PropertyDeclarationIntermediateNode : MemberDeclarationInter public string PropertyName { get; set; } - public string PropertyType { get; set; } + public IntermediateToken PropertyType { get; set; } + + public string PropertyExpression { get; set; } public override void Accept(IntermediateNodeVisitor visitor) { diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Mvc.Version2_X/PagesPropertyInjectionPass.cs b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Mvc.Version2_X/PagesPropertyInjectionPass.cs index 75030007965..fea140433f6 100644 --- a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Mvc.Version2_X/PagesPropertyInjectionPass.cs +++ b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Mvc.Version2_X/PagesPropertyInjectionPass.cs @@ -17,7 +17,7 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentInte return; } - var modelType = ModelDirective.GetModelType(documentNode); + var modelType = ModelDirective.GetModelType(documentNode).Content; var visitor = new Visitor(); visitor.Visit(documentNode); diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Mvc/InjectDirective.cs b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Mvc/InjectDirective.cs index 583286b24dc..bcb7d174a00 100644 --- a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Mvc/InjectDirective.cs +++ b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Mvc/InjectDirective.cs @@ -56,7 +56,7 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentInte var visitor = new Visitor(); visitor.Visit(documentNode); - var modelType = ModelDirective.GetModelType(documentNode); + var modelType = ModelDirective.GetModelType(documentNode).Content; var properties = new HashSet(StringComparer.Ordinal); diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Mvc/ModelDirective.cs b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Mvc/ModelDirective.cs index 206d2d7efc0..c6ee849285e 100644 --- a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Mvc/ModelDirective.cs +++ b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Mvc/ModelDirective.cs @@ -36,7 +36,7 @@ public static RazorProjectEngineBuilder Register(RazorProjectEngineBuilder build return builder; } - public static string GetModelType(DocumentIntermediateNode document) + public static IntermediateToken GetModelType(DocumentIntermediateNode document) { if (document == null) { @@ -44,7 +44,7 @@ public static string GetModelType(DocumentIntermediateNode document) } var visitor = new Visitor(); - return GetModelType(document, visitor).Content; + return GetModelType(document, visitor); } private static IntermediateToken GetModelType(DocumentIntermediateNode document, Visitor visitor) diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Mvc/PagesPropertyInjectionPass.cs b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Mvc/PagesPropertyInjectionPass.cs index 7195fe6fd5e..d9d8d63f6b6 100644 --- a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Mvc/PagesPropertyInjectionPass.cs +++ b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Mvc/PagesPropertyInjectionPass.cs @@ -18,8 +18,8 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentInte } // We only nullable-enable razor page `@model` for RazorLangVersion 9+ to avoid breaking users. - var nullableEnabled = codeDocument.ParserOptions.LanguageVersion >= RazorLanguageVersion.Version_9_0 && - !codeDocument.CodeGenerationOptions.SuppressNullabilityEnforcement; + var razor9OrHigher = codeDocument.ParserOptions.LanguageVersion >= RazorLanguageVersion.Version_9_0; + var nullableEnabled = razor9OrHigher && !codeDocument.CodeGenerationOptions.SuppressNullabilityEnforcement; var modelType = ModelDirective.GetModelType(documentNode); var visitor = new Visitor(); @@ -27,7 +27,7 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentInte var @class = visitor.Class; - var viewDataType = $"global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<{modelType}>"; + var viewDataType = $"global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<{modelType.Content}>"; var vddProperty = new CSharpCodeIntermediateNode(); vddProperty.Children.Add(new IntermediateToken() { @@ -36,13 +36,26 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentInte }); @class.Children.Add(vddProperty); - var modelProperty = new CSharpCodeIntermediateNode(); - modelProperty.Children.Add(new IntermediateToken() + if (codeDocument.CodeGenerationOptions.DesignTime || !razor9OrHigher) { - Kind = TokenKind.CSharp, - Content = nullableEnable(nullableEnabled, $"public {modelType} Model => ViewData.Model"), - }); - @class.Children.Add(modelProperty); + var modelProperty = new CSharpCodeIntermediateNode(); + modelProperty.Children.Add(new IntermediateToken() + { + Kind = TokenKind.CSharp, + Content = nullableEnable(nullableEnabled, $"public {modelType.Content} Model => ViewData.Model"), + }); + @class.Children.Add(modelProperty); + } + else + { + @class.Children.Add(new PropertyDeclarationIntermediateNode() + { + Modifiers = { "public" }, + PropertyName = "Model", + PropertyType = modelType, + PropertyExpression = "ViewData.Model" + }); + } static string nullableEnable(bool nullableEnabled, string code) { @@ -51,11 +64,7 @@ static string nullableEnable(bool nullableEnabled, string code) return code + ";"; } - return $""" - #nullable restore - {code}!; - #nullable disable - """; + return $"#nullable restore\r\n{code}!;\r\n#nullable disable"; } } diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/Legacy.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/Legacy.txt index ece52c1e7ba..84682511047 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/Legacy.txt +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/Legacy.txt @@ -4,6 +4,9 @@ Line Δ, Char Δ, Length, Type, Modifier(s), Text 0 5 3 string [] ["/"] 1 0 1 razorTransition [] [@] 0 1 5 razorDirective [] [model] +0 6 8 variable [] [AppThing] +0 8 1 operator [] [.] +0 1 5 variable [] [Model] 1 0 1 razorTransition [] [@] 0 1 5 keyword [] [using] 0 6 6 namespace name [] [System] diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/Legacy_VSCode.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/Legacy_VSCode.txt index f4c8cfb41c9..42564b82a5b 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/Legacy_VSCode.txt +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/Legacy_VSCode.txt @@ -4,6 +4,9 @@ Line Δ, Char Δ, Length, Type, Modifier(s), Text 0 5 3 string [] ["/"] 1 0 1 razorTransition [] [@] 0 1 5 razorDirective [] [model] +0 6 8 variable [] [AppThing] +0 8 1 operator [] [.] +0 1 5 variable [] [Model] 1 0 1 razorTransition [] [@] 0 1 5 keyword [] [using] 0 6 6 namespace [] [System] diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/Legacy_VSCode_with_background.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/Legacy_VSCode_with_background.txt index ad0cb479cfc..f65ff7a9139 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/Legacy_VSCode_with_background.txt +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/Legacy_VSCode_with_background.txt @@ -4,6 +4,9 @@ Line Δ, Char Δ, Length, Type, Modifier(s), Text 0 5 3 string [razorCode] ["/"] 1 0 1 razorTransition [] [@] 0 1 5 razorDirective [] [model] +0 6 8 variable [razorCode] [AppThing] +0 8 1 operator [razorCode] [.] +0 1 5 variable [razorCode] [Model] 1 0 1 razorTransition [] [@] 0 1 5 keyword [razorCode] [using] 0 5 1 markupTextLiteral [razorCode] [ ] diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/Legacy_with_background.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/Legacy_with_background.txt index ac3405ba765..fb6b3070a03 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/Legacy_with_background.txt +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/Legacy_with_background.txt @@ -4,6 +4,9 @@ Line Δ, Char Δ, Length, Type, Modifier(s), Text 0 5 3 string [razorCode] ["/"] 1 0 1 razorTransition [] [@] 0 1 5 razorDirective [] [model] +0 6 8 variable [razorCode] [AppThing] +0 8 1 operator [razorCode] [.] +0 1 5 variable [razorCode] [Model] 1 0 1 razorTransition [] [@] 0 1 5 keyword [razorCode] [using] 0 5 1 markupTextLiteral [razorCode] [ ] diff --git a/src/Shared/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/IntermediateNodeWriter.cs b/src/Shared/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/IntermediateNodeWriter.cs index a69b24b522b..e6911308e13 100644 --- a/src/Shared/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/IntermediateNodeWriter.cs +++ b/src/Shared/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/IntermediateNodeWriter.cs @@ -186,6 +186,11 @@ public override void VisitSetKey(SetKeyIntermediateNode node) WriteContentNode(node, node.KeyValueToken?.Content); } + public override void VisitPropertyDeclaration(PropertyDeclarationIntermediateNode node) + { + WriteContentNode(node, node.PropertyType.Content, node.PropertyName, node.PropertyExpression); + } + void IExtensionIntermediateNodeVisitor.VisitExtension(RouteAttributeExtensionNode node) { WriteContentNode(node, node.Template.ToString());