Skip to content

Commit 6352a32

Browse files
authored
Ensure @model types have a mapping in razor pages (#11844)
* Add assert to existing test * Return the actual token from GetModelType * Add type mapping and expression to property intermediate node * Use a property node, not raw intermediate token
1 parent 368c0c0 commit 6352a32

File tree

44 files changed

+193
-105
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+193
-105
lines changed

src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ModelDirectiveTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ @model Type2
4646
var documentNode = processor.GetDocumentNode();
4747

4848
// Act
49-
var result = ModelDirective.GetModelType(documentNode);
49+
var result = ModelDirective.GetModelType(documentNode).Content;
5050

5151
// Assert
5252
Assert.Equal("Type1", result);
@@ -61,7 +61,7 @@ public void ModelDirective_GetModelType_DefaultsToDynamic()
6161
var documentNode = processor.GetDocumentNode();
6262

6363
// Act
64-
var result = ModelDirective.GetModelType(documentNode);
64+
var result = ModelDirective.GetModelType(documentNode).Content;
6565

6666
// Assert
6767
Assert.Equal("dynamic", result);

src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ModelDirectiveTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ @model Type2
4646
var documentNode = processor.GetDocumentNode();
4747

4848
// Act
49-
var result = ModelDirective.GetModelType(documentNode);
49+
var result = ModelDirective.GetModelType(documentNode).Content;
5050

5151
// Assert
5252
Assert.Equal("Type1", result);
@@ -61,7 +61,7 @@ public void ModelDirective_GetModelType_DefaultsToDynamic()
6161
var documentNode = processor.GetDocumentNode();
6262

6363
// Act
64-
var result = ModelDirective.GetModelType(documentNode);
64+
var result = ModelDirective.GetModelType(documentNode).Content;
6565

6666
// Assert
6767
Assert.Equal("dynamic", result);

src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/IntegrationTests/CodeGenerationIntegrationTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ public void RazorPagesWithRouteTemplate_Runtime()
442442
// Assert
443443
AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode());
444444
AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument());
445+
AssertSourceMappingsMatchBaseline(compiled.CodeDocument);
445446
AssertLinePragmas(compiled.CodeDocument, designTime: false);
446447
}
447448

src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ModelDirectiveTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ @model Type2
4343
var documentNode = processor.GetDocumentNode();
4444

4545
// Act
46-
var result = ModelDirective.GetModelType(documentNode);
46+
var result = ModelDirective.GetModelType(documentNode).Content;
4747

4848
// Assert
4949
Assert.Equal("Type1", result);
@@ -58,7 +58,7 @@ public void ModelDirective_GetModelType_DefaultsToDynamic()
5858
var documentNode = processor.GetDocumentNode();
5959

6060
// Act
61-
var result = ModelDirective.GetModelType(documentNode);
61+
var result = ModelDirective.GetModelType(documentNode).Content;
6262

6363
// Assert
6464
Assert.Equal("dynamic", result);

src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,7 @@ internal sealed class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_I
8181
#nullable restore
8282
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives> ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives>)PageContext?.ViewData!;
8383
#nullable disable
84-
#nullable restore
85-
public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives Model => ViewData.Model!;
86-
#nullable disable
84+
public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives Model => ViewData.Model;
8785
}
8886
}
8987
#pragma warning restore 1591

src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,4 @@
6060
Inject -
6161
CSharpCode -
6262
IntermediateToken - - CSharp - #nullable restore\npublic global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives> ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives>)PageContext?.ViewData!;\n#nullable disable
63-
CSharpCode -
64-
IntermediateToken - - CSharp - #nullable restore\npublic TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives Model => ViewData.Model!;\n#nullable disable
63+
PropertyDeclaration - - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives - Model - ViewData.Model

src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsDirective_RazorPages_Runtime.codegen.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ internal sealed class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_t
5757
#nullable restore
5858
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test> ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test>)PageContext?.ViewData!;
5959
#nullable disable
60-
#nullable restore
61-
public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test Model => ViewData.Model!;
62-
#nullable disable
60+
public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test Model => ViewData.Model;
6361
}
6462
}
6563
#pragma warning restore 1591

src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsDirective_RazorPages_Runtime.ir.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,4 @@
2020
Inject -
2121
CSharpCode -
2222
IntermediateToken - - CSharp - #nullable restore\npublic global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test> ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test>)PageContext?.ViewData!;\n#nullable disable
23-
CSharpCode -
24-
IntermediateToken - - CSharp - #nullable restore\npublic TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test Model => ViewData.Model!;\n#nullable disable
23+
PropertyDeclaration - - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test - Model - ViewData.Model

src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.codegen.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,15 @@ internal sealed class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_I
7979
#nullable restore
8080
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<MyModel> ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<MyModel>)PageContext?.ViewData!;
8181
#nullable disable
82-
#nullable restore
83-
public MyModel Model => ViewData.Model!;
82+
public
83+
#nullable restore
84+
#line (2,8)-(2,15) "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml"
85+
MyModel
86+
87+
#line default
88+
#line hidden
8489
#nullable disable
90+
Model => ViewData.Model;
8591
}
8692
}
8793
#pragma warning restore 1591

src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.ir.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,4 @@
2121
Inject -
2222
CSharpCode -
2323
IntermediateToken - - CSharp - #nullable restore\npublic global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<MyModel> ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<MyModel>)PageContext?.ViewData!;\n#nullable disable
24-
CSharpCode -
25-
IntermediateToken - - CSharp - #nullable restore\npublic MyModel Model => ViewData.Model!;\n#nullable disable
24+
PropertyDeclaration - - MyModel - Model - ViewData.Model

src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.codegen.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ internal sealed class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_M
5050
#nullable restore
5151
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective> ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective>)PageContext?.ViewData!;
5252
#nullable disable
53-
#nullable restore
54-
public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective Model => ViewData.Model!;
55-
#nullable disable
53+
public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective Model => ViewData.Model;
5654
}
5755
}
5856
#pragma warning restore 1591

src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.ir.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,4 @@
3232
Inject -
3333
CSharpCode -
3434
IntermediateToken - - CSharp - #nullable restore\npublic global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective> ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective>)PageContext?.ViewData!;\n#nullable disable
35-
CSharpCode -
36-
IntermediateToken - - CSharp - #nullable restore\npublic TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective Model => ViewData.Model!;\n#nullable disable
35+
PropertyDeclaration - - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective - Model - ViewData.Model

src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.codegen.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ internal sealed class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_P
5050
#nullable restore
5151
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace> ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace>)PageContext?.ViewData!;
5252
#nullable disable
53-
#nullable restore
54-
public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace Model => ViewData.Model!;
55-
#nullable disable
53+
public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace Model => ViewData.Model;
5654
}
5755
}
5856
#pragma warning restore 1591

src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.ir.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,4 @@
2626
Inject -
2727
CSharpCode -
2828
IntermediateToken - - CSharp - #nullable restore\npublic global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace> ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace>)PageContext?.ViewData!;\n#nullable disable
29-
CSharpCode -
30-
IntermediateToken - - CSharp - #nullable restore\npublic TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace Model => ViewData.Model!;\n#nullable disable
29+
PropertyDeclaration - - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace - Model - ViewData.Model

src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_Runtime.codegen.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ internal sealed class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_R
5050
#nullable restore
5151
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPageWithNoLeadingPageDirective> ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPageWithNoLeadingPageDirective>)PageContext?.ViewData!;
5252
#nullable disable
53-
#nullable restore
54-
public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPageWithNoLeadingPageDirective Model => ViewData.Model!;
55-
#nullable disable
53+
public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPageWithNoLeadingPageDirective Model => ViewData.Model;
5654
}
5755
}
5856
#pragma warning restore 1591

src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_Runtime.ir.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,4 @@
2626
Inject -
2727
CSharpCode -
2828
IntermediateToken - - CSharp - #nullable restore\npublic global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPageWithNoLeadingPageDirective> ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPageWithNoLeadingPageDirective>)PageContext?.ViewData!;\n#nullable disable
29-
CSharpCode -
30-
IntermediateToken - - CSharp - #nullable restore\npublic TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPageWithNoLeadingPageDirective Model => ViewData.Model!;\n#nullable disable
29+
PropertyDeclaration - - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPageWithNoLeadingPageDirective - Model - ViewData.Model

src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithCssScope.codegen.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,7 @@ internal sealed class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_t
115115
#nullable restore
116116
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test> ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test>)PageContext?.ViewData!;
117117
#nullable disable
118-
#nullable restore
119-
public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test Model => ViewData.Model!;
120-
#nullable disable
118+
public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test Model => ViewData.Model;
121119
}
122120
}
123121
#pragma warning restore 1591

src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithCssScope.ir.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,4 @@
8080
Inject -
8181
CSharpCode -
8282
IntermediateToken - - CSharp - #nullable restore\npublic global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test> ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test>)PageContext?.ViewData!;\n#nullable disable
83-
CSharpCode -
84-
IntermediateToken - - CSharp - #nullable restore\npublic TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test Model => ViewData.Model!;\n#nullable disable
83+
PropertyDeclaration - - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test - Model - ViewData.Model

src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithNonNullableModel_LangNew_Runtime.codegen.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,15 @@ internal sealed class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_t
7676
#nullable restore
7777
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestModel> ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestModel>)PageContext?.ViewData!;
7878
#nullable disable
79-
#nullable restore
80-
public TestModel Model => ViewData.Model!;
79+
public
80+
#nullable restore
81+
#line (3,8)-(3,17) "TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml"
82+
TestModel
83+
84+
#line default
85+
#line hidden
8186
#nullable disable
87+
Model => ViewData.Model;
8288
}
8389
}
8490
#pragma warning restore 1591

src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithNonNullableModel_LangNew_Runtime.ir.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,4 @@
3636
Inject -
3737
CSharpCode -
3838
IntermediateToken - - CSharp - #nullable restore\npublic global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestModel> ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestModel>)PageContext?.ViewData!;\n#nullable disable
39-
CSharpCode -
40-
IntermediateToken - - CSharp - #nullable restore\npublic TestModel Model => ViewData.Model!;\n#nullable disable
39+
PropertyDeclaration - - TestModel - Model - ViewData.Model

src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithNonNullableModel_LangNew_Runtime.mappings.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@ Source Location: (78:6,5 [14] TestFiles\IntegrationTests\CodeGenerationIntegrati
1313
Generated Location: (2328:46,0 [14] )
1414
|Model?.Address|
1515

16+
Source Location: (36:2,7 [9] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml)
17+
|TestModel|
18+
Generated Location: (4123:81,0 [9] )
19+
|TestModel|
20+

src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithNullableModel_LangNew_Runtime.codegen.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,15 @@ internal sealed class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_t
7676
#nullable restore
7777
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestModel?> ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestModel?>)PageContext?.ViewData!;
7878
#nullable disable
79-
#nullable restore
80-
public TestModel? Model => ViewData.Model!;
79+
public
80+
#nullable restore
81+
#line (3,8)-(3,18) "TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml"
82+
TestModel?
83+
84+
#line default
85+
#line hidden
8186
#nullable disable
87+
Model => ViewData.Model;
8288
}
8389
}
8490
#pragma warning restore 1591

src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithNullableModel_LangNew_Runtime.ir.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,4 @@
3636
Inject -
3737
CSharpCode -
3838
IntermediateToken - - CSharp - #nullable restore\npublic global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestModel?> ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestModel?>)PageContext?.ViewData!;\n#nullable disable
39-
CSharpCode -
40-
IntermediateToken - - CSharp - #nullable restore\npublic TestModel? Model => ViewData.Model!;\n#nullable disable
39+
PropertyDeclaration - - TestModel? - Model - ViewData.Model

src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPage_WithNullableModel_LangNew_Runtime.mappings.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@ Source Location: (79:6,5 [14] TestFiles\IntegrationTests\CodeGenerationIntegrati
1313
Generated Location: (2328:46,0 [14] )
1414
|Model?.Address|
1515

16+
Source Location: (36:2,7 [10] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml)
17+
|TestModel?|
18+
Generated Location: (4126:81,0 [10] )
19+
|TestModel?|
20+

src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_Runtime.codegen.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,15 @@ public class NewModel : PageModel
9090
#nullable restore
9191
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<NewModel> ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<NewModel>)PageContext?.ViewData!;
9292
#nullable disable
93-
#nullable restore
94-
public NewModel Model => ViewData.Model!;
93+
public
94+
#nullable restore
95+
#line (3,8)-(3,16) "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml"
96+
NewModel
97+
98+
#line default
99+
#line hidden
95100
#nullable disable
101+
Model => ViewData.Model;
96102
}
97103
}
98104
#pragma warning restore 1591

src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_Runtime.ir.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,4 @@
3838
Inject -
3939
CSharpCode -
4040
IntermediateToken - - CSharp - #nullable restore\npublic global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<NewModel> ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<NewModel>)PageContext?.ViewData!;\n#nullable disable
41-
CSharpCode -
42-
IntermediateToken - - CSharp - #nullable restore\npublic NewModel Model => ViewData.Model!;\n#nullable disable
41+
PropertyDeclaration - - NewModel - Model - ViewData.Model
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Source Location: (36:3,1 [41] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml)
2+
|using Microsoft.AspNetCore.Mvc.RazorPages|
3+
Generated Location: (1098:16,0 [41] )
4+
|using Microsoft.AspNetCore.Mvc.RazorPages|
5+
6+
Source Location: (6:0,6 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml)
7+
|"/About"|
8+
Generated Location: (1464:26,0 [8] )
9+
|"/About"|
10+
11+
Source Location: (6:0,6 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml)
12+
|"/About"|
13+
Generated Location: (1464:26,0 [8] )
14+
|"/About"|
15+
16+
Source Location: (213:12,18 [10] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml)
17+
|Model.Name|
18+
Generated Location: (2690:48,0 [10] )
19+
|Model.Name|
20+
21+
Source Location: (93:5,12 [97] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml)
22+
|
23+
public class NewModel : PageModel
24+
{
25+
public string Name { get; set; }
26+
}
27+
|
28+
Generated Location: (2991:59,0 [97] )
29+
|
30+
public class NewModel : PageModel
31+
{
32+
public string Name { get; set; }
33+
}
34+
|
35+
36+
Source Location: (25:2,7 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml)
37+
|NewModel|
38+
Generated Location: (4788:95,0 [8] )
39+
|NewModel|
40+

src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.codegen.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,7 @@ public class Customer
187187
#nullable restore
188188
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel> ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel>)PageContext?.ViewData!;
189189
#nullable disable
190-
#nullable restore
191-
public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel Model => ViewData.Model!;
192-
#nullable disable
190+
public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel Model => ViewData.Model;
193191
}
194192
}
195193
#pragma warning restore 1591

0 commit comments

Comments
 (0)