Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
Code span at (13:0,13 [4] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (13:0,13 [9] )
Code span at (17:0,17 [1] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (17:0,17 [5] )
Code span at (18:0,18 [4] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (17:0,17 [5] )
Code span at (17:0,17 [5] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (17:0,17 [5] )
Code span at (22:0,22 [2] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (13:0,13 [11] )
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@
Transition;[<Missing>];
CSharpImplicitExpressionBody - [17..22)::5
CSharpCodeBlock - [17..22)::5
CSharpExpressionLiteral - [17..18)::1 - [@] - Gen<Expr> - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K15
Transition;[@];
CSharpExpressionLiteral - [18..22)::4 - [true] - Gen<Expr> - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K15
Keyword;[true];
CSharpExpressionLiteral - [17..22)::5 - [@true] - Gen<Expr> - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K15
Keyword;[@true];
CSharpExpressionLiteral - [22..24)::2 - [ ] - Gen<None> - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K15
Whitespace;[ ];
MarkupTextLiteral - [24..25)::1 - ['] - Gen<Markup> - SpanEditHandler;Accepts:Any
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
Code span at (13:0,13 [1] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (13:0,13 [19] )
Code span at (14:0,14 [1] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (14:0,14 [18] )
Code span at (15:0,15 [17] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (14:0,14 [18] )
Code span at (14:0,14 [18] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (14:0,14 [18] )
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@
Transition;[<Missing>];
CSharpImplicitExpressionBody - [14..32)::18
CSharpCodeBlock - [14..32)::18
CSharpExpressionLiteral - [14..15)::1 - [@] - Gen<Expr> - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K15
Transition;[@];
CSharpExpressionLiteral - [15..32)::17 - [DateTime.Now.Year] - Gen<Expr> - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K15
Identifier;[DateTime];
CSharpExpressionLiteral - [14..32)::18 - [@DateTime.Now.Year] - Gen<Expr> - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K15
Identifier;[@DateTime];
Dot;[.];
Identifier;[Now];
Dot;[.];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
Code span at (13:0,13 [1] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (13:0,13 [14] )
Code span at (14:0,14 [2] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (13:0,13 [14] )
Code span at (16:0,16 [1] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (16:0,16 [7] )
Code span at (17:0,17 [1] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (17:0,17 [6] )
Code span at (18:0,18 [5] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (17:0,17 [6] )
Code span at (17:0,17 [6] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (17:0,17 [6] )
Code span at (23:0,23 [2] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (13:0,13 [14] )
Code span at (25:0,25 [2] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (13:0,13 [14] )
Code span at (39:0,39 [6] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (39:0,39 [46] )
Code span at (45:0,45 [1] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (45:0,45 [11] )
Code span at (46:0,46 [10] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (45:0,45 [11] )
Code span at (45:0,45 [11] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (45:0,45 [11] )
Code span at (56:0,56 [2] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (39:0,39 [46] )
Code span at (58:0,58 [2] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (58:0,58 [3] )
Code span at (60:0,60 [1] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (58:0,58 [3] )
Code span at (61:0,61 [8] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (39:0,39 [46] )
Code span at (69:0,69 [2] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (39:0,39 [46] )
Code span at (71:0,71 [1] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (71:0,71 [14] )
Code span at (72:0,72 [1] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (72:0,72 [13] )
Code span at (73:0,73 [12] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (72:0,72 [13] )
Code span at (72:0,72 [13] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (72:0,72 [13] )
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@
Transition;[<Missing>];
CSharpImplicitExpressionBody - [17..23)::6
CSharpCodeBlock - [17..23)::6
CSharpExpressionLiteral - [17..18)::1 - [@] - Gen<Expr> - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K15
Transition;[@];
CSharpExpressionLiteral - [18..23)::5 - [value] - Gen<Expr> - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K15
Identifier;[value];
CSharpExpressionLiteral - [17..23)::6 - [@value] - Gen<Expr> - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K15
Identifier;[@value];
CSharpExpressionLiteral - [23..25)::2 - [ +] - Gen<None> - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K15
Whitespace;[ ];
Text;[+];
Expand All @@ -57,10 +55,8 @@
Transition;[<Missing>];
CSharpImplicitExpressionBody - [45..56)::11
CSharpCodeBlock - [45..56)::11
CSharpExpressionLiteral - [45..46)::1 - [@] - Gen<Expr> - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K15
Transition;[@];
CSharpExpressionLiteral - [46..56)::10 - [Bag["val"]] - Gen<Expr> - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K15
Identifier;[Bag];
CSharpExpressionLiteral - [45..56)::11 - [@Bag["val"]] - Gen<Expr> - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K15
Identifier;[@Bag];
LeftBracket;[[];
StringLiteral;["val"];
RightBracket;[]];
Expand All @@ -87,10 +83,8 @@
Transition;[<Missing>];
CSharpImplicitExpressionBody - [72..85)::13
CSharpCodeBlock - [72..85)::13
CSharpExpressionLiteral - [72..73)::1 - [@] - Gen<Expr> - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K15
Transition;[@];
CSharpExpressionLiteral - [73..85)::12 - [DateTime.Now] - Gen<Expr> - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K15
Identifier;[DateTime];
CSharpExpressionLiteral - [72..85)::13 - [@DateTime.Now] - Gen<Expr> - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K15
Identifier;[@DateTime];
Dot;[.];
Identifier;[Now];
MarkupTextLiteral - [85..86)::1 - ['] - Gen<Markup> - SpanEditHandler;Accepts:Any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Runtime.CompilerServices;
using Microsoft.AspNetCore.Razor.Language.Extensions;
using Microsoft.AspNetCore.Razor.Test.Common;
using Roslyn.Test.Utilities;

namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests;

Expand Down Expand Up @@ -255,6 +256,9 @@ public class CodeGenerationIntegrationTest(bool designTime = false)
[IntegrationTestFact]
public void AddTagHelperDirective() => RunTest();

[IntegrationTestFact, WorkItem("https://github.com/dotnet/razor/issues/10186")]
public void EscapedIdentifier() => RunTagHelpersTest(TestTagHelperDescriptors.SimpleTagHelperDescriptors);

public override string GetTestFileName(string testName)
{
return base.GetTestFileName(testName) + (designTime ? "_DesignTime" : "_Runtime");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Collections.Immutable;
using System.Globalization;
using Microsoft.AspNetCore.Razor.Language.Components;
using Roslyn.Test.Utilities;
using Xunit;
using static Microsoft.AspNetCore.Razor.Language.CommonMetadata;

Expand Down Expand Up @@ -555,6 +556,83 @@ public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes12()
EvaluateData(CodeTagHelperAttributes_Descriptors, "<person age=\"@{flag == 0 ? 11 : 12}\" />");
}

[Fact, WorkItem("https://github.com/dotnet/razor/issues/10186")]
public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes13()
{
EvaluateData(CodeTagHelperAttributes_Descriptors, """
@{
var count = "1";
}
<person age="Convert.ToInt32(@count)" />
""");
}

[Fact, WorkItem("https://github.com/dotnet/razor/issues/10186")]
public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes14()
{
EvaluateData(CodeTagHelperAttributes_Descriptors, """
@{
var @string = "1";
}
<person age="Convert.ToInt32(@string)" />
""");
}

[Fact, WorkItem("https://github.com/dotnet/razor/issues/10186")]
public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes15()
{
EvaluateData(CodeTagHelperAttributes_Descriptors, """
@{
var count = "1";
}
<person age=Convert.ToInt32(@count) />
""");
}

[Fact, WorkItem("https://github.com/dotnet/razor/issues/10186")]
public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes16()
{
EvaluateData(CodeTagHelperAttributes_Descriptors, """
@{
var count = "1";
}
<person age='Convert.ToInt32(@count + "2")' />
""");
}

[Fact, WorkItem("https://github.com/dotnet/razor/issues/10186")]
public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes17()
{
EvaluateData(CodeTagHelperAttributes_Descriptors, """
@{
var count = 1;
}
<person age='@@count' />
""");
}

[Fact, WorkItem("https://github.com/dotnet/razor/issues/10186")]
public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes18()
{
EvaluateData(CodeTagHelperAttributes_Descriptors, """
@{
var count = 1;
}
<person age="@@count" />
""");
}

[Fact, WorkItem("https://github.com/dotnet/razor/issues/10186")]
public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes19()
{
EvaluateData(CodeTagHelperAttributes_Descriptors, """
@{
var count = 1;
}
<person age=@@count />
""");
}

[Fact]
public void TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper1()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,7 @@
LazyIntermediateToken - (933:25,21 [2] ComplexTagHelpers.cshtml) - CSharp - +
LazyIntermediateToken - (935:25,23 [1] ComplexTagHelpers.cshtml) - CSharp -
CSharpExpression - (936:25,24 [24] ComplexTagHelpers.cshtml)
LazyIntermediateToken - (936:25,24 [1] ComplexTagHelpers.cshtml) - CSharp - @
LazyIntermediateToken - (937:25,25 [23] ComplexTagHelpers.cshtml) - CSharp - DateTimeOffset.Now.Year
LazyIntermediateToken - (936:25,24 [24] ComplexTagHelpers.cshtml) - CSharp - @DateTimeOffset.Now.Year
DefaultTagHelperExecute -
HtmlContent - (1075:27,12 [10] ComplexTagHelpers.cshtml)
LazyIntermediateToken - (1075:27,12 [10] ComplexTagHelpers.cshtml) - Html - \n
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,10 @@ Source Location: (935:25,23 [1] TestFiles/IntegrationTests/CodeGenerationIntegra
Generated Location: (9254:213,40 [1] )
| |

Source Location: (936:25,24 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml)
|@|
Generated Location: (9255:213,41 [1] )
|@|

Source Location: (937:25,25 [23] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml)
|DateTimeOffset.Now.Year|
Generated Location: (9256:213,42 [23] )
|DateTimeOffset.Now.Year|
Source Location: (936:25,24 [24] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml)
|@DateTimeOffset.Now.Year|
Generated Location: (9255:213,41 [24] )
|@DateTimeOffset.Now.Year|

Source Location: (1155:29,28 [30] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml)
|DateTimeOffset.Now.Year > 2014|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,15 +493,8 @@ public async System.Threading.Tasks.Task ExecuteAsync()
#line hidden
#nullable disable
#nullable restore
#line (26,25)-(26,26) "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml"
@

#line default
#line hidden
#nullable disable
#nullable restore
#line (26,26)-(26,49) "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml"
DateTimeOffset.Now.Year
Comment on lines -496 to -504
Copy link
Member Author

Choose a reason for hiding this comment

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

If we had been validating C# diagnostics, this would have been caught before FUSE was merged. More priority to #10247.

#line (26,25)-(26,49) "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml"
@DateTimeOffset.Now.Year

#line default
#line hidden
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,7 @@
LazyIntermediateToken - (933:25,21 [2] ComplexTagHelpers.cshtml) - CSharp - +
LazyIntermediateToken - (935:25,23 [1] ComplexTagHelpers.cshtml) - CSharp -
CSharpExpression - (936:25,24 [24] ComplexTagHelpers.cshtml)
LazyIntermediateToken - (936:25,24 [1] ComplexTagHelpers.cshtml) - CSharp - @
LazyIntermediateToken - (937:25,25 [23] ComplexTagHelpers.cshtml) - CSharp - DateTimeOffset.Now.Year
LazyIntermediateToken - (936:25,24 [24] ComplexTagHelpers.cshtml) - CSharp - @DateTimeOffset.Now.Year
DefaultTagHelperExecute -
HtmlContent - (1075:27,12 [10] ComplexTagHelpers.cshtml)
LazyIntermediateToken - (1075:27,12 [10] ComplexTagHelpers.cshtml) - Html - \n
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@addTagHelper "*, TestAssembly"

@{
var count = "1";
}
<input age="Convert.ToInt32(@count)" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// <auto-generated/>
#pragma warning disable 1591
namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles
{
#line hidden
public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EscapedIdentifier_DesignTime
{
#line hidden
#pragma warning disable 0649
private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext __tagHelperExecutionContext;
#pragma warning restore 0649
private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner __tagHelperRunner = new global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner();
private global::InputTagHelper __InputTagHelper;
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
((global::System.Action)(() => {
#nullable restore
#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedIdentifier.cshtml"
global::System.Object __typeHelper = "*, TestAssembly";

#line default
#line hidden
#nullable disable
}
))();
}
#pragma warning restore 219
#pragma warning disable 0414
private static object __o = null;
#pragma warning restore 0414
#pragma warning disable 1998
public async System.Threading.Tasks.Task ExecuteAsync()
{
#nullable restore
#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedIdentifier.cshtml"

var count = "1";

#line default
#line hidden
#nullable disable
__InputTagHelper = CreateTagHelper<global::InputTagHelper>();
#nullable restore
#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedIdentifier.cshtml"
__InputTagHelper.AgeProp = Convert.ToInt32(@count);

#line default
#line hidden
#nullable disable
await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
}
#pragma warning restore 1998
}
}
#pragma warning restore 1591
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
~~~~~~~~~~~~~ ~~~ ~~~~~~~~~~~~~

~~
~~~ ~~~~~ ~ ~~~~
~
<input age="~~~~~~~~~~~~~~~~~~~~~~~" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Source Location: (13:0,13 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedIdentifier.cshtml)
| |
Generated Location: (13:0,13 [1] )
| |

Source Location: (31:0,31 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedIdentifier.cshtml)
|

|
Generated Location: (31:0,31 [4] )
|

|

Source Location: (62:4,1 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedIdentifier.cshtml)
|
<input age="|
Generated Location: (62:4,1 [14] )
|
<input age="|

Source Location: (99:5,35 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedIdentifier.cshtml)
|" />
|
Generated Location: (99:5,35 [6] )
|" />
|

Loading