Skip to content

Commit 03f14c4

Browse files
jaredparchsienkijjonescz
authored
Fuse/fix debugging info (#11658) (#11710)
* Fix sequence point emitting so we get debug information for content * Update tests * Update src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentRuntimeNodeWriter.cs * Update src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentRuntimeNodeWriter.cs * Update source generator tests * Update test comments * Add multiline test * Fix test * Add the ability to diff sequence points in tests Add some diffs to existing tests * Baselines 🤦 * Line endings * Update src/Shared/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorBaselineIntegrationTestBase.cs * Fix baseline --------- Co-authored-by: Chris Sienkiewicz <chsienki@microsoft.com> Co-authored-by: Jan Jones <jan.jones.cz@gmail.com>
1 parent 5f20402 commit 03f14c4

File tree

161 files changed

+768
-529
lines changed

Some content is hidden

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

161 files changed

+768
-529
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.
3737
#nullable disable
3838
);
3939
__builder.AddMarkupContent(2, "\r\n Hello world\r\n ");
40-
__builder.AddContent(3,
4140
#nullable restore
42-
#line (4,6)-(4,35) "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent.cshtml"
43-
string.Format("{0}", "Hello")
41+
#line (4,6)-(4,35) 24 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent.cshtml"
42+
__builder.AddContent(3, string.Format("{0}", "Hello")
4443

4544
#line default
4645
#line hidden

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
#nullable disable
55

6-
using System;
76
using System.Globalization;
87
using System.Linq;
98
using Microsoft.AspNetCore.Razor.Language.Components;
@@ -2318,14 +2317,14 @@ public void InvalidCode_EmptyTransition()
23182317
// Assert
23192318
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
23202319
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
2321-
CompileToAssembly(generated, DesignTime?[
2320+
CompileToAssembly(generated, DesignTime ? [
23222321
// x:\dir\subdir\Test\TestComponent.cshtml(3,7): error CS1525: Invalid expression term ';'
23232322
// __o = ;
23242323
Diagnostic(ErrorCode.ERR_InvalidExprTerm, ";").WithArguments(";").WithLocation(3, 7)
23252324
] : [
2326-
// (24,36): error CS1525: Invalid expression term ')'
2327-
// __builder.AddContent(3,
2328-
Diagnostic(ErrorCode.ERR_InvalidExprTerm, "").WithArguments(")").WithLocation(24, 36)
2325+
// x:\dir\subdir\Test\TestComponent.cshtml(3,2): error CS1525: Invalid expression term ')'
2326+
// __builder.AddContent(3,
2327+
Diagnostic(ErrorCode.ERR_InvalidExprTerm, "").WithArguments(")").WithLocation(3, 2)
23292328
]);
23302329
}
23312330

@@ -2374,6 +2373,25 @@ @layout System.Object
23742373
CompileToAssembly(generated);
23752374
}
23762375

2376+
[IntegrationTestFact]
2377+
public void Component_AddContent_Multiline()
2378+
{
2379+
// Act
2380+
var generated = CompileToCSharp(""""
2381+
@(@"This
2382+
is
2383+
a
2384+
multiline
2385+
string")
2386+
"""");
2387+
2388+
// Assert
2389+
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
2390+
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
2391+
var result = CompileToAssembly(generated);
2392+
AssertSequencePointsMatchBaseline(result, generated.CodeDocument);
2393+
}
2394+
23772395
#endregion
23782396

23792397
#region Bind
@@ -5069,7 +5087,8 @@ public class MyComponent : ComponentBase
50695087
// Assert
50705088
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
50715089
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
5072-
CompileToAssembly(generated);
5090+
var result = CompileToAssembly(generated);
5091+
AssertSequencePointsMatchBaseline(result, generated.CodeDocument);
50735092
}
50745093

50755094
[IntegrationTestFact]
@@ -5099,10 +5118,10 @@ public class MyComponent : ComponentBase
50995118
// Assert
51005119
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
51015120
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
5102-
CompileToAssembly(generated);
5121+
var result = CompileToAssembly(generated);
5122+
AssertSequencePointsMatchBaseline(result, generated.CodeDocument);
51035123
}
51045124

5105-
51065125
[IntegrationTestFact]
51075126
public void ChildComponent_WithGenericChildContent_SetsParameterName()
51085127
{
@@ -5318,7 +5337,8 @@ Some Content
53185337
// Assert
53195338
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
53205339
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
5321-
CompileToAssembly(generated);
5340+
var result = CompileToAssembly(generated);
5341+
AssertSequencePointsMatchBaseline(result, generated.CodeDocument);
53225342
}
53235343

53245344
[IntegrationTestFact]
@@ -5355,7 +5375,8 @@ public class MyComponent : ComponentBase
53555375
// Assert
53565376
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
53575377
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
5358-
CompileToAssembly(generated);
5378+
var result = CompileToAssembly(generated);
5379+
AssertSequencePointsMatchBaseline(result, generated.CodeDocument);
53595380
}
53605381

53615382
[IntegrationTestFact]
@@ -10605,9 +10626,9 @@ @layout MainLayout
1060510626
// x:\dir\subdir\Test\_Imports.razor(5,2): error CS0103: The name 'Foo' does not exist in the current context
1060610627
// Foo
1060710628
Diagnostic(ErrorCode.ERR_NameNotInContext, "Foo").WithArguments("Foo").WithLocation(5, 2),
10608-
// (33,13): error CS0103: The name '__builder' does not exist in the current context
10609-
// __builder.AddContent(0,
10610-
Diagnostic(ErrorCode.ERR_NameNotInContext, "__builder").WithArguments("__builder").WithLocation(41, 13)]);
10629+
// x:\dir\subdir\Test\_Imports.razor(5,2): error CS0103: The name '__builder' does not exist in the current context
10630+
// __builder.AddContent(0, Foo
10631+
Diagnostic(ErrorCode.ERR_NameNotInContext, "__builder").WithArguments("__builder").WithLocation(5, 2)]);
1061110632
}
1061210633

1061310634
[IntegrationTestFact]

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentRenderModeDirectiveIntegrationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ @rendermode Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer
108108

109109
CompileToAssembly(compilationResult,
110110
// x:\dir\subdir\Test\TestComponent.cshtml(1,2): error CS0103: The name 'rendermode' does not exist in the current context
111-
// __builder.AddContent(0, rendermode);
111+
// __builder.AddContent(0, rendermode
112112
Diagnostic(ErrorCode.ERR_NameNotInContext, "rendermode").WithArguments("rendermode").WithLocation(1, 2)
113113
);
114114
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
get_Header:
2+
IL_0000: (9,48)-(9,52) ""
3+
set_Header:
4+
IL_0000: (9,53)-(9,57) ""
5+
get_ChildContent:
6+
IL_0000: (12,46)-(12,50) ""
7+
set_ChildContent:
8+
IL_0000: (12,51)-(12,55) ""
9+
get_Footer:
10+
IL_0000: (15,40)-(15,44) ""
11+
set_Footer:
12+
IL_0000: (15,45)-(15,49) ""
13+
BuildRenderTree:
14+
IL_0001: (1,4)-(17,89) "x:\dir\subdir\Test\TestComponent.cshtml"
15+
IL_0066: (2,1)-(2,40) "x:\dir\subdir\Test\TestComponent.cshtml"
16+
<BuildRenderTree>b__2:
17+
IL_0001: (1,50)-(1,83) "x:\dir\subdir\Test\TestComponent.cshtml"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
get_Header:
2+
IL_0000: (9,48)-(9,52) ""
3+
set_Header:
4+
IL_0000: (9,53)-(9,57) ""
5+
get_ChildContent:
6+
IL_0000: (12,46)-(12,50) ""
7+
set_ChildContent:
8+
IL_0000: (12,51)-(12,55) ""
9+
get_Footer:
10+
IL_0000: (15,40)-(15,44) ""
11+
set_Footer:
12+
IL_0000: (15,45)-(15,49) ""
13+
BuildRenderTree:
14+
IL_0001: (1,4)-(17,89) "x:\dir\subdir\Test\TestComponent.cshtml"
15+
IL_0092: (2,1)-(2,40) "x:\dir\subdir\Test\TestComponent.cshtml"
16+
<BuildRenderTree>b__3:
17+
IL_0001: (1,50)-(1,83) "x:\dir\subdir\Test\TestComponent.cshtml"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
get_MyAttr:
2+
IL_0000: (9,32)-(9,36) ""
3+
set_MyAttr:
4+
IL_0000: (9,37)-(9,41) ""
5+
get_ChildContent:
6+
IL_0000: (12,46)-(12,50) ""
7+
set_ChildContent:
8+
IL_0000: (12,51)-(12,55) ""
9+
BuildRenderTree:
10+
IL_003f: (1,1)-(1,40) "x:\dir\subdir\Test\TestComponent.cshtml"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
get_MyAttr:
2+
IL_0000: (9,32)-(9,36) ""
3+
set_MyAttr:
4+
IL_0000: (9,37)-(9,41) ""
5+
get_ChildContent:
6+
IL_0000: (12,54)-(12,58) ""
7+
set_ChildContent:
8+
IL_0000: (12,59)-(12,63) ""
9+
BuildRenderTree:
10+
IL_003f: (1,1)-(1,40) "x:\dir\subdir\Test\TestComponent.cshtml"
11+
<BuildRenderTree>b__1:
12+
IL_0001: (1,49)-(1,82) "x:\dir\subdir\Test\TestComponent.cshtml"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// <auto-generated/>
2+
#pragma warning disable 1591
3+
namespace Test
4+
{
5+
#line default
6+
using global::System;
7+
using global::System.Collections.Generic;
8+
using global::System.Linq;
9+
using global::System.Threading.Tasks;
10+
using global::Microsoft.AspNetCore.Components;
11+
#line default
12+
#line hidden
13+
#nullable restore
14+
public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase
15+
#nullable disable
16+
{
17+
#pragma warning disable 219
18+
private void __RazorDirectiveTokenHelpers__() {
19+
}
20+
#pragma warning restore 219
21+
#pragma warning disable 0414
22+
private static object __o = null;
23+
#pragma warning restore 0414
24+
#pragma warning disable 1998
25+
protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
26+
{
27+
#nullable restore
28+
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
29+
__o = @"This
30+
is
31+
a
32+
multiline
33+
string";
34+
35+
#line default
36+
#line hidden
37+
#nullable disable
38+
}
39+
#pragma warning restore 1998
40+
}
41+
}
42+
#pragma warning restore 1591
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Document -
2+
NamespaceDeclaration - - Test
3+
UsingDirective - (3:1,1 [20] ) - global::System
4+
UsingDirective - (26:2,1 [40] ) - global::System.Collections.Generic
5+
UsingDirective - (69:3,1 [25] ) - global::System.Linq
6+
UsingDirective - (97:4,1 [36] ) - global::System.Threading.Tasks
7+
UsingDirective - (136:5,1 [45] ) - global::Microsoft.AspNetCore.Components
8+
ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase -
9+
DesignTimeDirective -
10+
CSharpCode -
11+
IntermediateToken - - CSharp - #pragma warning disable 0414
12+
CSharpCode -
13+
IntermediateToken - - CSharp - private static object __o = null;
14+
CSharpCode -
15+
IntermediateToken - - CSharp - #pragma warning restore 0414
16+
MethodDeclaration - - protected override - void - BuildRenderTree
17+
CSharpExpression - (2:0,2 [33] x:\dir\subdir\Test\TestComponent.cshtml)
18+
LazyIntermediateToken - (2:0,2 [33] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - @"This\nis\na\nmultiline\nstring"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Source Location: (2:0,2 [33] x:\dir\subdir\Test\TestComponent.cshtml)
2+
|@"This
3+
is
4+
a
5+
multiline
6+
string"|
7+
Generated Location: (991:28,6 [33] )
8+
|@"This
9+
is
10+
a
11+
multiline
12+
string"|
13+

0 commit comments

Comments
 (0)