Skip to content

Commit df56bdb

Browse files
authored
[main] Revert "Map component start tags to C#, for better GTD, FAR, Hover, etc. (#12287) (#12486)
Backport of #12485 to main /cc @davidwengier ## Customer Impact ## Regression - [ ] Yes - [ ] No [If yes, specify when the regression was introduced. Provide the PR or commit if known.] ## Testing [How was the fix verified? How was the issue missed previously? What tests were added?] ## Risk [High/Medium/Low. Justify the indication by mentioning how risks were measured and addressed.]
2 parents d62ba62 + 1f3723e commit df56bdb

File tree

555 files changed

+1196
-5791
lines changed

Some content is hidden

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

555 files changed

+1196
-5791
lines changed

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,9 +2242,9 @@ public class MyComponent : ComponentBase
22422242
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
22432243
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
22442244
CompileToAssembly(generated, designTime ? [] : [
2245-
// (29,55): error CS0120: An object reference is required for the non-static field, method, or property 'MyComponent.Value'
2245+
// (21,55): error CS0120: An object reference is required for the non-static field, method, or property 'MyComponent.Value'
22462246
// __builder.AddComponentParameter(1, nameof(global::Test.MyComponent.
2247-
Diagnostic(ErrorCode.ERR_ObjectRequired, "global::Test.MyComponent.\r\n#nullable restore\r\n#line (1,14)-(1,19) \"x:\\dir\\subdir\\Test\\TestComponent.cshtml\"\r\nValue").WithArguments("Test.MyComponent.Value").WithLocation(29, 55)
2247+
Diagnostic(ErrorCode.ERR_ObjectRequired, "global::Test.MyComponent.\r\n#nullable restore\r\n#line (1,14)-(1,19) \"x:\\dir\\subdir\\Test\\TestComponent.cshtml\"\r\nValue").WithArguments("Test.MyComponent.Value").WithLocation(21, 55)
22482248
]);
22492249
}
22502250

@@ -2462,12 +2462,12 @@ public class MyComponent : ComponentBase
24622462
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
24632463
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
24642464
CompileToAssembly(generated, designTime ? [] : [
2465-
// (29,55): error CS0120: An object reference is required for the non-static field, method, or property 'MyComponent.Value'
2465+
// (21,55): error CS0120: An object reference is required for the non-static field, method, or property 'MyComponent.Value'
24662466
// __builder.AddComponentParameter(1, nameof(global::Test.MyComponent.
2467-
Diagnostic(ErrorCode.ERR_ObjectRequired, "global::Test.MyComponent.\r\n#nullable restore\r\n#line (1,20)-(1,25) \"x:\\dir\\subdir\\Test\\TestComponent.cshtml\"\r\nValue").WithArguments("Test.MyComponent.Value").WithLocation(29, 55),
2468-
// (46,55): error CS0120: An object reference is required for the non-static field, method, or property 'MyComponent.ValueChanged'
2467+
Diagnostic(ErrorCode.ERR_ObjectRequired, "global::Test.MyComponent.\r\n#nullable restore\r\n#line (1,20)-(1,25) \"x:\\dir\\subdir\\Test\\TestComponent.cshtml\"\r\nValue").WithArguments("Test.MyComponent.Value").WithLocation(21, 55),
2468+
// (38,55): error CS0120: An object reference is required for the non-static field, method, or property 'MyComponent.ValueChanged'
24692469
// __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.ValueChanged), (global::System.Action<System.Int32>)(__value => ParentValue = __value));
2470-
Diagnostic(ErrorCode.ERR_ObjectRequired, "global::Test.MyComponent.ValueChanged").WithArguments("Test.MyComponent.ValueChanged").WithLocation(46, 55)
2470+
Diagnostic(ErrorCode.ERR_ObjectRequired, "global::Test.MyComponent.ValueChanged").WithArguments("Test.MyComponent.ValueChanged").WithLocation(38, 55)
24712471
]);
24722472
}
24732473

@@ -2625,9 +2625,9 @@ public class MyComponent : ComponentBase
26252625
: [// x:\dir\subdir\Test\TestComponent.cshtml(1,27): error CS1503: Argument 1: cannot convert from 'string' to 'int'
26262626
// ParentValue
26272627
Diagnostic(ErrorCode.ERR_BadArgType, "ParentValue").WithArguments("1", "string", "int").WithLocation(1, 27),
2628-
// (46,166): error CS0029: Cannot implicitly convert type 'int' to 'string'
2628+
// (38,166): error CS0029: Cannot implicitly convert type 'int' to 'string'
26292629
// __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.ValueChanged), (global::System.Action<global::System.Int32>)(__value => ParentValue = __value));
2630-
Diagnostic(ErrorCode.ERR_NoImplicitConv, "__value").WithArguments("int", "string").WithLocation(46, 166)]);
2630+
Diagnostic(ErrorCode.ERR_NoImplicitConv, "__value").WithArguments("int", "string").WithLocation(38, 166)]);
26312631
}
26322632

26332633
[IntegrationTestFact]
@@ -2704,9 +2704,9 @@ public class MyComponent : ComponentBase
27042704
: [// x:\dir\subdir\Test\TestComponent.cshtml(1,27): error CS1503: Argument 1: cannot convert from 'string' to 'int'
27052705
// ParentValue
27062706
Diagnostic(ErrorCode.ERR_BadArgType, "ParentValue").WithArguments("1", "string", "int").WithLocation(1, 27),
2707-
// (46,351): error CS1503: Argument 2: cannot convert from 'Microsoft.AspNetCore.Components.EventCallback<string>' to 'Microsoft.AspNetCore.Components.EventCallback'
2707+
// (38,351): error CS1503: Argument 2: cannot convert from 'Microsoft.AspNetCore.Components.EventCallback<string>' to 'Microsoft.AspNetCore.Components.EventCallback'
27082708
// global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => ParentValue = __value, ParentValue)));
2709-
Diagnostic(ErrorCode.ERR_BadArgType, "global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => ParentValue = __value, ParentValue)").WithArguments("2", "Microsoft.AspNetCore.Components.EventCallback<string>", "Microsoft.AspNetCore.Components.EventCallback").WithLocation(46, 351)
2709+
Diagnostic(ErrorCode.ERR_BadArgType, "global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => ParentValue = __value, ParentValue)").WithArguments("2", "Microsoft.AspNetCore.Components.EventCallback<string>", "Microsoft.AspNetCore.Components.EventCallback").WithLocation(38, 351)
27102710
]
27112711
);
27122712
}
@@ -2911,12 +2911,12 @@ public class MyComponent : ComponentBase
29112911
// (38,195): error CS1662: Cannot convert lambda expression to intended delegate type because some of the return types in the block are not implicitly convertible to the delegate return type
29122912
// __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck<global::System.Linq.Expressions.Expression<global::System.Func<global::System.String>>>(() => ParentValue);
29132913
Diagnostic(ErrorCode.ERR_CantConvAnonMethReturns, "ParentValue").WithArguments("lambda expression").WithLocation(38, 195)]
2914-
: [// (47,274): error CS0029: Cannot implicitly convert type 'int' to 'string'
2914+
: [// (39,274): error CS0029: Cannot implicitly convert type 'int' to 'string'
29152915
// __builder.AddComponentParameter(3, nameof(global::Test.MyComponent.ValueExpression), global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck<global::System.Linq.Expressions.Expression<global::System.Func<global::System.String>>>(() => ParentValue));
2916-
Diagnostic(ErrorCode.ERR_NoImplicitConv, "ParentValue").WithArguments("int", "string").WithLocation(47, 274),
2917-
// (47,274): error CS1662: Cannot convert lambda expression to intended delegate type because some of the return types in the block are not implicitly convertible to the delegate return type
2916+
Diagnostic(ErrorCode.ERR_NoImplicitConv, "ParentValue").WithArguments("int", "string").WithLocation(39, 274),
2917+
// (39,274): error CS1662: Cannot convert lambda expression to intended delegate type because some of the return types in the block are not implicitly convertible to the delegate return type
29182918
// __builder.AddComponentParameter(3, nameof(global::Test.MyComponent.ValueExpression), global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck<global::System.Linq.Expressions.Expression<global::System.Func<global::System.String>>>(() => ParentValue));
2919-
Diagnostic(ErrorCode.ERR_CantConvAnonMethReturns, "ParentValue").WithArguments("lambda expression").WithLocation(47, 274)
2919+
Diagnostic(ErrorCode.ERR_CantConvAnonMethReturns, "ParentValue").WithArguments("lambda expression").WithLocation(39, 274)
29202920
]);
29212921
}
29222922

@@ -10909,7 +10909,7 @@ public class Counter : ComponentBase
1090910909
// Assert
1091010910
CompileToAssembly(generated);
1091110911
Assert.DoesNotContain("<Counter", generated.Code);
10912-
Assert.Contains("global::MyComponents.", generated.Code);
10912+
Assert.Contains("global::MyComponents.Counter", generated.Code);
1091310913
}
1091410914

1091510915
[IntegrationTestFact]
@@ -11811,9 +11811,9 @@ public class MyComponent : ComponentBase
1181111811
: [// x:\dir\subdir\Test\TestComponent.cshtml(1,32): error CS1003: Syntax error, ',' expected
1181211812
// x
1181311813
Diagnostic(ErrorCode.ERR_SyntaxError, "").WithArguments(",").WithLocation(1, 32),
11814-
// (37,88): error CS1501: No overload for method 'TypeCheck' takes 2 arguments
11814+
// (29,88): error CS1501: No overload for method 'TypeCheck' takes 2 arguments
1181511815
// __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck<global::System.String>(
11816-
Diagnostic(ErrorCode.ERR_BadArgCount, "TypeCheck<global::System.String>").WithArguments("TypeCheck", "2").WithLocation(37, 88)]
11816+
Diagnostic(ErrorCode.ERR_BadArgCount, "TypeCheck<global::System.String>").WithArguments("TypeCheck", "2").WithLocation(29, 88)]
1181711817
);
1181811818
Assert.NotEmpty(generated.RazorDiagnostics);
1181911819
}

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AddAttribute_ImplicitBooleanConversion/TestComponent.codegen.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,7 @@ internal static class TypeInference
5454
{
5555
public static void CreateMyComponent_0<T>(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, global::Test.MyClass<T> __arg0, int __seq1, global::System.Boolean __arg1)
5656
{
57-
__builder.OpenComponent<global::Test.
58-
#nullable restore
59-
#line (1,2)-(1,13) "x:\dir\subdir\Test\TestComponent.cshtml"
60-
MyComponent
61-
62-
#line default
63-
#line hidden
64-
#nullable disable
65-
<T>>(seq);
57+
__builder.OpenComponent<global::Test.MyComponent<T>>(seq);
6658
__builder.AddAttribute(__seq0, nameof(global::Test.MyComponent<T>.
6759
#nullable restore
6860
#line (1,14)-(1,25) "x:\dir\subdir\Test\TestComponent.cshtml"

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AddAttribute_ImplicitBooleanConversion/TestComponent.mappings.txt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,13 @@ Generated Location: (1189:40,0 [42] )
1717
private MyClass<string> c = new();
1818
|
1919

20-
Source Location: (1:0,1 [11] x:\dir\subdir\Test\TestComponent.cshtml)
21-
|MyComponent|
22-
Generated Location: (1766:59,0 [11] )
23-
|MyComponent|
24-
2520
Source Location: (13:0,13 [11] x:\dir\subdir\Test\TestComponent.cshtml)
2621
|MyParameter|
27-
Generated Location: (2007:68,0 [11] )
22+
Generated Location: (1864:60,0 [11] )
2823
|MyParameter|
2924

3025
Source Location: (29:0,29 [13] x:\dir\subdir\Test\TestComponent.cshtml)
3126
|BoolParameter|
32-
Generated Location: (2257:77,0 [13] )
27+
Generated Location: (2114:69,0 [13] )
3328
|BoolParameter|
3429

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AddAttribute_ImplicitStringConversion_Bind/TestComponent.codegen.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,7 @@ internal static class TypeInference
7070
{
7171
public static void CreateMyComponent_0<T>(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, global::System.Boolean __arg0, int __seq1, global::System.String __arg1, int __seq2, global::System.Delegate __arg2, int __seq3, global::System.Object __arg3, int __seq4, global::Test.MyClass<T> __arg4, int __seq5, global::Microsoft.AspNetCore.Components.EventCallback<global::Test.MyClass<T>> __arg5)
7272
{
73-
__builder.OpenComponent<global::Test.
74-
#nullable restore
75-
#line (1,2)-(1,13) "x:\dir\subdir\Test\TestComponent.cshtml"
76-
MyComponent
77-
78-
#line default
79-
#line hidden
80-
#nullable disable
81-
<T>>(seq);
73+
__builder.OpenComponent<global::Test.MyComponent<T>>(seq);
8274
__builder.AddAttribute(__seq0, nameof(global::Test.MyComponent<T>.
8375
#nullable restore
8476
#line (2,5)-(2,18) "x:\dir\subdir\Test\TestComponent.cshtml"

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AddAttribute_ImplicitStringConversion_Bind/TestComponent.mappings.txt

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,33 +27,28 @@ Generated Location: (1731:56,0 [42] )
2727
private MyClass<string> c = new();
2828
|
2929

30-
Source Location: (1:0,1 [11] x:\dir\subdir\Test\TestComponent.cshtml)
31-
|MyComponent|
32-
Generated Location: (2535:75,0 [11] )
33-
|MyComponent|
34-
3530
Source Location: (40:1,4 [13] x:\dir\subdir\Test\TestComponent.cshtml)
3631
|BoolParameter|
37-
Generated Location: (2775:84,0 [13] )
32+
Generated Location: (2632:76,0 [13] )
3833
|BoolParameter|
3934

4035
Source Location: (66:2,4 [15] x:\dir\subdir\Test\TestComponent.cshtml)
4136
|StringParameter|
42-
Generated Location: (3026:93,0 [15] )
37+
Generated Location: (2883:85,0 [15] )
4338
|StringParameter|
4439

4540
Source Location: (93:3,4 [17] x:\dir\subdir\Test\TestComponent.cshtml)
4641
|DelegateParameter|
47-
Generated Location: (3279:102,0 [17] )
42+
Generated Location: (3136:94,0 [17] )
4843
|DelegateParameter|
4944

5045
Source Location: (128:4,4 [15] x:\dir\subdir\Test\TestComponent.cshtml)
5146
|ObjectParameter|
52-
Generated Location: (3534:111,0 [15] )
47+
Generated Location: (3391:103,0 [15] )
5348
|ObjectParameter|
5449

5550
Source Location: (19:0,19 [11] x:\dir\subdir\Test\TestComponent.cshtml)
5651
|MyParameter|
57-
Generated Location: (3788:120,0 [11] )
52+
Generated Location: (3645:112,0 [11] )
5853
|MyParameter|
5954

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AddAttribute_ImplicitStringConversion_BindUnknown/TestComponent.codegen.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,7 @@ public partial class TestComponent : global::Microsoft.AspNetCore.Components.Com
1717
#pragma warning disable 1998
1818
protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
1919
{
20-
__builder.OpenComponent<global::Test.
21-
#nullable restore
22-
#line (1,2)-(1,13) "x:\dir\subdir\Test\TestComponent.cshtml"
23-
MyComponent
24-
25-
#line default
26-
#line hidden
27-
#nullable disable
28-
>(0);
20+
__builder.OpenComponent<global::Test.MyComponent>(0);
2921
__builder.AddAttribute(1, "Value", (object)(
3022
#nullable restore
3123
#line (1,27)-(1,28) "x:\dir\subdir\Test\TestComponent.cshtml"

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AddAttribute_ImplicitStringConversion_BindUnknown/TestComponent.mappings.txt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1-
Source Location: (1:0,1 [11] x:\dir\subdir\Test\TestComponent.cshtml)
2-
|MyComponent|
3-
Generated Location: (786:22,0 [11] )
4-
|MyComponent|
5-
6-
Source Location: (26:0,26 [1] x:\dir\subdir\Test\TestComponent.cshtml)
1+
Source Location: (26:0,26 [1] x:\dir\subdir\Test\TestComponent.cshtml)
72
|c|
8-
Generated Location: (1008:31,0 [1] )
3+
Generated Location: (861:23,0 [1] )
94
|c|
105

116
Source Location: (42:2,7 [34] x:\dir\subdir\Test\TestComponent.cshtml)
127
|
138
private MyClass c = new();
149
|
15-
Generated Location: (1448:43,0 [34] )
10+
Generated Location: (1301:35,0 [34] )
1611
|
1712
private MyClass c = new();
1813
|

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AddAttribute_ImplicitStringConversion_BindUnknown_Assignment/TestComponent.codegen.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,7 @@ public partial class TestComponent : global::Microsoft.AspNetCore.Components.Com
1717
#pragma warning disable 1998
1818
protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
1919
{
20-
__builder.OpenComponent<global::Test.
21-
#nullable restore
22-
#line (1,2)-(1,13) "x:\dir\subdir\Test\TestComponent.cshtml"
23-
MyComponent
24-
25-
#line default
26-
#line hidden
27-
#nullable disable
28-
>(0);
20+
__builder.OpenComponent<global::Test.MyComponent>(0);
2921
__builder.AddAttribute(1, "Value", (object)(
3022
#nullable restore
3123
#line (1,27)-(1,34) "x:\dir\subdir\Test\TestComponent.cshtml"

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AddAttribute_ImplicitStringConversion_BindUnknown_Assignment/TestComponent.mappings.txt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
1-
Source Location: (1:0,1 [11] x:\dir\subdir\Test\TestComponent.cshtml)
2-
|MyComponent|
3-
Generated Location: (786:22,0 [11] )
4-
|MyComponent|
5-
6-
Source Location: (26:0,26 [7] x:\dir\subdir\Test\TestComponent.cshtml)
1+
Source Location: (26:0,26 [7] x:\dir\subdir\Test\TestComponent.cshtml)
72
|c1 = c2|
8-
Generated Location: (1008:31,0 [7] )
3+
Generated Location: (861:23,0 [7] )
94
|c1 = c2|
105

116
Source Location: (48:2,7 [68] x:\dir\subdir\Test\TestComponent.cshtml)
127
|
138
private MyClass c1 = new();
149
private MyClass c2 = new();
1510
|
16-
Generated Location: (1466:43,0 [68] )
11+
Generated Location: (1319:35,0 [68] )
1712
|
1813
private MyClass c1 = new();
1914
private MyClass c2 = new();

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AddAttribute_ImplicitStringConversion_CustomEvent/TestComponent.codegen.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,7 @@ internal static class TypeInference
7878
{
7979
public static void CreateMyComponent_0<T>(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, global::Test.MyClass<T> __arg0, int __seq1, global::Microsoft.AspNetCore.Components.EventCallback __arg1, int __seq2, global::System.Boolean __arg2, int __seq3, global::System.String __arg3, int __seq4, global::System.Delegate __arg4, int __seq5, global::System.Object __arg5)
8080
{
81-
__builder.OpenComponent<global::Test.
82-
#nullable restore
83-
#line (1,2)-(1,13) "x:\dir\subdir\Test\TestComponent.cshtml"
84-
MyComponent
85-
86-
#line default
87-
#line hidden
88-
#nullable disable
89-
<T>>(seq);
81+
__builder.OpenComponent<global::Test.MyComponent<T>>(seq);
9082
__builder.AddAttribute(__seq0, nameof(global::Test.MyComponent<T>.
9183
#nullable restore
9284
#line (1,14)-(1,25) "x:\dir\subdir\Test\TestComponent.cshtml"

0 commit comments

Comments
 (0)