Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FUSE] Add some missing runtime source mappings #9883

Merged
merged 4 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public override void WriteUsingDirective(CodeRenderingContext context, UsingDire
{
using (context.CodeWriter.BuildLinePragma(node.Source.Value, context))
{
context.AddSourceMappingFor(node);
context.CodeWriter.WriteUsing(node.Content);
}
}
Expand Down Expand Up @@ -73,6 +74,7 @@ public override void WriteCSharpExpression(CodeRenderingContext context, CSharpE
{
if (node.Children[i] is IntermediateToken token && token.IsCSharp)
{
context.AddSourceMappingFor(token);
context.CodeWriter.Write(token.Content);
}
else
Expand Down Expand Up @@ -116,6 +118,7 @@ public override void WriteCSharpCode(CodeRenderingContext context, CSharpCodeInt
{
if (node.Children[i] is IntermediateToken token && token.IsCSharp)
{
context.AddSourceMappingFor(token);
context.CodeWriter.Write(token.Content);
}
else
Expand Down Expand Up @@ -232,6 +235,7 @@ public override void WriteCSharpExpressionAttributeValue(CodeRenderingContext co
{
if (node.Children[i] is IntermediateToken token && token.IsCSharp)
{
context.AddSourceMappingFor(token);
context.CodeWriter.Write(token.Content);
}
else
Expand Down Expand Up @@ -295,6 +299,7 @@ public override void WriteCSharpCodeAttributeValue(CodeRenderingContext context,
continue;
}

context.AddSourceMappingFor(token);
context.CodeWriter.Write(token.Content);

if (linePragmaScope != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public override void WriteCSharpExpression(CodeRenderingContext context, CSharpE
{
if (node.Children[i] is IntermediateToken token && token.IsCSharp)
{
context.AddSourceMappingFor(token);
WriteCSharpToken(context, token, includeLinePragma: false);
}
else
Expand Down Expand Up @@ -352,6 +353,7 @@ public override void WriteUsingDirective(CodeRenderingContext context, UsingDire
{
using (context.CodeWriter.BuildLinePragma(node.Source.Value, context))
{
context.AddSourceMappingFor(node);
context.CodeWriter.WriteUsing(node.Content);
}
}
Expand Down Expand Up @@ -1215,6 +1217,8 @@ private static void WriteCSharpToken(CodeRenderingContext context, IntermediateT
using (context.CodeWriter.BuildLinePragma(token.Source, context))
{
context.CodeWriter.WritePadding(0, token.Source.Value, context);

context.AddSourceMappingFor(token);
context.CodeWriter.Write(token.Content);
}
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ internal void RenderTagHelperAttributeInline(
}
else if (node is IntermediateToken token)
{
if (context.Options.DesignTime && node.Source != null)
if (node.Source != null)
{
context.AddSourceMappingFor(node);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
Source Location: (60:2,7 [42] x:\dir\subdir\Test\TestComponent.cshtml)
Source Location: (26:0,26 [1] x:\dir\subdir\Test\TestComponent.cshtml)
|c|
Generated Location: (767:18,26 [1] )
|c|

Source Location: (44:0,44 [1] x:\dir\subdir\Test\TestComponent.cshtml)
|c|
Generated Location: (953:26,44 [1] )
|c|

Source Location: (60:2,7 [42] x:\dir\subdir\Test\TestComponent.cshtml)
|
private MyClass<string> c = new();
|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
Source Location: (161:6,7 [42] x:\dir\subdir\Test\TestComponent.cshtml)
Source Location: (55:1,19 [4] x:\dir\subdir\Test\TestComponent.cshtml)
|true|
Generated Location: (760:18,19 [4] )
|true|

Source Location: (112:3,23 [9] x:\dir\subdir\Test\TestComponent.cshtml)
|() => { }|
Generated Location: (938:26,23 [9] )
|() => { }|

Source Location: (145:4,21 [1] x:\dir\subdir\Test\TestComponent.cshtml)
|c|
Generated Location: (1109:34,21 [1] )
|c|

Source Location: (32:0,32 [1] x:\dir\subdir\Test\TestComponent.cshtml)
|c|
Generated Location: (1283:42,32 [1] )
|c|

Source Location: (161:6,7 [42] x:\dir\subdir\Test\TestComponent.cshtml)
|
private MyClass<string> c = new();
|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
Source Location: (42:2,7 [34] x:\dir\subdir\Test\TestComponent.cshtml)
Source Location: (26:0,26 [1] x:\dir\subdir\Test\TestComponent.cshtml)
|c|
Generated Location: (791:19,26 [1] )
|c|

Source Location: (42:2,7 [34] x:\dir\subdir\Test\TestComponent.cshtml)
|
private MyClass c = new();
|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
Source Location: (48:2,7 [68] x:\dir\subdir\Test\TestComponent.cshtml)
Source Location: (26:0,26 [7] x:\dir\subdir\Test\TestComponent.cshtml)
|c1 = c2|
Generated Location: (791:19,26 [7] )
|c1 = c2|

Source Location: (48:2,7 [68] x:\dir\subdir\Test\TestComponent.cshtml)
|
private MyClass c1 = new();
private MyClass c2 = new();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
Source Location: (180:7,7 [42] x:\dir\subdir\Test\TestComponent.cshtml)
Source Location: (26:0,26 [1] x:\dir\subdir\Test\TestComponent.cshtml)
|c|
Generated Location: (767:18,26 [1] )
|c|

Source Location: (43:1,13 [9] x:\dir\subdir\Test\TestComponent.cshtml)
|() => { }|
Generated Location: (997:26,13 [9] )
|() => { }|

Source Location: (74:2,19 [4] x:\dir\subdir\Test\TestComponent.cshtml)
|true|
Generated Location: (1167:34,19 [4] )
|true|

Source Location: (131:4,23 [9] x:\dir\subdir\Test\TestComponent.cshtml)
|() => { }|
Generated Location: (1345:42,23 [9] )
|() => { }|

Source Location: (164:5,21 [1] x:\dir\subdir\Test\TestComponent.cshtml)
|c|
Generated Location: (1516:50,21 [1] )
|c|

Source Location: (180:7,7 [42] x:\dir\subdir\Test\TestComponent.cshtml)
|
private MyClass<string> c = new();
|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
Source Location: (155:6,7 [51] x:\dir\subdir\Test\TestComponent.cshtml)
Source Location: (26:0,26 [1] x:\dir\subdir\Test\TestComponent.cshtml)
|c|
Generated Location: (767:18,26 [1] )
|c|

Source Location: (49:1,19 [4] x:\dir\subdir\Test\TestComponent.cshtml)
|true|
Generated Location: (928:26,19 [4] )
|true|

Source Location: (106:3,23 [9] x:\dir\subdir\Test\TestComponent.cshtml)
|() => { }|
Generated Location: (1106:34,23 [9] )
|() => { }|

Source Location: (139:4,21 [1] x:\dir\subdir\Test\TestComponent.cshtml)
|c|
Generated Location: (1277:42,21 [1] )
|c|

Source Location: (155:6,7 [51] x:\dir\subdir\Test\TestComponent.cshtml)
|
private readonly MyClass<string> c = new();
|
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Source Location: (1:0,1 [30] x:\dir\subdir\Test\TestComponent.cshtml)
|using System.Threading.Tasks
|
Generated Location: (317:11,0 [30] )
|using System.Threading.Tasks;|
Copy link
Member

@jjonescz jjonescz Jan 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The source location has a newline as the last character while the generated location has a semicolon there instead. Perhaps the mapping should be one character shorter?

I wonder if we should assert that source and generated location texts match so we don't have to check this manually.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generated location also includes a semi-colon. I think this would be a problem, yes.

I wonder if we should assert that source and generated location texts match

I thought there was such a validation, maybe its just not called in all cases. Pretty sure I've hit it once or twice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh huh, good catch. I'll add the assertion if we don't have it, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, it turns out fixing the using discrepancy is significantly more involved, as it's actually a difference in parsing that's occurring.

I've backed out the using mappings from this PR, rather than try and fix a huge amount of stuff in one go.


Source Location: (32:1,1 [43] x:\dir\subdir\Test\TestComponent.cshtml)
|using Microsoft.AspNetCore.Components.Web
|
Generated Location: (468:18,0 [43] )
|using Microsoft.AspNetCore.Components.Web;|

Source Location: (94:2,19 [33] x:\dir\subdir\Test\TestComponent.cshtml)
|async (e) => await Task.Delay(10)|
Generated Location: (1165:32,19 [33] )
|async (e) => await Task.Delay(10)|

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
Source Location: (112:3,7 [88] x:\dir\subdir\Test\TestComponent.cshtml)
|
Task OnClick(MouseEventArgs e)
{
return Task.CompletedTask;
}
|
Generated Location: (1404:43,7 [88] )
|
Task OnClick(MouseEventArgs e)
{
return Task.CompletedTask;
}
|

Source Location: (1:0,1 [30] x:\dir\subdir\Test\TestComponent.cshtml)
|using System.Threading.Tasks
|
Generated Location: (317:11,0 [30] )
|using System.Threading.Tasks;|

Source Location: (32:1,1 [43] x:\dir\subdir\Test\TestComponent.cshtml)
|using Microsoft.AspNetCore.Components.Web
|
Generated Location: (468:18,0 [43] )
|using Microsoft.AspNetCore.Components.Web;|

Source Location: (92:2,17 [7] x:\dir\subdir\Test\TestComponent.cshtml)
|OnClick|
Generated Location: (1163:32,17 [7] )
|OnClick|

Source Location: (112:3,7 [88] x:\dir\subdir\Test\TestComponent.cshtml)
|
Task OnClick(MouseEventArgs e)
{
return Task.CompletedTask;
}
|
Generated Location: (1404:43,7 [88] )
|
Task OnClick(MouseEventArgs e)
{
return Task.CompletedTask;
}
|

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Source Location: (1:0,1 [30] x:\dir\subdir\Test\TestComponent.cshtml)
|using System.Threading.Tasks
|
Generated Location: (317:11,0 [30] )
|using System.Threading.Tasks;|

Source Location: (32:1,1 [43] x:\dir\subdir\Test\TestComponent.cshtml)
|using Microsoft.AspNetCore.Components.Web
|
Generated Location: (468:18,0 [43] )
|using Microsoft.AspNetCore.Components.Web;|

Source Location: (94:2,19 [32] x:\dir\subdir\Test\TestComponent.cshtml)
|async () => await Task.Delay(10)|
Generated Location: (1165:32,19 [32] )
|async () => await Task.Delay(10)|

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
Source Location: (112:3,7 [72] x:\dir\subdir\Test\TestComponent.cshtml)
|
Task OnClick()
{
return Task.CompletedTask;
}
|
Generated Location: (1404:43,7 [72] )
|
Task OnClick()
{
return Task.CompletedTask;
}
|

Source Location: (1:0,1 [30] x:\dir\subdir\Test\TestComponent.cshtml)
|using System.Threading.Tasks
|
Generated Location: (317:11,0 [30] )
|using System.Threading.Tasks;|

Source Location: (32:1,1 [43] x:\dir\subdir\Test\TestComponent.cshtml)
|using Microsoft.AspNetCore.Components.Web
|
Generated Location: (468:18,0 [43] )
|using Microsoft.AspNetCore.Components.Web;|

Source Location: (92:2,17 [7] x:\dir\subdir\Test\TestComponent.cshtml)
|OnClick|
Generated Location: (1163:32,17 [7] )
|OnClick|

Source Location: (112:3,7 [72] x:\dir\subdir\Test\TestComponent.cshtml)
|
Task OnClick()
{
return Task.CompletedTask;
}
|
Generated Location: (1404:43,7 [72] )
|
Task OnClick()
{
return Task.CompletedTask;
}
|

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
Source Location: (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml)
Source Location: (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml)
|ParentValue|
Generated Location: (895:19,26 [11] )
|ParentValue|

Source Location: (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml)
|
public int ParentValue { get; set; } = 42;
|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
Source Location: (54:1,7 [65] x:\dir\subdir\Test\TestComponent.cshtml)
Source Location: (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml)
|ParentValue|
Generated Location: (771:18,30 [11] )
|ParentValue|

Source Location: (54:1,7 [65] x:\dir\subdir\Test\TestComponent.cshtml)
|
public DateTime ParentValue { get; set; } = DateTime.Now;
|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
Source Location: (54:1,7 [89] x:\dir\subdir\Test\TestComponent.cshtml)
Source Location: (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml)
|ParentValue|
Generated Location: (771:18,30 [11] )
|ParentValue|

Source Location: (54:1,7 [89] x:\dir\subdir\Test\TestComponent.cshtml)
|
public IEnumerable<DateTime> ParentValue { get; set; } = new [] { DateTime.Now };
|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
Source Location: (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml)
Source Location: (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml)
|ParentValue|
Generated Location: (895:19,26 [11] )
|ParentValue|

Source Location: (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml)
|
public int ParentValue { get; set; } = 42;
|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
Source Location: (50:1,7 [55] x:\dir\subdir\Test\TestComponent.cshtml)
Source Location: (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml)
|ParentValue|
Generated Location: (895:19,26 [11] )
|ParentValue|

Source Location: (50:1,7 [55] x:\dir\subdir\Test\TestComponent.cshtml)
|
public string ParentValue { get; set; } = "42";
|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
Source Location: (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml)
Source Location: (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml)
|ParentValue|
Generated Location: (895:19,26 [11] )
|ParentValue|

Source Location: (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml)
|
public int ParentValue { get; set; } = 42;
|
Expand Down
Loading