From 4b68a48f1d05c48f208040fc9e005ff113831953 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Mon, 28 Aug 2017 17:00:24 -0700 Subject: [PATCH] Fix: Broken intellisense for extensible directives --- .../DesignTimeDirectiveTargetExtension.cs | 29 +++++++++++++++ .../Legacy/CSharpCodeParser.cs | 9 +++++ ...IncompleteDirectives_DesignTime.codegen.cs | 21 +++++++++++ .../IncompleteDirectives_DesignTime.ir.txt | 14 +++++++ ...completeDirectives_DesignTime.mappings.txt | 37 ++++++++++++++++++- .../IncompleteDirectives_Runtime.ir.txt | 7 ++++ ...IncompleteDirectives_DesignTime.codegen.cs | 15 ++++++++ .../IncompleteDirectives_DesignTime.ir.txt | 10 +++++ ...completeDirectives_DesignTime.mappings.txt | 27 +++++++++++++- .../Legacy/CSharpDirectivesTest.cs | 4 +- .../Legacy/CSharpSectionTest.cs | 9 ++++- .../Legacy/CSharpSpecialBlockTest.cs | 8 +++- ...IncompleteDirectives_DesignTime.codegen.cs | 12 ++++++ .../IncompleteDirectives_DesignTime.ir.txt | 8 ++++ ...completeDirectives_DesignTime.mappings.txt | 20 ++++++++++ .../IncompleteDirectives_Runtime.ir.txt | 4 ++ 16 files changed, 227 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/DesignTimeDirectiveTargetExtension.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/DesignTimeDirectiveTargetExtension.cs index 8ba3733039..bc73343044 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Extensions/DesignTimeDirectiveTargetExtension.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/DesignTimeDirectiveTargetExtension.cs @@ -57,6 +57,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions { case DirectiveTokenKind.Type: + if (string.IsNullOrEmpty(node.Content)) + { + // This is most likely a marker symbol. + WriteMarkerSymbol(context, node); + break; + } + // {node.Content} __typeHelper = default({node.Content}); context.AddSourceMappingFor(node); @@ -71,6 +78,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions case DirectiveTokenKind.Member: + if (string.IsNullOrEmpty(node.Content)) + { + // This is most likely a marker symbol. + WriteMarkerSymbol(context, node); + break; + } + // global::System.Object {node.content} = null; context.CodeWriter @@ -86,6 +100,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions case DirectiveTokenKind.Namespace: + if (string.IsNullOrEmpty(node.Content)) + { + // This is most likely a marker symbol. + WriteMarkerSymbol(context, node); + break; + } + // global::System.Object __typeHelper = nameof({node.Content}); context.CodeWriter @@ -133,5 +154,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions } context.CodeWriter.WriteLine("))();"); } + + private void WriteMarkerSymbol(CodeRenderingContext context, DirectiveTokenIntermediateNode node) + { + // We want to map marker symbols to a location in the generated document + // that will provide CSharp intellisense. + context.AddSourceMappingFor(node); + context.CodeWriter.Write(" "); + } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpCodeParser.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpCodeParser.cs index 4f90d496b6..1f0c3aaad0 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpCodeParser.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpCodeParser.cs @@ -1665,6 +1665,15 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { Span.ChunkGenerator = SpanChunkGenerator.Null; Output(SpanKindInternal.Code, AcceptedCharactersInternal.WhiteSpace); + + if (EndOfFile || At(CSharpSymbolType.NewLine)) + { + // Add a marker symbol to provide CSharp intellisense when we start typing the directive token. + AddMarkerSymbolIfNecessary(); + Span.ChunkGenerator = new DirectiveTokenChunkGenerator(tokenDescriptor); + Span.EditHandler = new DirectiveTokenEditHandler(Language.TokenizeString); + Output(SpanKindInternal.Code, AcceptedCharactersInternal.NonWhiteSpace); + } } else { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs index 1a14b13feb..3e79145caf 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs @@ -16,8 +16,29 @@ namespace AspNetCore #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { ((System.Action)(() => { + } + ))(); + ((System.Action)(() => { + } + ))(); + ((System.Action)(() => { + } + ))(); + ((System.Action)(() => { + } + ))(); + ((System.Action)(() => { MyService __typeHelper = default(MyService); } + ))(); + ((System.Action)(() => { + } + ))(); + ((System.Action)(() => { + } + ))(); + ((System.Action)(() => { + } ))(); } #pragma warning restore 219 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt index e5d9732ac5..e6cca7f462 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt @@ -23,7 +23,14 @@ Document - DirectiveToken - (617:12,14 [96] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor DirectiveToken - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (119:6,6 [0] IncompleteDirectives.cshtml) - + DirectiveToken - (128:7,7 [0] IncompleteDirectives.cshtml) - + DirectiveToken - (139:9,7 [0] IncompleteDirectives.cshtml) - + DirectiveToken - (149:10,8 [0] IncompleteDirectives.cshtml) - DirectiveToken - (159:11,8 [17] IncompleteDirectives.cshtml) - MyService + DirectiveToken - (176:11,25 [0] IncompleteDirectives.cshtml) - + DirectiveToken - (190:13,10 [0] IncompleteDirectives.cshtml) - + DirectiveToken - (203:14,11 [0] IncompleteDirectives.cshtml) - CSharpCode - IntermediateToken - - CSharp - #pragma warning disable 0414 CSharpCode - @@ -38,25 +45,32 @@ Document - HtmlContent - (108:4,6 [5] IncompleteDirectives.cshtml) IntermediateToken - (108:4,6 [5] IncompleteDirectives.cshtml) - Html - "\n\n MalformedDirective - (113:6,0 [6] IncompleteDirectives.cshtml) - model + DirectiveToken - (119:6,6 [0] IncompleteDirectives.cshtml) - HtmlContent - (119:6,6 [2] IncompleteDirectives.cshtml) IntermediateToken - (119:6,6 [2] IncompleteDirectives.cshtml) - Html - \n MalformedDirective - (121:7,0 [7] IncompleteDirectives.cshtml) - model + DirectiveToken - (128:7,7 [0] IncompleteDirectives.cshtml) - HtmlContent - (128:7,7 [4] IncompleteDirectives.cshtml) IntermediateToken - (128:7,7 [4] IncompleteDirectives.cshtml) - Html - \n\n MalformedDirective - (132:9,0 [7] IncompleteDirectives.cshtml) - inject + DirectiveToken - (139:9,7 [0] IncompleteDirectives.cshtml) - HtmlContent - (139:9,7 [2] IncompleteDirectives.cshtml) IntermediateToken - (139:9,7 [2] IncompleteDirectives.cshtml) - Html - \n MalformedDirective - (141:10,0 [8] IncompleteDirectives.cshtml) - inject + DirectiveToken - (149:10,8 [0] IncompleteDirectives.cshtml) - HtmlContent - (149:10,8 [2] IncompleteDirectives.cshtml) IntermediateToken - (149:10,8 [2] IncompleteDirectives.cshtml) - Html - \n MalformedDirective - (151:11,0 [25] IncompleteDirectives.cshtml) - inject DirectiveToken - (159:11,8 [17] IncompleteDirectives.cshtml) - MyService + DirectiveToken - (176:11,25 [0] IncompleteDirectives.cshtml) - HtmlContent - (176:11,25 [4] IncompleteDirectives.cshtml) IntermediateToken - (176:11,25 [4] IncompleteDirectives.cshtml) - Html - \n\n MalformedDirective - (180:13,0 [10] IncompleteDirectives.cshtml) - namespace + DirectiveToken - (190:13,10 [0] IncompleteDirectives.cshtml) - HtmlContent - (190:13,10 [2] IncompleteDirectives.cshtml) IntermediateToken - (190:13,10 [2] IncompleteDirectives.cshtml) - Html - \n MalformedDirective - (192:14,0 [11] IncompleteDirectives.cshtml) - namespace + DirectiveToken - (203:14,11 [0] IncompleteDirectives.cshtml) - HtmlContent - (203:14,11 [2] IncompleteDirectives.cshtml) IntermediateToken - (203:14,11 [2] IncompleteDirectives.cshtml) - Html - \n Inject - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt index bb3e3bdbe3..77fa549e07 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt @@ -1,5 +1,40 @@ +Source Location: (119:6,6 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (678:18,0 [0] ) +|| + +Source Location: (128:7,7 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (731:21,0 [0] ) +|| + +Source Location: (139:9,7 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (784:24,0 [0] ) +|| + +Source Location: (149:10,8 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (837:27,0 [0] ) +|| + Source Location: (159:11,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) |MyService| -Generated Location: (678:18,0 [17] ) +Generated Location: (890:30,0 [17] ) |MyService| +Source Location: (176:11,25 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (1012:34,0 [0] ) +|| + +Source Location: (190:13,10 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (1065:37,0 [0] ) +|| + +Source Location: (203:14,11 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (1118:40,0 [0] ) +|| + diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt index 1ea163df4a..cea68367fe 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt @@ -26,6 +26,7 @@ Document - CSharpCode - IntermediateToken - - CSharp - EndContext(); MalformedDirective - (113:6,0 [6] IncompleteDirectives.cshtml) - model + DirectiveToken - (119:6,6 [0] IncompleteDirectives.cshtml) - CSharpCode - IntermediateToken - - CSharp - BeginContext(119, 2, true); HtmlContent - (119:6,6 [2] IncompleteDirectives.cshtml) @@ -33,6 +34,7 @@ Document - CSharpCode - IntermediateToken - - CSharp - EndContext(); MalformedDirective - (121:7,0 [7] IncompleteDirectives.cshtml) - model + DirectiveToken - (128:7,7 [0] IncompleteDirectives.cshtml) - CSharpCode - IntermediateToken - - CSharp - BeginContext(128, 4, true); HtmlContent - (128:7,7 [4] IncompleteDirectives.cshtml) @@ -40,6 +42,7 @@ Document - CSharpCode - IntermediateToken - - CSharp - EndContext(); MalformedDirective - (132:9,0 [7] IncompleteDirectives.cshtml) - inject + DirectiveToken - (139:9,7 [0] IncompleteDirectives.cshtml) - CSharpCode - IntermediateToken - - CSharp - BeginContext(139, 2, true); HtmlContent - (139:9,7 [2] IncompleteDirectives.cshtml) @@ -47,6 +50,7 @@ Document - CSharpCode - IntermediateToken - - CSharp - EndContext(); MalformedDirective - (141:10,0 [8] IncompleteDirectives.cshtml) - inject + DirectiveToken - (149:10,8 [0] IncompleteDirectives.cshtml) - CSharpCode - IntermediateToken - - CSharp - BeginContext(149, 2, true); HtmlContent - (149:10,8 [2] IncompleteDirectives.cshtml) @@ -55,6 +59,7 @@ Document - IntermediateToken - - CSharp - EndContext(); MalformedDirective - (151:11,0 [25] IncompleteDirectives.cshtml) - inject DirectiveToken - (159:11,8 [17] IncompleteDirectives.cshtml) - MyService + DirectiveToken - (176:11,25 [0] IncompleteDirectives.cshtml) - CSharpCode - IntermediateToken - - CSharp - BeginContext(176, 4, true); HtmlContent - (176:11,25 [4] IncompleteDirectives.cshtml) @@ -62,6 +67,7 @@ Document - CSharpCode - IntermediateToken - - CSharp - EndContext(); MalformedDirective - (180:13,0 [10] IncompleteDirectives.cshtml) - namespace + DirectiveToken - (190:13,10 [0] IncompleteDirectives.cshtml) - CSharpCode - IntermediateToken - - CSharp - BeginContext(190, 2, true); HtmlContent - (190:13,10 [2] IncompleteDirectives.cshtml) @@ -69,6 +75,7 @@ Document - CSharpCode - IntermediateToken - - CSharp - EndContext(); MalformedDirective - (192:14,0 [11] IncompleteDirectives.cshtml) - namespace + DirectiveToken - (203:14,11 [0] IncompleteDirectives.cshtml) - CSharpCode - IntermediateToken - - CSharp - BeginContext(203, 2, true); HtmlContent - (203:14,11 [2] IncompleteDirectives.cshtml) diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs index f47ba2071e..e213442d23 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs @@ -16,8 +16,23 @@ namespace AspNetCore #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { ((System.Action)(() => { + } + ))(); + ((System.Action)(() => { + } + ))(); + ((System.Action)(() => { + } + ))(); + ((System.Action)(() => { + } + ))(); + ((System.Action)(() => { MyService __typeHelper = default(MyService); } + ))(); + ((System.Action)(() => { + } ))(); } #pragma warning restore 219 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt index 79491f3568..ef934781a0 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt @@ -21,7 +21,12 @@ Document - DirectiveToken - (507:11,8 [70] ) - global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider DirectiveToken - (578:11,79 [23] ) - ModelExpressionProvider DirectiveToken - (617:12,14 [96] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (93:2,6 [0] IncompleteDirectives.cshtml) - + DirectiveToken - (102:3,7 [0] IncompleteDirectives.cshtml) - + DirectiveToken - (113:5,7 [0] IncompleteDirectives.cshtml) - + DirectiveToken - (123:6,8 [0] IncompleteDirectives.cshtml) - DirectiveToken - (133:7,8 [17] IncompleteDirectives.cshtml) - MyService + DirectiveToken - (150:7,25 [0] IncompleteDirectives.cshtml) - CSharpCode - IntermediateToken - - CSharp - #pragma warning disable 0414 CSharpCode - @@ -32,19 +37,24 @@ Document - HtmlContent - (83:0,83 [4] IncompleteDirectives.cshtml) IntermediateToken - (83:0,83 [4] IncompleteDirectives.cshtml) - Html - \n\n MalformedDirective - (87:2,0 [6] IncompleteDirectives.cshtml) - model + DirectiveToken - (93:2,6 [0] IncompleteDirectives.cshtml) - HtmlContent - (93:2,6 [2] IncompleteDirectives.cshtml) IntermediateToken - (93:2,6 [2] IncompleteDirectives.cshtml) - Html - \n MalformedDirective - (95:3,0 [7] IncompleteDirectives.cshtml) - model + DirectiveToken - (102:3,7 [0] IncompleteDirectives.cshtml) - HtmlContent - (102:3,7 [4] IncompleteDirectives.cshtml) IntermediateToken - (102:3,7 [4] IncompleteDirectives.cshtml) - Html - \n\n MalformedDirective - (106:5,0 [7] IncompleteDirectives.cshtml) - inject + DirectiveToken - (113:5,7 [0] IncompleteDirectives.cshtml) - HtmlContent - (113:5,7 [2] IncompleteDirectives.cshtml) IntermediateToken - (113:5,7 [2] IncompleteDirectives.cshtml) - Html - \n MalformedDirective - (115:6,0 [8] IncompleteDirectives.cshtml) - inject + DirectiveToken - (123:6,8 [0] IncompleteDirectives.cshtml) - HtmlContent - (123:6,8 [2] IncompleteDirectives.cshtml) IntermediateToken - (123:6,8 [2] IncompleteDirectives.cshtml) - Html - \n MalformedDirective - (125:7,0 [25] IncompleteDirectives.cshtml) - inject DirectiveToken - (133:7,8 [17] IncompleteDirectives.cshtml) - MyService + DirectiveToken - (150:7,25 [0] IncompleteDirectives.cshtml) - HtmlContent - (150:7,25 [2] IncompleteDirectives.cshtml) IntermediateToken - (150:7,25 [2] IncompleteDirectives.cshtml) - Html - \n Inject - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt index a0f227e239..27676d9e12 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt @@ -1,5 +1,30 @@ +Source Location: (93:2,6 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (687:18,0 [0] ) +|| + +Source Location: (102:3,7 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (740:21,0 [0] ) +|| + +Source Location: (113:5,7 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (793:24,0 [0] ) +|| + +Source Location: (123:6,8 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (846:27,0 [0] ) +|| + Source Location: (133:7,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) |MyService| -Generated Location: (687:18,0 [17] ) +Generated Location: (899:30,0 [17] ) |MyService| +Source Location: (150:7,25 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (1021:34,0 [0] ) +|| + diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpDirectivesTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpDirectivesTest.cs index 9d657bf0fd..e77d07f418 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpDirectivesTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpDirectivesTest.cs @@ -1747,7 +1747,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new DirectiveChunkGenerator(descriptor), Factory.CodeTransition(), Factory.MetaCode("TestDirective").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace))); + Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), + Factory.Span(SpanKindInternal.Code, string.Empty, CSharpSymbolType.Unknown) + .AsDirectiveToken(descriptor.Tokens[0]))); } [Fact] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSectionTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSectionTest.cs index 4681038d84..2966814826 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSectionTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSectionTest.cs @@ -30,7 +30,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.EmptyHtml(), new DirectiveBlock(chunkGenerator, Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None)), + Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), + Factory.Span(SpanKindInternal.Code, string.Empty, CSharpSymbolType.Unknown) + .AsDirectiveToken(DirectiveTokenDescriptor.CreateToken(DirectiveTokenKind.Member))), Factory.Markup(Environment.NewLine))); } @@ -82,7 +84,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new DirectiveBlock(chunkGenerator, Factory.CodeTransition(), Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace)), + Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), + Factory + .Span(SpanKindInternal.Code, string.Empty, CSharpSymbolType.Unknown) + .AsDirectiveToken(DirectiveTokenDescriptor.CreateToken(DirectiveTokenKind.Member))), Factory.Markup(Environment.NewLine + " "))); } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSpecialBlockTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSpecialBlockTest.cs index 5aa64332a0..69e78889f9 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSpecialBlockTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSpecialBlockTest.cs @@ -29,7 +29,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.EmptyHtml(), new DirectiveBlock(chunkGenerator, Factory.CodeTransition(), - Factory.MetaCode("inherits").Accepts(AcceptedCharactersInternal.None)), + Factory.MetaCode("inherits").Accepts(AcceptedCharactersInternal.None), + Factory.Span(SpanKindInternal.Code, string.Empty, CSharpSymbolType.Unknown) + .AsDirectiveToken(DirectiveTokenDescriptor.CreateToken(DirectiveTokenKind.Type))), Factory.EmptyHtml())); } @@ -69,7 +71,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new DirectiveBlock(chunkGenerator, Factory.CodeTransition(), Factory.MetaCode("inherits").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace)), + Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), + Factory.Span(SpanKindInternal.Code, string.Empty, CSharpSymbolType.Unknown) + .AsDirectiveToken(DirectiveTokenDescriptor.CreateToken(DirectiveTokenKind.Type))), Factory.Markup(Environment.NewLine + "foo"))); } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs index 45ce47888a..03f5c03321 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs @@ -42,6 +42,18 @@ global::System.Object __typeHelper = ""; ((System.Action)(() => { global::System.Object __typeHelper = "; } + ))(); + ((System.Action)(() => { + } + ))(); + ((System.Action)(() => { + } + ))(); + ((System.Action)(() => { + } + ))(); + ((System.Action)(() => { + } ))(); } #pragma warning restore 219 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt index f12791b06e..f21273aeb2 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt @@ -11,6 +11,10 @@ Document - DirectiveToken - (212:10,16 [0] IncompleteDirectives.cshtml) - DirectiveToken - (231:11,17 [0] IncompleteDirectives.cshtml) - DirectiveToken - (250:12,17 [1] IncompleteDirectives.cshtml) - " + DirectiveToken - (264:14,9 [0] IncompleteDirectives.cshtml) - + DirectiveToken - (276:15,10 [0] IncompleteDirectives.cshtml) - + DirectiveToken - (315:20,8 [0] IncompleteDirectives.cshtml) - + DirectiveToken - (326:21,9 [0] IncompleteDirectives.cshtml) - CSharpCode - IntermediateToken - - CSharp - #pragma warning disable 0414 CSharpCode - @@ -57,17 +61,21 @@ Document - HtmlContent - (251:12,18 [4] IncompleteDirectives.cshtml) IntermediateToken - (251:12,18 [4] IncompleteDirectives.cshtml) - Html - \n\n MalformedDirective - (255:14,0 [9] IncompleteDirectives.cshtml) - inherits + DirectiveToken - (264:14,9 [0] IncompleteDirectives.cshtml) - HtmlContent - (264:14,9 [2] IncompleteDirectives.cshtml) IntermediateToken - (264:14,9 [2] IncompleteDirectives.cshtml) - Html - \n MalformedDirective - (266:15,0 [10] IncompleteDirectives.cshtml) - inherits + DirectiveToken - (276:15,10 [0] IncompleteDirectives.cshtml) - HtmlContent - (276:15,10 [4] IncompleteDirectives.cshtml) IntermediateToken - (276:15,10 [4] IncompleteDirectives.cshtml) - Html - \n\n MalformedDirective - (280:17,0 [12] IncompleteDirectives.cshtml) - functions MalformedDirective - (292:18,0 [15] IncompleteDirectives.cshtml) - functions MalformedDirective - (307:20,0 [8] IncompleteDirectives.cshtml) - section + DirectiveToken - (315:20,8 [0] IncompleteDirectives.cshtml) - HtmlContent - (315:20,8 [2] IncompleteDirectives.cshtml) IntermediateToken - (315:20,8 [2] IncompleteDirectives.cshtml) - Html - \n MalformedDirective - (317:21,0 [9] IncompleteDirectives.cshtml) - section + DirectiveToken - (326:21,9 [0] IncompleteDirectives.cshtml) - HtmlContent - (326:21,9 [4] IncompleteDirectives.cshtml) IntermediateToken - (326:21,9 [4] IncompleteDirectives.cshtml) - Html - \n\n MalformedDirective - (330:23,0 [9] IncompleteDirectives.cshtml) - section diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt index 40ddc63fb9..b5f9ac8df5 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt @@ -43,3 +43,23 @@ Source Location: (250:12,17 [1] TestFiles/IntegrationTests/CodeGenerationIntegra Generated Location: (1240:42,37 [1] ) |"| +Source Location: (264:14,9 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (1304:46,0 [0] ) +|| + +Source Location: (276:15,10 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (1357:49,0 [0] ) +|| + +Source Location: (315:20,8 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (1410:52,0 [0] ) +|| + +Source Location: (326:21,9 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (1463:55,0 [0] ) +|| + diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt index ba23934871..aad13cff1a 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt @@ -29,17 +29,21 @@ Document - HtmlContent - (253:13,0 [2] IncompleteDirectives.cshtml) IntermediateToken - (253:13,0 [2] IncompleteDirectives.cshtml) - Html - \n MalformedDirective - (255:14,0 [9] IncompleteDirectives.cshtml) - inherits + DirectiveToken - (264:14,9 [0] IncompleteDirectives.cshtml) - HtmlContent - (264:14,9 [2] IncompleteDirectives.cshtml) IntermediateToken - (264:14,9 [2] IncompleteDirectives.cshtml) - Html - \n MalformedDirective - (266:15,0 [10] IncompleteDirectives.cshtml) - inherits + DirectiveToken - (276:15,10 [0] IncompleteDirectives.cshtml) - HtmlContent - (276:15,10 [4] IncompleteDirectives.cshtml) IntermediateToken - (276:15,10 [4] IncompleteDirectives.cshtml) - Html - \n\n MalformedDirective - (280:17,0 [12] IncompleteDirectives.cshtml) - functions MalformedDirective - (292:18,0 [15] IncompleteDirectives.cshtml) - functions MalformedDirective - (307:20,0 [8] IncompleteDirectives.cshtml) - section + DirectiveToken - (315:20,8 [0] IncompleteDirectives.cshtml) - HtmlContent - (315:20,8 [2] IncompleteDirectives.cshtml) IntermediateToken - (315:20,8 [2] IncompleteDirectives.cshtml) - Html - \n MalformedDirective - (317:21,0 [9] IncompleteDirectives.cshtml) - section + DirectiveToken - (326:21,9 [0] IncompleteDirectives.cshtml) - HtmlContent - (326:21,9 [4] IncompleteDirectives.cshtml) IntermediateToken - (326:21,9 [4] IncompleteDirectives.cshtml) - Html - \n\n MalformedDirective - (330:23,0 [9] IncompleteDirectives.cshtml) - section