From 7d9223c62c66bf84c2b017d9a3b1c8acd7f9ec82 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Fri, 12 Dec 2025 16:24:53 +1100 Subject: [PATCH 01/16] Create one failing test, and one passing with our desired state --- .../SemanticTokens/RenderFragment.txt | 24 +++++++++++ .../RenderFragment_Expression.txt | 38 +++++++++++++++++ .../RenderFragment_Expression_misc_file.txt | 38 +++++++++++++++++ ...derFragment_Expression_with_background.txt | 42 +++++++++++++++++++ ...t_Expression_with_background_misc_file.txt | 42 +++++++++++++++++++ .../RenderFragment_misc_file.txt | 24 +++++++++++ .../RenderFragment_with_background.txt | 28 +++++++++++++ ...nderFragment_with_background_misc_file.txt | 28 +++++++++++++ .../CohostSemanticTokensRangeEndpointTest.cs | 34 +++++++++++++++ 9 files changed, 298 insertions(+) create mode 100644 src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment.txt create mode 100644 src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Expression.txt create mode 100644 src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Expression_misc_file.txt create mode 100644 src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Expression_with_background.txt create mode 100644 src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Expression_with_background_misc_file.txt create mode 100644 src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_misc_file.txt create mode 100644 src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_with_background.txt create mode 100644 src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_with_background_misc_file.txt diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment.txt new file mode 100644 index 00000000000..95b4b2586e4 --- /dev/null +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment.txt @@ -0,0 +1,24 @@ +Line Δ, Char Δ, Length, Type, Modifier(s), Text +0 0 1 razorTransition [] [@] +0 1 10 razorDirective [] [rendermode] +2 0 4 markupCommentPunctuation [] [] +2 0 1 razorTransition [] [@] +0 1 1 razorTransition [] [{] +1 4 3 keyword [] [var] +0 4 1 local name [] [r] +0 2 1 operator [] [=] +0 2 9 namespace name [] [Microsoft] +0 9 1 operator [] [.] +0 1 10 namespace name [] [AspNetCore] +0 10 1 operator [] [.] +0 1 10 namespace name [] [Components] +0 10 1 operator [] [.] +0 1 3 namespace name [] [Web] +0 3 1 operator [] [.] +0 1 10 class name [static] [RenderMode] +0 10 1 operator [] [.] +0 1 15 property name [static] [InteractiveAuto] +0 15 1 punctuation [] [;] +1 0 1 razorTransition [] [}] diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Expression.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Expression.txt new file mode 100644 index 00000000000..28d12e8de61 --- /dev/null +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Expression.txt @@ -0,0 +1,38 @@ +Line Δ, Char Δ, Length, Type, Modifier(s), Text +0 0 1 razorTransition [] [@] +0 1 10 razorDirective [] [rendermode] +0 11 1 razorTransition [] [@] +0 1 1 razorTransition [] [(] +0 1 9 namespace name [] [Microsoft] +0 9 1 operator [] [.] +0 1 10 namespace name [] [AspNetCore] +0 10 1 operator [] [.] +0 1 10 namespace name [] [Components] +0 10 1 operator [] [.] +0 1 3 namespace name [] [Web] +0 3 1 operator [] [.] +0 1 10 class name [static] [RenderMode] +0 10 1 operator [] [.] +0 1 17 property name [static] [InteractiveServer] +0 17 1 razorTransition [] [)] +2 0 4 markupCommentPunctuation [] [] +2 0 1 razorTransition [] [@] +0 1 1 razorTransition [] [{] +1 4 3 keyword [] [var] +0 4 1 local name [] [r] +0 2 1 operator [] [=] +0 2 9 namespace name [] [Microsoft] +0 9 1 operator [] [.] +0 1 10 namespace name [] [AspNetCore] +0 10 1 operator [] [.] +0 1 10 namespace name [] [Components] +0 10 1 operator [] [.] +0 1 3 namespace name [] [Web] +0 3 1 operator [] [.] +0 1 10 class name [static] [RenderMode] +0 10 1 operator [] [.] +0 1 15 property name [static] [InteractiveAuto] +0 15 1 punctuation [] [;] +1 0 1 razorTransition [] [}] diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Expression_misc_file.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Expression_misc_file.txt new file mode 100644 index 00000000000..57368b36cae --- /dev/null +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Expression_misc_file.txt @@ -0,0 +1,38 @@ +Line Δ, Char Δ, Length, Type, Modifier(s), Text +0 0 1 razorTransition [] [@] +0 1 10 razorDirective [] [rendermode] +0 11 1 razorTransition [] [@] +0 1 1 razorTransition [] [(] +0 1 9 namespace name [] [Microsoft] +0 9 1 operator [] [.] +0 1 10 variable [] [AspNetCore] +0 10 1 operator [] [.] +0 1 10 variable [] [Components] +0 10 1 operator [] [.] +0 1 3 variable [] [Web] +0 3 1 operator [] [.] +0 1 10 variable [] [RenderMode] +0 10 1 operator [] [.] +0 1 17 variable [] [InteractiveServer] +0 17 1 razorTransition [] [)] +2 0 4 markupCommentPunctuation [] [] +2 0 1 razorTransition [] [@] +0 1 1 razorTransition [] [{] +1 4 3 keyword [] [var] +0 4 1 local name [] [r] +0 2 1 operator [] [=] +0 2 9 namespace name [] [Microsoft] +0 9 1 operator [] [.] +0 1 10 variable [] [AspNetCore] +0 10 1 operator [] [.] +0 1 10 variable [] [Components] +0 10 1 operator [] [.] +0 1 3 variable [] [Web] +0 3 1 operator [] [.] +0 1 10 variable [] [RenderMode] +0 10 1 operator [] [.] +0 1 15 variable [] [InteractiveAuto] +0 15 1 punctuation [] [;] +1 0 1 razorTransition [] [}] diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Expression_with_background.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Expression_with_background.txt new file mode 100644 index 00000000000..e85ca4e2705 --- /dev/null +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Expression_with_background.txt @@ -0,0 +1,42 @@ +Line Δ, Char Δ, Length, Type, Modifier(s), Text +0 0 1 razorTransition [] [@] +0 1 10 razorDirective [] [rendermode] +0 11 1 razorTransition [] [@] +0 1 1 razorTransition [razorCode] [(] +0 1 9 namespace name [razorCode] [Microsoft] +0 9 1 operator [razorCode] [.] +0 1 10 namespace name [razorCode] [AspNetCore] +0 10 1 operator [razorCode] [.] +0 1 10 namespace name [razorCode] [Components] +0 10 1 operator [razorCode] [.] +0 1 3 namespace name [razorCode] [Web] +0 3 1 operator [razorCode] [.] +0 1 10 class name [static, razorCode] [RenderMode] +0 10 1 operator [razorCode] [.] +0 1 17 property name [static, razorCode] [InteractiveServer] +0 17 1 razorTransition [razorCode] [)] +2 0 4 markupCommentPunctuation [] [] +2 0 1 razorTransition [razorCode] [@] +0 1 1 razorTransition [razorCode] [{] +1 0 4 markupTextLiteral [razorCode] [ ] +0 4 3 keyword [razorCode] [var] +0 3 1 markupTextLiteral [razorCode] [ ] +0 1 1 local name [razorCode] [r] +0 1 1 markupTextLiteral [razorCode] [ ] +0 1 1 operator [razorCode] [=] +0 1 1 markupTextLiteral [razorCode] [ ] +0 1 9 namespace name [razorCode] [Microsoft] +0 9 1 operator [razorCode] [.] +0 1 10 namespace name [razorCode] [AspNetCore] +0 10 1 operator [razorCode] [.] +0 1 10 namespace name [razorCode] [Components] +0 10 1 operator [razorCode] [.] +0 1 3 namespace name [razorCode] [Web] +0 3 1 operator [razorCode] [.] +0 1 10 class name [static, razorCode] [RenderMode] +0 10 1 operator [razorCode] [.] +0 1 15 property name [static, razorCode] [InteractiveAuto] +0 15 1 punctuation [razorCode] [;] +1 0 1 razorTransition [razorCode] [}] diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Expression_with_background_misc_file.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Expression_with_background_misc_file.txt new file mode 100644 index 00000000000..380fdce4e32 --- /dev/null +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Expression_with_background_misc_file.txt @@ -0,0 +1,42 @@ +Line Δ, Char Δ, Length, Type, Modifier(s), Text +0 0 1 razorTransition [] [@] +0 1 10 razorDirective [] [rendermode] +0 11 1 razorTransition [] [@] +0 1 1 razorTransition [razorCode] [(] +0 1 9 namespace name [razorCode] [Microsoft] +0 9 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [AspNetCore] +0 10 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [Components] +0 10 1 operator [razorCode] [.] +0 1 3 variable [razorCode] [Web] +0 3 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [RenderMode] +0 10 1 operator [razorCode] [.] +0 1 17 variable [razorCode] [InteractiveServer] +0 17 1 razorTransition [razorCode] [)] +2 0 4 markupCommentPunctuation [] [] +2 0 1 razorTransition [razorCode] [@] +0 1 1 razorTransition [razorCode] [{] +1 0 4 markupTextLiteral [razorCode] [ ] +0 4 3 keyword [razorCode] [var] +0 3 1 markupTextLiteral [razorCode] [ ] +0 1 1 local name [razorCode] [r] +0 1 1 markupTextLiteral [razorCode] [ ] +0 1 1 operator [razorCode] [=] +0 1 1 markupTextLiteral [razorCode] [ ] +0 1 9 namespace name [razorCode] [Microsoft] +0 9 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [AspNetCore] +0 10 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [Components] +0 10 1 operator [razorCode] [.] +0 1 3 variable [razorCode] [Web] +0 3 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [RenderMode] +0 10 1 operator [razorCode] [.] +0 1 15 variable [razorCode] [InteractiveAuto] +0 15 1 punctuation [razorCode] [;] +1 0 1 razorTransition [razorCode] [}] diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_misc_file.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_misc_file.txt new file mode 100644 index 00000000000..00903218742 --- /dev/null +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_misc_file.txt @@ -0,0 +1,24 @@ +Line Δ, Char Δ, Length, Type, Modifier(s), Text +0 0 1 razorTransition [] [@] +0 1 10 razorDirective [] [rendermode] +2 0 4 markupCommentPunctuation [] [] +2 0 1 razorTransition [] [@] +0 1 1 razorTransition [] [{] +1 4 3 keyword [] [var] +0 4 1 local name [] [r] +0 2 1 operator [] [=] +0 2 9 namespace name [] [Microsoft] +0 9 1 operator [] [.] +0 1 10 variable [] [AspNetCore] +0 10 1 operator [] [.] +0 1 10 variable [] [Components] +0 10 1 operator [] [.] +0 1 3 variable [] [Web] +0 3 1 operator [] [.] +0 1 10 variable [] [RenderMode] +0 10 1 operator [] [.] +0 1 15 variable [] [InteractiveAuto] +0 15 1 punctuation [] [;] +1 0 1 razorTransition [] [}] diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_with_background.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_with_background.txt new file mode 100644 index 00000000000..ad953369a9e --- /dev/null +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_with_background.txt @@ -0,0 +1,28 @@ +Line Δ, Char Δ, Length, Type, Modifier(s), Text +0 0 1 razorTransition [] [@] +0 1 10 razorDirective [] [rendermode] +2 0 4 markupCommentPunctuation [] [] +2 0 1 razorTransition [razorCode] [@] +0 1 1 razorTransition [razorCode] [{] +1 0 4 markupTextLiteral [razorCode] [ ] +0 4 3 keyword [razorCode] [var] +0 3 1 markupTextLiteral [razorCode] [ ] +0 1 1 local name [razorCode] [r] +0 1 1 markupTextLiteral [razorCode] [ ] +0 1 1 operator [razorCode] [=] +0 1 1 markupTextLiteral [razorCode] [ ] +0 1 9 namespace name [razorCode] [Microsoft] +0 9 1 operator [razorCode] [.] +0 1 10 namespace name [razorCode] [AspNetCore] +0 10 1 operator [razorCode] [.] +0 1 10 namespace name [razorCode] [Components] +0 10 1 operator [razorCode] [.] +0 1 3 namespace name [razorCode] [Web] +0 3 1 operator [razorCode] [.] +0 1 10 class name [static, razorCode] [RenderMode] +0 10 1 operator [razorCode] [.] +0 1 15 property name [static, razorCode] [InteractiveAuto] +0 15 1 punctuation [razorCode] [;] +1 0 1 razorTransition [razorCode] [}] diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_with_background_misc_file.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_with_background_misc_file.txt new file mode 100644 index 00000000000..144c9cc2670 --- /dev/null +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_with_background_misc_file.txt @@ -0,0 +1,28 @@ +Line Δ, Char Δ, Length, Type, Modifier(s), Text +0 0 1 razorTransition [] [@] +0 1 10 razorDirective [] [rendermode] +2 0 4 markupCommentPunctuation [] [] +2 0 1 razorTransition [razorCode] [@] +0 1 1 razorTransition [razorCode] [{] +1 0 4 markupTextLiteral [razorCode] [ ] +0 4 3 keyword [razorCode] [var] +0 3 1 markupTextLiteral [razorCode] [ ] +0 1 1 local name [razorCode] [r] +0 1 1 markupTextLiteral [razorCode] [ ] +0 1 1 operator [razorCode] [=] +0 1 1 markupTextLiteral [razorCode] [ ] +0 1 9 namespace name [razorCode] [Microsoft] +0 9 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [AspNetCore] +0 10 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [Components] +0 10 1 operator [razorCode] [.] +0 1 3 variable [razorCode] [Web] +0 3 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [RenderMode] +0 10 1 operator [razorCode] [.] +0 1 15 variable [razorCode] [InteractiveAuto] +0 15 1 punctuation [razorCode] [;] +1 0 1 razorTransition [razorCode] [}] diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/Endpoints/Shared/CohostSemanticTokensRangeEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/Endpoints/Shared/CohostSemanticTokensRangeEndpointTest.cs index cb7bf4bb484..3732e37efa3 100644 --- a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/Endpoints/Shared/CohostSemanticTokensRangeEndpointTest.cs +++ b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/Endpoints/Shared/CohostSemanticTokensRangeEndpointTest.cs @@ -136,6 +136,40 @@ public void M() await VerifySemanticTokensAsync(input, colorBackground, miscellaneousFile, fileKind: RazorFileKind.Legacy); } + [Theory] + [CombinatorialData] + public async Task RenderFragment(bool colorBackground, bool miscellaneousFile) + { + var input = """ + @rendermode Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer + + + + @{ + var r = Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveAuto; + } + """; + + await VerifySemanticTokensAsync(input, colorBackground, miscellaneousFile); + } + + [Theory] + [CombinatorialData] + public async Task RenderFragment_Expression(bool colorBackground, bool miscellaneousFile) + { + var input = """ + @rendermode @(Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer) + + + + @{ + var r = Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveAuto; + } + """; + + await VerifySemanticTokensAsync(input, colorBackground, miscellaneousFile); + } + private async Task VerifySemanticTokensAsync( string input, bool colorBackground, From 116ff7bae7f66b80dd20b3f4a44b16ff0b373b85 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Fri, 12 Dec 2025 16:35:47 +1100 Subject: [PATCH 02/16] Map the directive contents --- .../Components/ComponentRenderModeDirectivePass.cs | 7 ++++++- .../TestFiles/SemanticTokens/RenderFragment.txt | 11 +++++++++++ .../SemanticTokens/RenderFragment_misc_file.txt | 11 +++++++++++ .../SemanticTokens/RenderFragment_with_background.txt | 11 +++++++++++ .../RenderFragment_with_background_misc_file.txt | 11 +++++++++++ 5 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentRenderModeDirectivePass.cs b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentRenderModeDirectivePass.cs index 7df4a4bd719..19005f499f9 100644 --- a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentRenderModeDirectivePass.cs +++ b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentRenderModeDirectivePass.cs @@ -67,7 +67,12 @@ protected override void ExecuteCore( { child is not DirectiveTokenIntermediateNode directiveToken ? child - : IntermediateNodeFactory.CSharpToken(directiveToken.Content) + : IntermediateNodeFactory.CSharpToken( + content: directiveToken.Content, + // To avoid breaking hot reload, we don't map the content back to the source unless we're on Razor 10 or higher + source: codeDocument.ParserOptions.LanguageVersion >= RazorLanguageVersion.Version_10_0 + ? directiveToken.Source + : null) } }, IntermediateNodeFactory.CSharpToken(";") diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment.txt index 95b4b2586e4..933d7e875b5 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment.txt +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment.txt @@ -1,6 +1,17 @@ Line Δ, Char Δ, Length, Type, Modifier(s), Text 0 0 1 razorTransition [] [@] 0 1 10 razorDirective [] [rendermode] +0 11 9 namespace name [] [Microsoft] +0 9 1 operator [] [.] +0 1 10 namespace name [] [AspNetCore] +0 10 1 operator [] [.] +0 1 10 namespace name [] [Components] +0 10 1 operator [] [.] +0 1 3 namespace name [] [Web] +0 3 1 operator [] [.] +0 1 10 class name [static] [RenderMode] +0 10 1 operator [] [.] +0 1 17 property name [static] [InteractiveServer] 2 0 4 markupCommentPunctuation [] [] diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_misc_file.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_misc_file.txt index 00903218742..f20b19cfd6d 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_misc_file.txt +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_misc_file.txt @@ -1,6 +1,17 @@ Line Δ, Char Δ, Length, Type, Modifier(s), Text 0 0 1 razorTransition [] [@] 0 1 10 razorDirective [] [rendermode] +0 11 9 namespace name [] [Microsoft] +0 9 1 operator [] [.] +0 1 10 variable [] [AspNetCore] +0 10 1 operator [] [.] +0 1 10 variable [] [Components] +0 10 1 operator [] [.] +0 1 3 variable [] [Web] +0 3 1 operator [] [.] +0 1 10 variable [] [RenderMode] +0 10 1 operator [] [.] +0 1 17 variable [] [InteractiveServer] 2 0 4 markupCommentPunctuation [] [] diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_with_background.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_with_background.txt index ad953369a9e..73fe1225f61 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_with_background.txt +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_with_background.txt @@ -1,6 +1,17 @@ Line Δ, Char Δ, Length, Type, Modifier(s), Text 0 0 1 razorTransition [] [@] 0 1 10 razorDirective [] [rendermode] +0 11 9 namespace name [razorCode] [Microsoft] +0 9 1 operator [razorCode] [.] +0 1 10 namespace name [razorCode] [AspNetCore] +0 10 1 operator [razorCode] [.] +0 1 10 namespace name [razorCode] [Components] +0 10 1 operator [razorCode] [.] +0 1 3 namespace name [razorCode] [Web] +0 3 1 operator [razorCode] [.] +0 1 10 class name [static, razorCode] [RenderMode] +0 10 1 operator [razorCode] [.] +0 1 17 property name [static, razorCode] [InteractiveServer] 2 0 4 markupCommentPunctuation [] [] diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_with_background_misc_file.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_with_background_misc_file.txt index 144c9cc2670..f8c0f4e9b84 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_with_background_misc_file.txt +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_with_background_misc_file.txt @@ -1,6 +1,17 @@ Line Δ, Char Δ, Length, Type, Modifier(s), Text 0 0 1 razorTransition [] [@] 0 1 10 razorDirective [] [rendermode] +0 11 9 namespace name [razorCode] [Microsoft] +0 9 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [AspNetCore] +0 10 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [Components] +0 10 1 operator [razorCode] [.] +0 1 3 variable [razorCode] [Web] +0 3 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [RenderMode] +0 10 1 operator [razorCode] [.] +0 1 17 variable [razorCode] [InteractiveServer] 2 0 4 markupCommentPunctuation [] [] From a509c26d235a23aaa2ab3489bdee7b162aea3d51 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Fri, 12 Dec 2025 16:49:32 +1100 Subject: [PATCH 03/16] Add regression test to ensure no difference in line directives for Razor 9 --- .../SemanticTokens/RenderFragment_Razor9.txt | 24 ++++++++++++ .../RenderFragment_Razor9_misc_file.txt | 35 +++++++++++++++++ .../RenderFragment_Razor9_with_background.txt | 28 +++++++++++++ ...gment_Razor9_with_background_misc_file.txt | 39 +++++++++++++++++++ .../CohostSemanticTokensRangeEndpointTest.cs | 26 ++++++++++++- 5 files changed, 150 insertions(+), 2 deletions(-) create mode 100644 src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Razor9.txt create mode 100644 src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_misc_file.txt create mode 100644 src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_with_background.txt create mode 100644 src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_with_background_misc_file.txt diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Razor9.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Razor9.txt new file mode 100644 index 00000000000..9f9f101a1d7 --- /dev/null +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Razor9.txt @@ -0,0 +1,24 @@ +Line Δ, Char Δ, Length, Type, Modifier(s), Text +0 0 1 razorTransition [] [@] +0 1 10 razorDirective [] [rendermode] +2 0 4 markupCommentPunctuation [] [] +2 0 1 razorTransition [] [@] +0 1 1 razorTransition [] [{] +1 4 3 keyword [] [var] +0 4 1 local name [] [r] +0 2 1 operator [] [=] +0 2 9 namespace name [] [Microsoft] +0 9 1 operator [] [.] +0 1 10 namespace name [] [AspNetCore] +0 10 1 operator [] [.] +0 1 10 namespace name [] [Components] +0 10 1 operator [] [.] +0 1 3 namespace name [] [Web] +0 3 1 operator [] [.] +0 1 10 class name [static] [RenderMode] +0 10 1 operator [] [.] +0 1 15 property name [static] [InteractiveAuto] +0 15 1 punctuation [] [;] +1 0 1 razorTransition [] [}] diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_misc_file.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_misc_file.txt new file mode 100644 index 00000000000..2e2f2814a9a --- /dev/null +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_misc_file.txt @@ -0,0 +1,35 @@ +Line Δ, Char Δ, Length, Type, Modifier(s), Text +0 0 1 razorTransition [] [@] +0 1 10 razorDirective [] [rendermode] +0 11 9 namespace name [] [Microsoft] +0 9 1 operator [] [.] +0 1 10 variable [] [AspNetCore] +0 10 1 operator [] [.] +0 1 10 variable [] [Components] +0 10 1 operator [] [.] +0 1 3 variable [] [Web] +0 3 1 operator [] [.] +0 1 10 variable [] [RenderMode] +0 10 1 operator [] [.] +0 1 17 variable [] [InteractiveServer] +2 0 4 markupCommentPunctuation [] [] +2 0 1 razorTransition [] [@] +0 1 1 razorTransition [] [{] +1 4 3 keyword [] [var] +0 4 1 local name [] [r] +0 2 1 operator [] [=] +0 2 9 namespace name [] [Microsoft] +0 9 1 operator [] [.] +0 1 10 variable [] [AspNetCore] +0 10 1 operator [] [.] +0 1 10 variable [] [Components] +0 10 1 operator [] [.] +0 1 3 variable [] [Web] +0 3 1 operator [] [.] +0 1 10 variable [] [RenderMode] +0 10 1 operator [] [.] +0 1 15 variable [] [InteractiveAuto] +0 15 1 punctuation [] [;] +1 0 1 razorTransition [] [}] diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_with_background.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_with_background.txt new file mode 100644 index 00000000000..f1930a86698 --- /dev/null +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_with_background.txt @@ -0,0 +1,28 @@ +Line Δ, Char Δ, Length, Type, Modifier(s), Text +0 0 1 razorTransition [] [@] +0 1 10 razorDirective [] [rendermode] +2 0 4 markupCommentPunctuation [] [] +2 0 1 razorTransition [razorCode] [@] +0 1 1 razorTransition [razorCode] [{] +1 0 4 markupTextLiteral [razorCode] [ ] +0 4 3 keyword [razorCode] [var] +0 3 1 markupTextLiteral [razorCode] [ ] +0 1 1 local name [razorCode] [r] +0 1 1 markupTextLiteral [razorCode] [ ] +0 1 1 operator [razorCode] [=] +0 1 1 markupTextLiteral [razorCode] [ ] +0 1 9 namespace name [razorCode] [Microsoft] +0 9 1 operator [razorCode] [.] +0 1 10 namespace name [razorCode] [AspNetCore] +0 10 1 operator [razorCode] [.] +0 1 10 namespace name [razorCode] [Components] +0 10 1 operator [razorCode] [.] +0 1 3 namespace name [razorCode] [Web] +0 3 1 operator [razorCode] [.] +0 1 10 class name [static, razorCode] [RenderMode] +0 10 1 operator [razorCode] [.] +0 1 15 property name [static, razorCode] [InteractiveAuto] +0 15 1 punctuation [razorCode] [;] +1 0 1 razorTransition [razorCode] [}] diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_with_background_misc_file.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_with_background_misc_file.txt new file mode 100644 index 00000000000..ac88a4ec265 --- /dev/null +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_with_background_misc_file.txt @@ -0,0 +1,39 @@ +Line Δ, Char Δ, Length, Type, Modifier(s), Text +0 0 1 razorTransition [] [@] +0 1 10 razorDirective [] [rendermode] +0 11 9 namespace name [razorCode] [Microsoft] +0 9 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [AspNetCore] +0 10 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [Components] +0 10 1 operator [razorCode] [.] +0 1 3 variable [razorCode] [Web] +0 3 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [RenderMode] +0 10 1 operator [razorCode] [.] +0 1 17 variable [razorCode] [InteractiveServer] +2 0 4 markupCommentPunctuation [] [] +2 0 1 razorTransition [razorCode] [@] +0 1 1 razorTransition [razorCode] [{] +1 0 4 markupTextLiteral [razorCode] [ ] +0 4 3 keyword [razorCode] [var] +0 3 1 markupTextLiteral [razorCode] [ ] +0 1 1 local name [razorCode] [r] +0 1 1 markupTextLiteral [razorCode] [ ] +0 1 1 operator [razorCode] [=] +0 1 1 markupTextLiteral [razorCode] [ ] +0 1 9 namespace name [razorCode] [Microsoft] +0 9 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [AspNetCore] +0 10 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [Components] +0 10 1 operator [razorCode] [.] +0 1 3 variable [razorCode] [Web] +0 3 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [RenderMode] +0 10 1 operator [razorCode] [.] +0 1 15 variable [razorCode] [InteractiveAuto] +0 15 1 punctuation [razorCode] [;] +1 0 1 razorTransition [razorCode] [}] diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/Endpoints/Shared/CohostSemanticTokensRangeEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/Endpoints/Shared/CohostSemanticTokensRangeEndpointTest.cs index 3732e37efa3..76bea26cc22 100644 --- a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/Endpoints/Shared/CohostSemanticTokensRangeEndpointTest.cs +++ b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/Endpoints/Shared/CohostSemanticTokensRangeEndpointTest.cs @@ -153,6 +153,27 @@ @rendermode Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer await VerifySemanticTokensAsync(input, colorBackground, miscellaneousFile); } + [Theory] + [CombinatorialData] + public async Task RenderFragment_Razor9(bool colorBackground, bool miscellaneousFile) + { + var input = """ + @rendermode Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer + + + + @{ + var r = Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveAuto; + } + """; + + await VerifySemanticTokensAsync( + input, + colorBackground, + miscellaneousFile, + projectConfigure: p => p.RazorLanguageVersion = RazorLanguageVersion.Version_9_0); + } + [Theory] [CombinatorialData] public async Task RenderFragment_Expression(bool colorBackground, bool miscellaneousFile) @@ -175,9 +196,10 @@ private async Task VerifySemanticTokensAsync( bool colorBackground, bool miscellaneousFile, RazorFileKind? fileKind = null, - [CallerMemberName] string? testName = null) + [CallerMemberName] string? testName = null, + Action? projectConfigure = null) { - var document = CreateProjectAndRazorDocument(input, fileKind, miscellaneousFile: miscellaneousFile); + var document = CreateProjectAndRazorDocument(input, fileKind, miscellaneousFile: miscellaneousFile, projectConfigure: projectConfigure); var sourceText = await document.GetTextAsync(DisposalToken); // We need to manually initialize the OOP service so we can get semantic token info later From e7804dfddf23e25fd2d4752bfc06b1a2691a1d5e Mon Sep 17 00:00:00 2001 From: David Wengier Date: Fri, 12 Dec 2025 16:49:59 +1100 Subject: [PATCH 04/16] Add ability for tests to customize project generation Got sick of adding lots and lots of parameters. Going to clean these up in future --- .../CohostTestBase.cs | 23 ++++++++++++------- .../RazorProjectBuilder.cs | 5 +++- .../Cohost/CohostEndpointTestBase.cs | 15 +++++++----- .../Cohost/RetryProjectTest.cs | 2 +- .../CohostEndpointTestBase.cs | 7 +++--- 5 files changed, 33 insertions(+), 19 deletions(-) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Cohosting/CohostTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Cohosting/CohostTestBase.cs index 1149a600c66..ab255282600 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Cohosting/CohostTestBase.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Cohosting/CohostTestBase.cs @@ -143,16 +143,17 @@ private protected void UpdateClientLSPInitializationOptions(Func? projectConfigure = null); - protected TextDocument CreateProjectAndRazorDocument( + private protected TextDocument CreateProjectAndRazorDocument( CodeAnalysis.Workspace remoteWorkspace, string contents, RazorFileKind? fileKind = null, @@ -160,7 +161,8 @@ protected TextDocument CreateProjectAndRazorDocument( (string fileName, string contents)[]? additionalFiles = null, bool inGlobalNamespace = false, bool miscellaneousFile = false, - bool addDefaultImports = true) + bool addDefaultImports = true, + Action? projectConfigure = null) { // Using IsLegacy means null == component, so easier for test authors var isComponent = fileKind != RazorFileKind.Legacy; @@ -172,18 +174,23 @@ protected TextDocument CreateProjectAndRazorDocument( var projectId = ProjectId.CreateNewId(debugName: TestProjectData.SomeProject.DisplayName); var documentId = DocumentId.CreateNewId(projectId, debugName: documentFilePath); - return CreateProjectAndRazorDocument(remoteWorkspace, projectId, miscellaneousFile, documentId, documentFilePath, contents, additionalFiles, inGlobalNamespace, addDefaultImports); + return CreateProjectAndRazorDocument(remoteWorkspace, projectId, miscellaneousFile, documentId, documentFilePath, contents, additionalFiles, inGlobalNamespace, addDefaultImports, projectConfigure); } - protected static TextDocument CreateProjectAndRazorDocument(CodeAnalysis.Workspace workspace, ProjectId projectId, bool miscellaneousFile, DocumentId documentId, string documentFilePath, string contents, (string fileName, string contents)[]? additionalFiles, bool inGlobalNamespace, bool addDefaultImports) + private protected static TextDocument CreateProjectAndRazorDocument(CodeAnalysis.Workspace workspace, ProjectId projectId, bool miscellaneousFile, DocumentId documentId, string documentFilePath, string contents, (string fileName, string contents)[]? additionalFiles, bool inGlobalNamespace, bool addDefaultImports, Action? projectConfigure) { - return AddProjectAndRazorDocument(workspace.CurrentSolution, TestProjectData.SomeProject.FilePath, projectId, miscellaneousFile, documentId, documentFilePath, contents, additionalFiles, inGlobalNamespace, addDefaultImports); + return AddProjectAndRazorDocument(workspace.CurrentSolution, TestProjectData.SomeProject.FilePath, projectId, miscellaneousFile, documentId, documentFilePath, contents, additionalFiles, inGlobalNamespace, addDefaultImports, projectConfigure); } - protected static TextDocument AddProjectAndRazorDocument(Solution solution, [DisallowNull] string? projectFilePath, ProjectId projectId, bool miscellaneousFile, DocumentId documentId, string documentFilePath, string contents, (string fileName, string contents)[]? additionalFiles, bool inGlobalNamespace, bool addDefaultImports) + private protected static TextDocument AddProjectAndRazorDocument(Solution solution, [DisallowNull] string? projectFilePath, ProjectId projectId, bool miscellaneousFile, DocumentId documentId, string documentFilePath, string contents, (string fileName, string contents)[]? additionalFiles, bool inGlobalNamespace, bool addDefaultImports, Action? projectConfigure) { var builder = new RazorProjectBuilder(projectId); + if (projectConfigure is not null) + { + projectConfigure(builder); + } + builder.AddReferences(miscellaneousFile ? Net461.ReferenceInfos.All.Select(r => r.Reference) // This isn't quite what Roslyn does, but its close enough for our tests : AspNet80.ReferenceInfos.All.Select(r => r.Reference)); diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Cohosting/RazorProjectBuilder.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Cohosting/RazorProjectBuilder.cs index 8bd7ebb30ad..4d33924234c 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Cohosting/RazorProjectBuilder.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Cohosting/RazorProjectBuilder.cs @@ -6,6 +6,7 @@ using System.IO; using System.Text; using Microsoft.AspNetCore.Razor; +using Microsoft.AspNetCore.Razor.Language; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Diagnostics; @@ -40,6 +41,8 @@ public string? ProjectFilePath public bool GenerateMSBuildProjectDirectory { get; set; } = true; public bool GenerateAdditionalDocumentMetadata { get; set; } = true; + public RazorLanguageVersion RazorLanguageVersion { get; set; } = FallbackRazorConfiguration.Latest.LanguageVersion; + private readonly List _references = []; private readonly List<(DocumentId id, string name, SourceText text, string filePath)> _documents = []; private readonly List<(DocumentId id, string name, SourceText text, string filePath)> _additionalDocuments = []; @@ -111,7 +114,7 @@ public Solution Build(Solution solution) globalConfigContent.AppendLine($""" is_global = true - build_property.RazorLangVersion = {FallbackRazorConfiguration.Latest.LanguageVersion} + build_property.RazorLangVersion = {RazorLanguageVersion} build_property.RazorConfiguration = {FallbackRazorConfiguration.Latest.ConfigurationName} build_property.RootNamespace = {RootNamespace} diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostEndpointTestBase.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostEndpointTestBase.cs index cba1dc26f9a..9a2f01c80cb 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostEndpointTestBase.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostEndpointTestBase.cs @@ -91,17 +91,18 @@ protected TextDocument CreateProjectAndRazorDocument( return this.CreateProjectAndRazorDocument(contents); } - protected override TextDocument CreateProjectAndRazorDocument( + private protected override TextDocument CreateProjectAndRazorDocument( string contents, RazorFileKind? fileKind = null, string? documentFilePath = null, (string fileName, string contents)[]? additionalFiles = null, bool inGlobalNamespace = false, bool miscellaneousFile = false, - bool addDefaultImports = true) + bool addDefaultImports = true, + Action? projectConfigure = null) { var remoteWorkspace = RemoteWorkspaceProvider.Instance.GetWorkspace(); - var remoteDocument = base.CreateProjectAndRazorDocument(remoteWorkspace, contents, fileKind, documentFilePath, additionalFiles, inGlobalNamespace, miscellaneousFile, addDefaultImports); + var remoteDocument = base.CreateProjectAndRazorDocument(remoteWorkspace, contents, fileKind, documentFilePath, additionalFiles, inGlobalNamespace, miscellaneousFile, addDefaultImports, projectConfigure); // In this project we simulate remote services running OOP by creating a different workspace with a different // set of services to represent the devenv Roslyn side of things. We don't have any actual solution syncing set @@ -116,7 +117,8 @@ protected override TextDocument CreateProjectAndRazorDocument( contents, additionalFiles, inGlobalNamespace, - addDefaultImports); + addDefaultImports, + projectConfigure); } private TextDocument CreateLocalProjectAndRazorDocument( @@ -128,9 +130,10 @@ private TextDocument CreateLocalProjectAndRazorDocument( string contents, (string fileName, string contents)[]? additionalFiles, bool inGlobalNamespace, - bool addDefaultImports) + bool addDefaultImports, + Action? projectConfigure) { - var razorDocument = CreateProjectAndRazorDocument(LocalWorkspace, projectId, miscellaneousFile, documentId, documentFilePath, contents, additionalFiles, inGlobalNamespace, addDefaultImports); + var razorDocument = CreateProjectAndRazorDocument(LocalWorkspace, projectId, miscellaneousFile, documentId, documentFilePath, contents, additionalFiles, inGlobalNamespace, addDefaultImports, projectConfigure); // If we're creating remote and local workspaces, then we'll return the local document, and have to allow // the remote service invoker to map from the local solution to the remote one. diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/RetryProjectTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/RetryProjectTest.cs index d00b9af95da..0bd8db17d59 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/RetryProjectTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/RetryProjectTest.cs @@ -72,7 +72,7 @@ public async Task HoverRequest_MultipleProjects_ReturnsResults() var projectId = ProjectId.CreateNewId(debugName: TestProjectData.SomeProject.DisplayName); var documentFilePath = TestProjectData.AnotherProjectComponentFile1.FilePath; var documentId = DocumentId.CreateNewId(projectId, debugName: documentFilePath); - var otherDocument = AddProjectAndRazorDocument(document.Project.Solution, TestProjectData.AnotherProject.FilePath, projectId, miscellaneousFile: false, documentId, documentFilePath, otherInput.Text, additionalFiles: null, inGlobalNamespace: false, addDefaultImports: true); + var otherDocument = AddProjectAndRazorDocument(document.Project.Solution, TestProjectData.AnotherProject.FilePath, projectId, miscellaneousFile: false, documentId, documentFilePath, otherInput.Text, additionalFiles: null, inGlobalNamespace: false, addDefaultImports: true, projectConfigure: null); // Make sure we have the document from our new fork document = otherDocument.Project.Solution.GetAdditionalDocument(document.Id).AssumeNotNull(); diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/CohostEndpointTestBase.cs b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/CohostEndpointTestBase.cs index a9ffb6472e9..72dee2fbefb 100644 --- a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/CohostEndpointTestBase.cs +++ b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/CohostEndpointTestBase.cs @@ -81,15 +81,16 @@ private protected override RemoteClientLSPInitializationOptions GetRemoteClientL }; } - protected override TextDocument CreateProjectAndRazorDocument( + private protected override TextDocument CreateProjectAndRazorDocument( string contents, RazorFileKind? fileKind = null, string? documentFilePath = null, (string fileName, string contents)[]? additionalFiles = null, bool inGlobalNamespace = false, bool miscellaneousFile = false, - bool addDefaultImports = true) + bool addDefaultImports = true, + Action? projectConfigure = null) { - return CreateProjectAndRazorDocument(LocalWorkspace, contents, fileKind, documentFilePath, additionalFiles, inGlobalNamespace, miscellaneousFile, addDefaultImports); + return CreateProjectAndRazorDocument(LocalWorkspace, contents, fileKind, documentFilePath, additionalFiles, inGlobalNamespace, miscellaneousFile, addDefaultImports, projectConfigure); } } From 1f2df9680a2590e59cbafb1a8f2859150867b09f Mon Sep 17 00:00:00 2001 From: David Wengier Date: Fri, 12 Dec 2025 21:25:38 +1100 Subject: [PATCH 05/16] Oops, missed a few baselines --- .../SemanticTokens/RenderFragment.txt | 35 ++++++++++++++++ .../RenderFragment_Expression.txt | 38 +++++++++++++++++ .../RenderFragment_Expression_misc_file.txt | 38 +++++++++++++++++ ...derFragment_Expression_with_background.txt | 42 +++++++++++++++++++ ...t_Expression_with_background_misc_file.txt | 42 +++++++++++++++++++ .../SemanticTokens/RenderFragment_Razor9.txt | 24 +++++++++++ .../RenderFragment_Razor9_misc_file.txt | 35 ++++++++++++++++ .../RenderFragment_Razor9_with_background.txt | 28 +++++++++++++ ...gment_Razor9_with_background_misc_file.txt | 39 +++++++++++++++++ .../RenderFragment_misc_file.txt | 35 ++++++++++++++++ .../RenderFragment_with_background.txt | 39 +++++++++++++++++ ...nderFragment_with_background_misc_file.txt | 39 +++++++++++++++++ 12 files changed, 434 insertions(+) create mode 100644 src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment.txt create mode 100644 src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Expression.txt create mode 100644 src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Expression_misc_file.txt create mode 100644 src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Expression_with_background.txt create mode 100644 src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Expression_with_background_misc_file.txt create mode 100644 src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Razor9.txt create mode 100644 src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_misc_file.txt create mode 100644 src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_with_background.txt create mode 100644 src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_with_background_misc_file.txt create mode 100644 src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_misc_file.txt create mode 100644 src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_with_background.txt create mode 100644 src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_with_background_misc_file.txt diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment.txt b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment.txt new file mode 100644 index 00000000000..9663a1806fa --- /dev/null +++ b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment.txt @@ -0,0 +1,35 @@ +Line Δ, Char Δ, Length, Type, Modifier(s), Text +0 0 1 razorTransition [] [@] +0 1 10 razorDirective [] [rendermode] +0 11 9 namespace [] [Microsoft] +0 9 1 operator [] [.] +0 1 10 namespace [] [AspNetCore] +0 10 1 operator [] [.] +0 1 10 namespace [] [Components] +0 10 1 operator [] [.] +0 1 3 namespace [] [Web] +0 3 1 operator [] [.] +0 1 10 class [static] [RenderMode] +0 10 1 operator [] [.] +0 1 17 property [static] [InteractiveServer] +2 0 4 markupCommentPunctuation [] [] +2 0 1 razorTransition [] [@] +0 1 1 razorTransition [] [{] +1 4 3 keyword [] [var] +0 4 1 variable [] [r] +0 2 1 operator [] [=] +0 2 9 namespace [] [Microsoft] +0 9 1 operator [] [.] +0 1 10 namespace [] [AspNetCore] +0 10 1 operator [] [.] +0 1 10 namespace [] [Components] +0 10 1 operator [] [.] +0 1 3 namespace [] [Web] +0 3 1 operator [] [.] +0 1 10 class [static] [RenderMode] +0 10 1 operator [] [.] +0 1 15 property [static] [InteractiveAuto] +0 15 1 punctuation [] [;] +1 0 1 razorTransition [] [}] diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Expression.txt b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Expression.txt new file mode 100644 index 00000000000..c3614859f15 --- /dev/null +++ b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Expression.txt @@ -0,0 +1,38 @@ +Line Δ, Char Δ, Length, Type, Modifier(s), Text +0 0 1 razorTransition [] [@] +0 1 10 razorDirective [] [rendermode] +0 11 1 razorTransition [] [@] +0 1 1 razorTransition [] [(] +0 1 9 namespace [] [Microsoft] +0 9 1 operator [] [.] +0 1 10 namespace [] [AspNetCore] +0 10 1 operator [] [.] +0 1 10 namespace [] [Components] +0 10 1 operator [] [.] +0 1 3 namespace [] [Web] +0 3 1 operator [] [.] +0 1 10 class [static] [RenderMode] +0 10 1 operator [] [.] +0 1 17 property [static] [InteractiveServer] +0 17 1 razorTransition [] [)] +2 0 4 markupCommentPunctuation [] [] +2 0 1 razorTransition [] [@] +0 1 1 razorTransition [] [{] +1 4 3 keyword [] [var] +0 4 1 variable [] [r] +0 2 1 operator [] [=] +0 2 9 namespace [] [Microsoft] +0 9 1 operator [] [.] +0 1 10 namespace [] [AspNetCore] +0 10 1 operator [] [.] +0 1 10 namespace [] [Components] +0 10 1 operator [] [.] +0 1 3 namespace [] [Web] +0 3 1 operator [] [.] +0 1 10 class [static] [RenderMode] +0 10 1 operator [] [.] +0 1 15 property [static] [InteractiveAuto] +0 15 1 punctuation [] [;] +1 0 1 razorTransition [] [}] diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Expression_misc_file.txt b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Expression_misc_file.txt new file mode 100644 index 00000000000..8534957dfa0 --- /dev/null +++ b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Expression_misc_file.txt @@ -0,0 +1,38 @@ +Line Δ, Char Δ, Length, Type, Modifier(s), Text +0 0 1 razorTransition [] [@] +0 1 10 razorDirective [] [rendermode] +0 11 1 razorTransition [] [@] +0 1 1 razorTransition [] [(] +0 1 9 namespace [] [Microsoft] +0 9 1 operator [] [.] +0 1 10 variable [] [AspNetCore] +0 10 1 operator [] [.] +0 1 10 variable [] [Components] +0 10 1 operator [] [.] +0 1 3 variable [] [Web] +0 3 1 operator [] [.] +0 1 10 variable [] [RenderMode] +0 10 1 operator [] [.] +0 1 17 variable [] [InteractiveServer] +0 17 1 razorTransition [] [)] +2 0 4 markupCommentPunctuation [] [] +2 0 1 razorTransition [] [@] +0 1 1 razorTransition [] [{] +1 4 3 keyword [] [var] +0 4 1 variable [] [r] +0 2 1 operator [] [=] +0 2 9 namespace [] [Microsoft] +0 9 1 operator [] [.] +0 1 10 variable [] [AspNetCore] +0 10 1 operator [] [.] +0 1 10 variable [] [Components] +0 10 1 operator [] [.] +0 1 3 variable [] [Web] +0 3 1 operator [] [.] +0 1 10 variable [] [RenderMode] +0 10 1 operator [] [.] +0 1 15 variable [] [InteractiveAuto] +0 15 1 punctuation [] [;] +1 0 1 razorTransition [] [}] diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Expression_with_background.txt b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Expression_with_background.txt new file mode 100644 index 00000000000..6d454600f9e --- /dev/null +++ b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Expression_with_background.txt @@ -0,0 +1,42 @@ +Line Δ, Char Δ, Length, Type, Modifier(s), Text +0 0 1 razorTransition [] [@] +0 1 10 razorDirective [] [rendermode] +0 11 1 razorTransition [] [@] +0 1 1 razorTransition [razorCode] [(] +0 1 9 namespace [razorCode] [Microsoft] +0 9 1 operator [razorCode] [.] +0 1 10 namespace [razorCode] [AspNetCore] +0 10 1 operator [razorCode] [.] +0 1 10 namespace [razorCode] [Components] +0 10 1 operator [razorCode] [.] +0 1 3 namespace [razorCode] [Web] +0 3 1 operator [razorCode] [.] +0 1 10 class [static, razorCode] [RenderMode] +0 10 1 operator [razorCode] [.] +0 1 17 property [static, razorCode] [InteractiveServer] +0 17 1 razorTransition [razorCode] [)] +2 0 4 markupCommentPunctuation [] [] +2 0 1 razorTransition [razorCode] [@] +0 1 1 razorTransition [razorCode] [{] +1 0 4 markupTextLiteral [razorCode] [ ] +0 4 3 keyword [razorCode] [var] +0 3 1 markupTextLiteral [razorCode] [ ] +0 1 1 variable [razorCode] [r] +0 1 1 markupTextLiteral [razorCode] [ ] +0 1 1 operator [razorCode] [=] +0 1 1 markupTextLiteral [razorCode] [ ] +0 1 9 namespace [razorCode] [Microsoft] +0 9 1 operator [razorCode] [.] +0 1 10 namespace [razorCode] [AspNetCore] +0 10 1 operator [razorCode] [.] +0 1 10 namespace [razorCode] [Components] +0 10 1 operator [razorCode] [.] +0 1 3 namespace [razorCode] [Web] +0 3 1 operator [razorCode] [.] +0 1 10 class [static, razorCode] [RenderMode] +0 10 1 operator [razorCode] [.] +0 1 15 property [static, razorCode] [InteractiveAuto] +0 15 1 punctuation [razorCode] [;] +1 0 1 razorTransition [razorCode] [}] diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Expression_with_background_misc_file.txt b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Expression_with_background_misc_file.txt new file mode 100644 index 00000000000..f70ea619c52 --- /dev/null +++ b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Expression_with_background_misc_file.txt @@ -0,0 +1,42 @@ +Line Δ, Char Δ, Length, Type, Modifier(s), Text +0 0 1 razorTransition [] [@] +0 1 10 razorDirective [] [rendermode] +0 11 1 razorTransition [] [@] +0 1 1 razorTransition [razorCode] [(] +0 1 9 namespace [razorCode] [Microsoft] +0 9 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [AspNetCore] +0 10 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [Components] +0 10 1 operator [razorCode] [.] +0 1 3 variable [razorCode] [Web] +0 3 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [RenderMode] +0 10 1 operator [razorCode] [.] +0 1 17 variable [razorCode] [InteractiveServer] +0 17 1 razorTransition [razorCode] [)] +2 0 4 markupCommentPunctuation [] [] +2 0 1 razorTransition [razorCode] [@] +0 1 1 razorTransition [razorCode] [{] +1 0 4 markupTextLiteral [razorCode] [ ] +0 4 3 keyword [razorCode] [var] +0 3 1 markupTextLiteral [razorCode] [ ] +0 1 1 variable [razorCode] [r] +0 1 1 markupTextLiteral [razorCode] [ ] +0 1 1 operator [razorCode] [=] +0 1 1 markupTextLiteral [razorCode] [ ] +0 1 9 namespace [razorCode] [Microsoft] +0 9 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [AspNetCore] +0 10 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [Components] +0 10 1 operator [razorCode] [.] +0 1 3 variable [razorCode] [Web] +0 3 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [RenderMode] +0 10 1 operator [razorCode] [.] +0 1 15 variable [razorCode] [InteractiveAuto] +0 15 1 punctuation [razorCode] [;] +1 0 1 razorTransition [razorCode] [}] diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Razor9.txt b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Razor9.txt new file mode 100644 index 00000000000..cb5fd2fa4bc --- /dev/null +++ b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Razor9.txt @@ -0,0 +1,24 @@ +Line Δ, Char Δ, Length, Type, Modifier(s), Text +0 0 1 razorTransition [] [@] +0 1 10 razorDirective [] [rendermode] +2 0 4 markupCommentPunctuation [] [] +2 0 1 razorTransition [] [@] +0 1 1 razorTransition [] [{] +1 4 3 keyword [] [var] +0 4 1 variable [] [r] +0 2 1 operator [] [=] +0 2 9 namespace [] [Microsoft] +0 9 1 operator [] [.] +0 1 10 namespace [] [AspNetCore] +0 10 1 operator [] [.] +0 1 10 namespace [] [Components] +0 10 1 operator [] [.] +0 1 3 namespace [] [Web] +0 3 1 operator [] [.] +0 1 10 class [static] [RenderMode] +0 10 1 operator [] [.] +0 1 15 property [static] [InteractiveAuto] +0 15 1 punctuation [] [;] +1 0 1 razorTransition [] [}] diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_misc_file.txt b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_misc_file.txt new file mode 100644 index 00000000000..a5c4374ca80 --- /dev/null +++ b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_misc_file.txt @@ -0,0 +1,35 @@ +Line Δ, Char Δ, Length, Type, Modifier(s), Text +0 0 1 razorTransition [] [@] +0 1 10 razorDirective [] [rendermode] +0 11 9 namespace [] [Microsoft] +0 9 1 operator [] [.] +0 1 10 variable [] [AspNetCore] +0 10 1 operator [] [.] +0 1 10 variable [] [Components] +0 10 1 operator [] [.] +0 1 3 variable [] [Web] +0 3 1 operator [] [.] +0 1 10 variable [] [RenderMode] +0 10 1 operator [] [.] +0 1 17 variable [] [InteractiveServer] +2 0 4 markupCommentPunctuation [] [] +2 0 1 razorTransition [] [@] +0 1 1 razorTransition [] [{] +1 4 3 keyword [] [var] +0 4 1 variable [] [r] +0 2 1 operator [] [=] +0 2 9 namespace [] [Microsoft] +0 9 1 operator [] [.] +0 1 10 variable [] [AspNetCore] +0 10 1 operator [] [.] +0 1 10 variable [] [Components] +0 10 1 operator [] [.] +0 1 3 variable [] [Web] +0 3 1 operator [] [.] +0 1 10 variable [] [RenderMode] +0 10 1 operator [] [.] +0 1 15 variable [] [InteractiveAuto] +0 15 1 punctuation [] [;] +1 0 1 razorTransition [] [}] diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_with_background.txt b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_with_background.txt new file mode 100644 index 00000000000..21f9e8c06e0 --- /dev/null +++ b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_with_background.txt @@ -0,0 +1,28 @@ +Line Δ, Char Δ, Length, Type, Modifier(s), Text +0 0 1 razorTransition [] [@] +0 1 10 razorDirective [] [rendermode] +2 0 4 markupCommentPunctuation [] [] +2 0 1 razorTransition [razorCode] [@] +0 1 1 razorTransition [razorCode] [{] +1 0 4 markupTextLiteral [razorCode] [ ] +0 4 3 keyword [razorCode] [var] +0 3 1 markupTextLiteral [razorCode] [ ] +0 1 1 variable [razorCode] [r] +0 1 1 markupTextLiteral [razorCode] [ ] +0 1 1 operator [razorCode] [=] +0 1 1 markupTextLiteral [razorCode] [ ] +0 1 9 namespace [razorCode] [Microsoft] +0 9 1 operator [razorCode] [.] +0 1 10 namespace [razorCode] [AspNetCore] +0 10 1 operator [razorCode] [.] +0 1 10 namespace [razorCode] [Components] +0 10 1 operator [razorCode] [.] +0 1 3 namespace [razorCode] [Web] +0 3 1 operator [razorCode] [.] +0 1 10 class [static, razorCode] [RenderMode] +0 10 1 operator [razorCode] [.] +0 1 15 property [static, razorCode] [InteractiveAuto] +0 15 1 punctuation [razorCode] [;] +1 0 1 razorTransition [razorCode] [}] diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_with_background_misc_file.txt b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_with_background_misc_file.txt new file mode 100644 index 00000000000..b86e269b4ce --- /dev/null +++ b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_with_background_misc_file.txt @@ -0,0 +1,39 @@ +Line Δ, Char Δ, Length, Type, Modifier(s), Text +0 0 1 razorTransition [] [@] +0 1 10 razorDirective [] [rendermode] +0 11 9 namespace [razorCode] [Microsoft] +0 9 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [AspNetCore] +0 10 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [Components] +0 10 1 operator [razorCode] [.] +0 1 3 variable [razorCode] [Web] +0 3 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [RenderMode] +0 10 1 operator [razorCode] [.] +0 1 17 variable [razorCode] [InteractiveServer] +2 0 4 markupCommentPunctuation [] [] +2 0 1 razorTransition [razorCode] [@] +0 1 1 razorTransition [razorCode] [{] +1 0 4 markupTextLiteral [razorCode] [ ] +0 4 3 keyword [razorCode] [var] +0 3 1 markupTextLiteral [razorCode] [ ] +0 1 1 variable [razorCode] [r] +0 1 1 markupTextLiteral [razorCode] [ ] +0 1 1 operator [razorCode] [=] +0 1 1 markupTextLiteral [razorCode] [ ] +0 1 9 namespace [razorCode] [Microsoft] +0 9 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [AspNetCore] +0 10 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [Components] +0 10 1 operator [razorCode] [.] +0 1 3 variable [razorCode] [Web] +0 3 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [RenderMode] +0 10 1 operator [razorCode] [.] +0 1 15 variable [razorCode] [InteractiveAuto] +0 15 1 punctuation [razorCode] [;] +1 0 1 razorTransition [razorCode] [}] diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_misc_file.txt b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_misc_file.txt new file mode 100644 index 00000000000..f58c30bdcfd --- /dev/null +++ b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_misc_file.txt @@ -0,0 +1,35 @@ +Line Δ, Char Δ, Length, Type, Modifier(s), Text +0 0 1 razorTransition [] [@] +0 1 10 razorDirective [] [rendermode] +0 11 9 namespace [] [Microsoft] +0 9 1 operator [] [.] +0 1 10 variable [] [AspNetCore] +0 10 1 operator [] [.] +0 1 10 variable [] [Components] +0 10 1 operator [] [.] +0 1 3 variable [] [Web] +0 3 1 operator [] [.] +0 1 10 variable [] [RenderMode] +0 10 1 operator [] [.] +0 1 17 variable [] [InteractiveServer] +2 0 4 markupCommentPunctuation [] [] +2 0 1 razorTransition [] [@] +0 1 1 razorTransition [] [{] +1 4 3 keyword [] [var] +0 4 1 variable [] [r] +0 2 1 operator [] [=] +0 2 9 namespace [] [Microsoft] +0 9 1 operator [] [.] +0 1 10 variable [] [AspNetCore] +0 10 1 operator [] [.] +0 1 10 variable [] [Components] +0 10 1 operator [] [.] +0 1 3 variable [] [Web] +0 3 1 operator [] [.] +0 1 10 variable [] [RenderMode] +0 10 1 operator [] [.] +0 1 15 variable [] [InteractiveAuto] +0 15 1 punctuation [] [;] +1 0 1 razorTransition [] [}] diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_with_background.txt b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_with_background.txt new file mode 100644 index 00000000000..54072f691e4 --- /dev/null +++ b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_with_background.txt @@ -0,0 +1,39 @@ +Line Δ, Char Δ, Length, Type, Modifier(s), Text +0 0 1 razorTransition [] [@] +0 1 10 razorDirective [] [rendermode] +0 11 9 namespace [razorCode] [Microsoft] +0 9 1 operator [razorCode] [.] +0 1 10 namespace [razorCode] [AspNetCore] +0 10 1 operator [razorCode] [.] +0 1 10 namespace [razorCode] [Components] +0 10 1 operator [razorCode] [.] +0 1 3 namespace [razorCode] [Web] +0 3 1 operator [razorCode] [.] +0 1 10 class [static, razorCode] [RenderMode] +0 10 1 operator [razorCode] [.] +0 1 17 property [static, razorCode] [InteractiveServer] +2 0 4 markupCommentPunctuation [] [] +2 0 1 razorTransition [razorCode] [@] +0 1 1 razorTransition [razorCode] [{] +1 0 4 markupTextLiteral [razorCode] [ ] +0 4 3 keyword [razorCode] [var] +0 3 1 markupTextLiteral [razorCode] [ ] +0 1 1 variable [razorCode] [r] +0 1 1 markupTextLiteral [razorCode] [ ] +0 1 1 operator [razorCode] [=] +0 1 1 markupTextLiteral [razorCode] [ ] +0 1 9 namespace [razorCode] [Microsoft] +0 9 1 operator [razorCode] [.] +0 1 10 namespace [razorCode] [AspNetCore] +0 10 1 operator [razorCode] [.] +0 1 10 namespace [razorCode] [Components] +0 10 1 operator [razorCode] [.] +0 1 3 namespace [razorCode] [Web] +0 3 1 operator [razorCode] [.] +0 1 10 class [static, razorCode] [RenderMode] +0 10 1 operator [razorCode] [.] +0 1 15 property [static, razorCode] [InteractiveAuto] +0 15 1 punctuation [razorCode] [;] +1 0 1 razorTransition [razorCode] [}] diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_with_background_misc_file.txt b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_with_background_misc_file.txt new file mode 100644 index 00000000000..71d70992bad --- /dev/null +++ b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_with_background_misc_file.txt @@ -0,0 +1,39 @@ +Line Δ, Char Δ, Length, Type, Modifier(s), Text +0 0 1 razorTransition [] [@] +0 1 10 razorDirective [] [rendermode] +0 11 9 namespace [razorCode] [Microsoft] +0 9 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [AspNetCore] +0 10 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [Components] +0 10 1 operator [razorCode] [.] +0 1 3 variable [razorCode] [Web] +0 3 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [RenderMode] +0 10 1 operator [razorCode] [.] +0 1 17 variable [razorCode] [InteractiveServer] +2 0 4 markupCommentPunctuation [] [] +2 0 1 razorTransition [razorCode] [@] +0 1 1 razorTransition [razorCode] [{] +1 0 4 markupTextLiteral [razorCode] [ ] +0 4 3 keyword [razorCode] [var] +0 3 1 markupTextLiteral [razorCode] [ ] +0 1 1 variable [razorCode] [r] +0 1 1 markupTextLiteral [razorCode] [ ] +0 1 1 operator [razorCode] [=] +0 1 1 markupTextLiteral [razorCode] [ ] +0 1 9 namespace [razorCode] [Microsoft] +0 9 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [AspNetCore] +0 10 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [Components] +0 10 1 operator [razorCode] [.] +0 1 3 variable [razorCode] [Web] +0 3 1 operator [razorCode] [.] +0 1 10 variable [razorCode] [RenderMode] +0 10 1 operator [razorCode] [.] +0 1 15 variable [razorCode] [InteractiveAuto] +0 15 1 punctuation [razorCode] [;] +1 0 1 razorTransition [razorCode] [}] From 97d71f521c804854849bff76c9a3586a8d7c2684 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Fri, 12 Dec 2025 21:50:43 +1100 Subject: [PATCH 06/16] Update directive test baselines --- ...nentRenderModeDirectiveIntegrationTests.cs | 47 ++++++++++++++----- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentRenderModeDirectiveIntegrationTests.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentRenderModeDirectiveIntegrationTests.cs index 0e404a0899b..a4c1b6c0283 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentRenderModeDirectiveIntegrationTests.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentRenderModeDirectiveIntegrationTests.cs @@ -27,7 +27,13 @@ @rendermode Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer VerifyRenderModeAttribute(component, $$""" file sealed class __PrivateComponentRenderModeAttribute : global::Microsoft.AspNetCore.Components.RenderModeAttribute { - private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer + private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => + #nullable restore + #line (3,13)-(3,77) "x:\dir\subdir\Test\TestComponent.cshtml" + Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer + #line default + #line hidden + #nullable disable ; public override global::Microsoft.AspNetCore.Components.IComponentRenderMode Mode => ModeImpl; } @@ -83,7 +89,13 @@ @rendermode Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer VerifyRenderModeAttribute(component, """ private sealed class __PrivateComponentRenderModeAttribute : global::Microsoft.AspNetCore.Components.RenderModeAttribute { - private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer + private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => + #nullable restore + #line (1,13)-(1,77) "x:\dir\subdir\Test\TestComponent.cshtml" + Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer + #line default + #line hidden + #nullable disable ; public override global::Microsoft.AspNetCore.Components.IComponentRenderMode Mode => ModeImpl; } @@ -103,7 +115,13 @@ @rendermode InteractiveServer VerifyRenderModeAttribute(component, """ private sealed class __PrivateComponentRenderModeAttribute : global::Microsoft.AspNetCore.Components.RenderModeAttribute { - private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => InteractiveServer + private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => + #nullable restore + #line (2,13)-(2,30) "x:\dir\subdir\Test\TestComponent.cshtml" + InteractiveServer + #line default + #line hidden + #nullable disable ; public override global::Microsoft.AspNetCore.Components.IComponentRenderMode Mode => ModeImpl; } @@ -124,7 +142,13 @@ @rendermode InteractiveServer VerifyRenderModeAttribute(component, """ file sealed class __PrivateComponentRenderModeAttribute : global::Microsoft.AspNetCore.Components.RenderModeAttribute { - private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => InteractiveServer + private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => + #nullable restore + #line (3,13)-(3,30) "x:\dir\subdir\Test\TestComponent.cshtml" + InteractiveServer + #line default + #line hidden + #nullable disable ; public override global::Microsoft.AspNetCore.Components.IComponentRenderMode Mode => ModeImpl; } @@ -171,10 +195,9 @@ @rendermode NoExist Assert.Empty(compilationResult.RazorDiagnostics); CompileToAssembly(compilationResult, - // x:\dir\subdir\Test\TestComponent.cshtml(25,101): error CS0103: The name 'NoExist' does not exist in the current context - // NoExist - Diagnostic(ErrorCode.ERR_NameNotInContext, "NoExist").WithArguments("NoExist").WithLocation(25, 101) - ); + // x:\dir\subdir\Test\TestComponent.cshtml(1,13): error CS0103: The name 'NoExist' does not exist in the current context + // NoExist + Diagnostic(ErrorCode.ERR_NameNotInContext, "NoExist").WithArguments("NoExist").WithLocation(1, 13)); } [Fact] @@ -234,7 +257,6 @@ @rendermode Foo ); } - [Fact] public void RenderMode_Referencing_Instance_Code() { @@ -249,10 +271,9 @@ @rendermode myRenderMode Assert.Empty(compilationResult.RazorDiagnostics); CompileToAssembly(compilationResult, - // x:\dir\subdir\Test\TestComponent.cshtml(34, 101): error CS0120: An object reference is required for the non-static field, method, or property 'TestComponent.myRenderMode' - // myRenderMode - Diagnostic(ErrorCode.ERR_ObjectRequired, "myRenderMode").WithArguments("Test.TestComponent.myRenderMode").WithLocation(34, 101) - ); + // x:\dir\subdir\Test\TestComponent.cshtml(1,13): error CS0120: An object reference is required for the non-static field, method, or property 'TestComponent.myRenderMode' + // myRenderMode + Diagnostic(ErrorCode.ERR_ObjectRequired, "myRenderMode").WithArguments("Test.TestComponent.myRenderMode").WithLocation(1, 13)); } [Fact] From 0a5c83f243395214335758ea4c289d35394421a9 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Fri, 12 Dec 2025 21:55:16 +1100 Subject: [PATCH 07/16] Regenerate baselines for a couple of compiler integration tests, for your review --- .../ComponentCodeGenerationTestBase.cs | 15 +++++++++++++++ .../TestComponent.ir.txt | 2 +- .../TestComponent.mappings.txt | 5 +++++ .../TestComponent.codegen.cs | 10 +++++++++- .../TestComponent.ir.txt | 2 +- .../TestComponent.mappings.txt | 5 +++++ 6 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs index 1d957c34f87..2a7dc87d70e 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -12163,6 +12163,21 @@ @rendermode Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer CompileToAssembly(generated); } + [IntegrationTestFact] + public void RenderMode_Directive_WithTypeParam_Razor9() + { + var generated = CompileToCSharp(""" + @typeparam T + @rendermode Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer + """, + configuration: Configuration with { LanguageVersion = RazorLanguageVersion.Version_9_0 }); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + [IntegrationTestFact] public void RenderMode_Directive_WithTypeParam_First() { diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithTypeParam/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithTypeParam/TestComponent.ir.txt index 9eaa469b410..8b57f941b00 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithTypeParam/TestComponent.ir.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithTypeParam/TestComponent.ir.txt @@ -29,7 +29,7 @@ CSharpCode - IntermediateToken - - CSharp - private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => CSharpCode - (26:1,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) - IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer + IntermediateToken - (26:1,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer IntermediateToken - - CSharp - ; CSharpCode - IntermediateToken - - CSharp - public override global::Microsoft.AspNetCore.Components.IComponentRenderMode Mode => ModeImpl; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithTypeParam/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithTypeParam/TestComponent.mappings.txt index b0f2e6eba1c..f4610091808 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithTypeParam/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithTypeParam/TestComponent.mappings.txt @@ -8,3 +8,8 @@ Source Location: (26:1,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) Generated Location: (971:33,44 [64] ) |Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer| +Source Location: (26:1,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) +|Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer| +Generated Location: (2086:63,12 [64] ) +|Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam/TestComponent.codegen.cs index 10104da8a51..c976239e20b 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam/TestComponent.codegen.cs @@ -31,7 +31,15 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. } file sealed class __PrivateComponentRenderModeAttribute : global::Microsoft.AspNetCore.Components.RenderModeAttribute { - private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer + private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => +#nullable restore +#line (2,13)-(2,77) "x:\dir\subdir\Test\TestComponent.cshtml" +Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer + +#line default +#line hidden +#nullable disable + ; public override global::Microsoft.AspNetCore.Components.IComponentRenderMode Mode => ModeImpl; } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam/TestComponent.ir.txt index cb77278e555..89b6b2a3930 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam/TestComponent.ir.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam/TestComponent.ir.txt @@ -13,7 +13,7 @@ CSharpCode - IntermediateToken - - CSharp - private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => CSharpCode - (26:1,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) - IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer + IntermediateToken - (26:1,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer IntermediateToken - - CSharp - ; CSharpCode - IntermediateToken - - CSharp - public override global::Microsoft.AspNetCore.Components.IComponentRenderMode Mode => ModeImpl; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam/TestComponent.mappings.txt index d51bcb9ed83..87aeafd088c 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam/TestComponent.mappings.txt @@ -3,3 +3,8 @@ Generated Location: (519:17,0 [1] ) |T| +Source Location: (26:1,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) +|Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer| +Generated Location: (1208:36,0 [64] ) +|Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer| + From 475e13b395bf804aec2871638f4c47e126689d50 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Fri, 12 Dec 2025 22:34:48 +1100 Subject: [PATCH 08/16] Update compiler test baselines --- .../TestComponent.ir.txt | 2 +- .../TestComponent.mappings.txt | 5 +++++ .../TestComponent.ir.txt | 2 +- .../TestComponent.mappings.txt | 5 +++++ .../TestComponent.ir.txt | 2 +- .../TestComponent.mappings.txt | 5 +++++ .../TestComponent.codegen.cs | 10 +++++++++- .../TestComponent.ir.txt | 2 +- .../TestComponent.mappings.txt | 5 +++++ .../TestComponent.codegen.cs | 10 +++++++++- .../TestComponent.ir.txt | 2 +- .../TestComponent.mappings.txt | 5 +++++ .../TestComponent.codegen.cs | 10 +++++++++- .../TestComponent.ir.txt | 2 +- .../TestComponent.mappings.txt | 5 +++++ 15 files changed, 63 insertions(+), 9 deletions(-) create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_FullyQualified/TestComponent.mappings.txt diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_FullyQualified/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_FullyQualified/TestComponent.ir.txt index 45dc06bf2ca..de07c841928 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_FullyQualified/TestComponent.ir.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_FullyQualified/TestComponent.ir.txt @@ -28,7 +28,7 @@ CSharpCode - IntermediateToken - - CSharp - private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => CSharpCode - (12:0,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) - IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer + IntermediateToken - (12:0,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer IntermediateToken - - CSharp - ; CSharpCode - IntermediateToken - - CSharp - public override global::Microsoft.AspNetCore.Components.IComponentRenderMode Mode => ModeImpl; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_FullyQualified/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_FullyQualified/TestComponent.mappings.txt index 668e0fe7fe4..18ccc635016 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_FullyQualified/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_FullyQualified/TestComponent.mappings.txt @@ -3,3 +3,8 @@ Generated Location: (799:22,44 [64] ) |Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer| +Source Location: (12:0,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) +|Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer| +Generated Location: (1950:51,12 [64] ) +|Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithNamespaces/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithNamespaces/TestComponent.ir.txt index 353bbbbec49..697dd51ef76 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithNamespaces/TestComponent.ir.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithNamespaces/TestComponent.ir.txt @@ -31,7 +31,7 @@ CSharpCode - IntermediateToken - - CSharp - private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => CSharpCode - (43:2,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) - IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer + IntermediateToken - (43:2,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer IntermediateToken - - CSharp - ; CSharpCode - IntermediateToken - - CSharp - public override global::Microsoft.AspNetCore.Components.IComponentRenderMode Mode => ModeImpl; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithNamespaces/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithNamespaces/TestComponent.mappings.txt index 45faf716a9b..a13a0f95e58 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithNamespaces/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithNamespaces/TestComponent.mappings.txt @@ -8,3 +8,8 @@ Source Location: (43:2,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) Generated Location: (1075:32,44 [64] ) |Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer| +Source Location: (43:2,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) +|Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer| +Generated Location: (2226:61,12 [64] ) +|Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_First/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_First/TestComponent.ir.txt index 2cb3caa0e59..5fee6bcbd11 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_First/TestComponent.ir.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_First/TestComponent.ir.txt @@ -29,7 +29,7 @@ CSharpCode - IntermediateToken - - CSharp - private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => CSharpCode - (12:0,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) - IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer + IntermediateToken - (12:0,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer IntermediateToken - - CSharp - ; CSharpCode - IntermediateToken - - CSharp - public override global::Microsoft.AspNetCore.Components.IComponentRenderMode Mode => ModeImpl; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_First/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_First/TestComponent.mappings.txt index c4b88fa2dd3..354d7462dfd 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_First/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_First/TestComponent.mappings.txt @@ -8,3 +8,8 @@ Source Location: (12:0,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) Generated Location: (903:30,44 [64] ) |Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer| +Source Location: (12:0,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) +|Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer| +Generated Location: (2086:63,12 [64] ) +|Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_FullyQualified/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_FullyQualified/TestComponent.codegen.cs index 09254ae367b..21583a385ae 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_FullyQualified/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_FullyQualified/TestComponent.codegen.cs @@ -22,7 +22,15 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #pragma warning restore 1998 private sealed class __PrivateComponentRenderModeAttribute : global::Microsoft.AspNetCore.Components.RenderModeAttribute { - private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer + private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => +#nullable restore +#line (1,13)-(1,77) "x:\dir\subdir\Test\TestComponent.cshtml" +Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer + +#line default +#line hidden +#nullable disable + ; public override global::Microsoft.AspNetCore.Components.IComponentRenderMode Mode => ModeImpl; } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_FullyQualified/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_FullyQualified/TestComponent.ir.txt index 09fb15ec983..dd168de9614 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_FullyQualified/TestComponent.ir.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_FullyQualified/TestComponent.ir.txt @@ -13,7 +13,7 @@ CSharpCode - IntermediateToken - - CSharp - private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => CSharpCode - (12:0,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) - IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer + IntermediateToken - (12:0,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer IntermediateToken - - CSharp - ; CSharpCode - IntermediateToken - - CSharp - public override global::Microsoft.AspNetCore.Components.IComponentRenderMode Mode => ModeImpl; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_FullyQualified/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_FullyQualified/TestComponent.mappings.txt new file mode 100644 index 00000000000..f43427c96e2 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_FullyQualified/TestComponent.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (12:0,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) +|Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer| +Generated Location: (1100:27,0 [64] ) +|Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithNamespaces/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithNamespaces/TestComponent.codegen.cs index aad4143b641..973716b765a 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithNamespaces/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithNamespaces/TestComponent.codegen.cs @@ -29,7 +29,15 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #pragma warning restore 1998 private sealed class __PrivateComponentRenderModeAttribute : global::Microsoft.AspNetCore.Components.RenderModeAttribute { - private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer + private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => +#nullable restore +#line (3,13)-(3,77) "x:\dir\subdir\Test\TestComponent.cshtml" +Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer + +#line default +#line hidden +#nullable disable + ; public override global::Microsoft.AspNetCore.Components.IComponentRenderMode Mode => ModeImpl; } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithNamespaces/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithNamespaces/TestComponent.ir.txt index 05166e87312..94b04eb6e6b 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithNamespaces/TestComponent.ir.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithNamespaces/TestComponent.ir.txt @@ -13,7 +13,7 @@ CSharpCode - IntermediateToken - - CSharp - private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => CSharpCode - (43:2,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) - IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer + IntermediateToken - (43:2,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer IntermediateToken - - CSharp - ; CSharpCode - IntermediateToken - - CSharp - public override global::Microsoft.AspNetCore.Components.IComponentRenderMode Mode => ModeImpl; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithNamespaces/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithNamespaces/TestComponent.mappings.txt index 2d3d9bb71c1..f4bd9529513 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithNamespaces/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithNamespaces/TestComponent.mappings.txt @@ -3,3 +3,8 @@ Generated Location: (146:5,0 [16] ) |Custom.Namespace| +Source Location: (43:2,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) +|Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer| +Generated Location: (1258:34,0 [64] ) +|Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_First/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_First/TestComponent.codegen.cs index b39d974fe95..f717453f37f 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_First/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_First/TestComponent.codegen.cs @@ -31,7 +31,15 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. } file sealed class __PrivateComponentRenderModeAttribute : global::Microsoft.AspNetCore.Components.RenderModeAttribute { - private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer + private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => +#nullable restore +#line (1,13)-(1,77) "x:\dir\subdir\Test\TestComponent.cshtml" +Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer + +#line default +#line hidden +#nullable disable + ; public override global::Microsoft.AspNetCore.Components.IComponentRenderMode Mode => ModeImpl; } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_First/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_First/TestComponent.ir.txt index 7953a6f8d4a..82e79475ddc 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_First/TestComponent.ir.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_First/TestComponent.ir.txt @@ -13,7 +13,7 @@ CSharpCode - IntermediateToken - - CSharp - private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => CSharpCode - (12:0,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) - IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer + IntermediateToken - (12:0,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer IntermediateToken - - CSharp - ; CSharpCode - IntermediateToken - - CSharp - public override global::Microsoft.AspNetCore.Components.IComponentRenderMode Mode => ModeImpl; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_First/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_First/TestComponent.mappings.txt index aa0066860dd..69a8af45042 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_First/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_First/TestComponent.mappings.txt @@ -3,3 +3,8 @@ Generated Location: (519:17,0 [1] ) |T| +Source Location: (12:0,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) +|Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer| +Generated Location: (1208:36,0 [64] ) +|Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer| + From f290a30d7b1d174450741044a3c3f9d2f96262ae Mon Sep 17 00:00:00 2001 From: David Wengier Date: Sat, 13 Dec 2025 10:51:14 +1100 Subject: [PATCH 09/16] Fix tests --- .../ComponentCodeGenerationTestBase.cs | 11 ++- .../test/RazorLanguageVersionTest.cs | 2 +- .../TestComponent.codegen.cs | 73 +++++++++++++++++++ .../TestComponent.ir.txt | 35 +++++++++ .../TestComponent.mappings.txt | 10 +++ .../TestComponent.codegen.cs | 39 ++++++++++ .../TestComponent.ir.txt | 19 +++++ .../TestComponent.mappings.txt | 5 ++ 8 files changed, 191 insertions(+), 3 deletions(-) create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_Razor9/TestComponent.codegen.cs create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_Razor9/TestComponent.ir.txt create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_Razor9/TestComponent.mappings.txt create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_Razor9/TestComponent.codegen.cs create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_Razor9/TestComponent.ir.txt create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_Razor9/TestComponent.mappings.txt diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs index 2a7dc87d70e..cb969d332a5 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -12170,12 +12170,19 @@ public void RenderMode_Directive_WithTypeParam_Razor9() @typeparam T @rendermode Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer """, - configuration: Configuration with { LanguageVersion = RazorLanguageVersion.Version_9_0 }); + configuration: Configuration with { LanguageVersion = RazorLanguageVersion.Version_9_0 }, + expectedCSharpDiagnostics: + // (17,19): error CS0305: Using the generic type 'TestComponent' requires 1 type arguments + // [global::Test.TestComponent.__PrivateComponentRenderModeAttribute] + Diagnostic(ErrorCode.ERR_BadArity, "TestComponent").WithArguments("Test.TestComponent", "type", "1").WithLocation(17, 19)); // Assert AssertDocumentNodeMatchesBaseline(generated.CodeDocument); AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); - CompileToAssembly(generated); + CompileToAssembly(generated, + // (13,19): error CS0305: Using the generic type 'TestComponent' requires 1 type arguments + // [global::Test.TestComponent.__PrivateComponentRenderModeAttribute] + Diagnostic(ErrorCode.ERR_BadArity, "TestComponent").WithArguments("Test.TestComponent", "type", "1").WithLocation(13, 19)); } [IntegrationTestFact] diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/RazorLanguageVersionTest.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/RazorLanguageVersionTest.cs index 89fb8bc8e9c..ed4c7f5f1ec 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/RazorLanguageVersionTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/RazorLanguageVersionTest.cs @@ -205,7 +205,7 @@ public void TryParseLatest() // Assert Assert.True(result); Assert.Same(RazorLanguageVersion.Latest, version); - Assert.Same(RazorLanguageVersion.Version_9_0, version); + Assert.Same(RazorLanguageVersion.Version_10_0, version); } [Fact] diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_Razor9/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_Razor9/TestComponent.codegen.cs new file mode 100644 index 00000000000..fca2fa9975c --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_Razor9/TestComponent.codegen.cs @@ -0,0 +1,73 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line default + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::System.Threading.Tasks; + using global::Microsoft.AspNetCore.Components; + #line default + #line hidden + [global::Test.TestComponent.__PrivateComponentRenderModeAttribute] + #nullable restore + public partial class TestComponent< +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +T + +#line default +#line hidden +#nullable disable + > : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((global::System.Action)(() => { + } + ))(); + ((global::System.Action)(() => { +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" +global::System.Object __typeHelper = nameof(Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer); + +#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 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + } + #pragma warning restore 1998 + private sealed class __PrivateComponentRenderModeAttribute : global::Microsoft.AspNetCore.Components.RenderModeAttribute + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static object __o = null; + #pragma warning restore 0414 + private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer + +#line default +#line hidden +#nullable disable + ; + public override global::Microsoft.AspNetCore.Components.IComponentRenderMode Mode => ModeImpl; + } + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_Razor9/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_Razor9/TestComponent.ir.txt new file mode 100644 index 00000000000..a9e3d2358df --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_Razor9/TestComponent.ir.txt @@ -0,0 +1,35 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [20] ) - global::System + UsingDirective - (26:2,1 [40] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [25] ) - global::System.Linq + UsingDirective - (97:4,1 [36] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [45] ) - global::Microsoft.AspNetCore.Components + CSharpCode - + IntermediateToken - - CSharp - [global::Test.TestComponent.__PrivateComponentRenderModeAttribute] + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - - T + DesignTimeDirective - + DirectiveToken - (11:0,11 [1] x:\dir\subdir\Test\TestComponent.cshtml) - T + DirectiveToken - (26:1,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) - Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer + CSharpCode - + IntermediateToken - - CSharp - #pragma warning disable 0414 + CSharpCode - + IntermediateToken - - CSharp - private static object __o = null; + CSharpCode - + IntermediateToken - - CSharp - #pragma warning restore 0414 + MethodDeclaration - - protected override - void - BuildRenderTree + ClassDeclaration - - private sealed - __PrivateComponentRenderModeAttribute - global::Microsoft.AspNetCore.Components.RenderModeAttribute - + DesignTimeDirective - + CSharpCode - + IntermediateToken - - CSharp - #pragma warning disable 0414 + CSharpCode - + IntermediateToken - - CSharp - private static object __o = null; + CSharpCode - + IntermediateToken - - CSharp - #pragma warning restore 0414 + CSharpCode - + IntermediateToken - - CSharp - private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => + CSharpCode - (26:1,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer + IntermediateToken - - CSharp - ; + CSharpCode - + IntermediateToken - - CSharp - public override global::Microsoft.AspNetCore.Components.IComponentRenderMode Mode => ModeImpl; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_Razor9/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_Razor9/TestComponent.mappings.txt new file mode 100644 index 00000000000..f77b4850911 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_Razor9/TestComponent.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (11:0,11 [1] x:\dir\subdir\Test\TestComponent.cshtml) +|T| +Generated Location: (534:17,0 [1] ) +|T| + +Source Location: (26:1,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) +|Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer| +Generated Location: (998:33,44 [64] ) +|Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_Razor9/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_Razor9/TestComponent.codegen.cs new file mode 100644 index 00000000000..2dcf885600f --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_Razor9/TestComponent.codegen.cs @@ -0,0 +1,39 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line default + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::System.Threading.Tasks; + using global::Microsoft.AspNetCore.Components; + #line default + #line hidden + [global::Test.TestComponent.__PrivateComponentRenderModeAttribute] + #nullable restore + public partial class TestComponent< +#nullable restore +#line (1,12)-(1,13) "x:\dir\subdir\Test\TestComponent.cshtml" +T + +#line default +#line hidden +#nullable disable + > : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + } + #pragma warning restore 1998 + private sealed class __PrivateComponentRenderModeAttribute : global::Microsoft.AspNetCore.Components.RenderModeAttribute + { + private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer + ; + public override global::Microsoft.AspNetCore.Components.IComponentRenderMode Mode => ModeImpl; + } + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_Razor9/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_Razor9/TestComponent.ir.txt new file mode 100644 index 00000000000..15e90cdcf64 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_Razor9/TestComponent.ir.txt @@ -0,0 +1,19 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [20] ) - global::System + UsingDirective - (26:2,1 [40] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [25] ) - global::System.Linq + UsingDirective - (97:4,1 [36] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [45] ) - global::Microsoft.AspNetCore.Components + CSharpCode - + IntermediateToken - - CSharp - [global::Test.TestComponent.__PrivateComponentRenderModeAttribute] + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - - T + MethodDeclaration - - protected override - void - BuildRenderTree + ClassDeclaration - - private sealed - __PrivateComponentRenderModeAttribute - global::Microsoft.AspNetCore.Components.RenderModeAttribute - + CSharpCode - + IntermediateToken - - CSharp - private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => + CSharpCode - (26:1,12 [64] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer + IntermediateToken - - CSharp - ; + CSharpCode - + IntermediateToken - - CSharp - public override global::Microsoft.AspNetCore.Components.IComponentRenderMode Mode => ModeImpl; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_Razor9/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_Razor9/TestComponent.mappings.txt new file mode 100644 index 00000000000..97b5870256a --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RenderMode_Directive_WithTypeParam_Razor9/TestComponent.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (11:0,11 [1] x:\dir\subdir\Test\TestComponent.cshtml) +|T| +Generated Location: (546:17,0 [1] ) +|T| + From 58bb9a34c9ad6bdda3a6ef435b780e187700f819 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Sat, 13 Dec 2025 13:02:24 +1100 Subject: [PATCH 10/16] Cross platform fix --- ...ComponentRenderModeDirectiveIntegrationTests.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentRenderModeDirectiveIntegrationTests.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentRenderModeDirectiveIntegrationTests.cs index a4c1b6c0283..bb226ab8b69 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentRenderModeDirectiveIntegrationTests.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentRenderModeDirectiveIntegrationTests.cs @@ -29,7 +29,7 @@ @rendermode Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer { private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => #nullable restore - #line (3,13)-(3,77) "x:\dir\subdir\Test\TestComponent.cshtml" + #line (3,13)-(3,77) "{{DefaultDocumentPath}}" Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer #line default #line hidden @@ -86,12 +86,12 @@ @rendermode Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer """); // Assert - VerifyRenderModeAttribute(component, """ + VerifyRenderModeAttribute(component, $$""" private sealed class __PrivateComponentRenderModeAttribute : global::Microsoft.AspNetCore.Components.RenderModeAttribute { private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => #nullable restore - #line (1,13)-(1,77) "x:\dir\subdir\Test\TestComponent.cshtml" + #line (1,13)-(1,77) "{{DefaultDocumentPath}}" Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer #line default #line hidden @@ -112,12 +112,12 @@ @rendermode InteractiveServer """); // Assert - VerifyRenderModeAttribute(component, """ + VerifyRenderModeAttribute(component, $$""" private sealed class __PrivateComponentRenderModeAttribute : global::Microsoft.AspNetCore.Components.RenderModeAttribute { private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => #nullable restore - #line (2,13)-(2,30) "x:\dir\subdir\Test\TestComponent.cshtml" + #line (2,13)-(2,30) "{{DefaultDocumentPath}}" InteractiveServer #line default #line hidden @@ -139,12 +139,12 @@ @rendermode InteractiveServer """, genericArity: 1); // Assert - VerifyRenderModeAttribute(component, """ + VerifyRenderModeAttribute(component, $$""" file sealed class __PrivateComponentRenderModeAttribute : global::Microsoft.AspNetCore.Components.RenderModeAttribute { private static global::Microsoft.AspNetCore.Components.IComponentRenderMode ModeImpl => #nullable restore - #line (3,13)-(3,30) "x:\dir\subdir\Test\TestComponent.cshtml" + #line (3,13)-(3,30) "{{DefaultDocumentPath}}" InteractiveServer #line default #line hidden From 2fb82bc083b82c4adc316775149cbfdb1b0e2599 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Tue, 16 Dec 2025 21:55:24 +1100 Subject: [PATCH 11/16] Fix test --- .../test/RazorLanguageVersionTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/RazorLanguageVersionTest.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/RazorLanguageVersionTest.cs index ed4c7f5f1ec..89fb8bc8e9c 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/RazorLanguageVersionTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/RazorLanguageVersionTest.cs @@ -205,7 +205,7 @@ public void TryParseLatest() // Assert Assert.True(result); Assert.Same(RazorLanguageVersion.Latest, version); - Assert.Same(RazorLanguageVersion.Version_10_0, version); + Assert.Same(RazorLanguageVersion.Version_9_0, version); } [Fact] From fce8e0f4ca8dc34515b3bdd451cf3316a72ee7ec Mon Sep 17 00:00:00 2001 From: David Wengier Date: Tue, 16 Dec 2025 22:14:50 +1100 Subject: [PATCH 12/16] Fix typo in test names --- .../{RenderFragment.txt => RenderMode.txt} | 0 ...gment_Expression.txt => RenderMode_Expression.txt} | 0 ...c_file.txt => RenderMode_Expression_misc_file.txt} | 0 ....txt => RenderMode_Expression_with_background.txt} | 0 ...nderMode_Expression_with_background_misc_file.txt} | 0 ...enderFragment_Razor9.txt => RenderMode_Razor9.txt} | 0 ..._misc_file.txt => RenderMode_Razor9_misc_file.txt} | 11 ----------- ...ound.txt => RenderMode_Razor9_with_background.txt} | 0 ...> RenderMode_Razor9_with_background_misc_file.txt} | 11 ----------- ...ragment_misc_file.txt => RenderMode_misc_file.txt} | 11 ----------- ..._background.txt => RenderMode_with_background.txt} | 0 ...e.txt => RenderMode_with_background_misc_file.txt} | 11 ----------- .../Shared/CohostSemanticTokensRangeEndpointTest.cs | 6 +++--- .../{RenderFragment.txt => RenderMode.txt} | 0 ...gment_Expression.txt => RenderMode_Expression.txt} | 0 ...c_file.txt => RenderMode_Expression_misc_file.txt} | 0 ....txt => RenderMode_Expression_with_background.txt} | 0 ...nderMode_Expression_with_background_misc_file.txt} | 0 ...enderFragment_Razor9.txt => RenderMode_Razor9.txt} | 0 ..._misc_file.txt => RenderMode_Razor9_misc_file.txt} | 11 ----------- ...ound.txt => RenderMode_Razor9_with_background.txt} | 0 ...> RenderMode_Razor9_with_background_misc_file.txt} | 11 ----------- ...ragment_misc_file.txt => RenderMode_misc_file.txt} | 11 ----------- ..._background.txt => RenderMode_with_background.txt} | 0 ...e.txt => RenderMode_with_background_misc_file.txt} | 11 ----------- 25 files changed, 3 insertions(+), 91 deletions(-) rename src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/{RenderFragment.txt => RenderMode.txt} (100%) rename src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/{RenderFragment_Expression.txt => RenderMode_Expression.txt} (100%) rename src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/{RenderFragment_Expression_misc_file.txt => RenderMode_Expression_misc_file.txt} (100%) rename src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/{RenderFragment_Expression_with_background.txt => RenderMode_Expression_with_background.txt} (100%) rename src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/{RenderFragment_Expression_with_background_misc_file.txt => RenderMode_Expression_with_background_misc_file.txt} (100%) rename src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/{RenderFragment_Razor9.txt => RenderMode_Razor9.txt} (100%) rename src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/{RenderFragment_Razor9_misc_file.txt => RenderMode_Razor9_misc_file.txt} (71%) rename src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/{RenderFragment_Razor9_with_background.txt => RenderMode_Razor9_with_background.txt} (100%) rename src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/{RenderFragment_Razor9_with_background_misc_file.txt => RenderMode_Razor9_with_background_misc_file.txt} (72%) rename src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/{RenderFragment_misc_file.txt => RenderMode_misc_file.txt} (71%) rename src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/{RenderFragment_with_background.txt => RenderMode_with_background.txt} (100%) rename src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/{RenderFragment_with_background_misc_file.txt => RenderMode_with_background_misc_file.txt} (72%) rename src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/{RenderFragment.txt => RenderMode.txt} (100%) rename src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/{RenderFragment_Expression.txt => RenderMode_Expression.txt} (100%) rename src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/{RenderFragment_Expression_misc_file.txt => RenderMode_Expression_misc_file.txt} (100%) rename src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/{RenderFragment_Expression_with_background.txt => RenderMode_Expression_with_background.txt} (100%) rename src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/{RenderFragment_Expression_with_background_misc_file.txt => RenderMode_Expression_with_background_misc_file.txt} (100%) rename src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/{RenderFragment_Razor9.txt => RenderMode_Razor9.txt} (100%) rename src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/{RenderFragment_Razor9_misc_file.txt => RenderMode_Razor9_misc_file.txt} (71%) rename src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/{RenderFragment_Razor9_with_background.txt => RenderMode_Razor9_with_background.txt} (100%) rename src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/{RenderFragment_Razor9_with_background_misc_file.txt => RenderMode_Razor9_with_background_misc_file.txt} (73%) rename src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/{RenderFragment_misc_file.txt => RenderMode_misc_file.txt} (71%) rename src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/{RenderFragment_with_background.txt => RenderMode_with_background.txt} (100%) rename src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/{RenderFragment_with_background_misc_file.txt => RenderMode_with_background_misc_file.txt} (72%) diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderMode.txt similarity index 100% rename from src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment.txt rename to src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderMode.txt diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Expression.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderMode_Expression.txt similarity index 100% rename from src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Expression.txt rename to src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderMode_Expression.txt diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Expression_misc_file.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderMode_Expression_misc_file.txt similarity index 100% rename from src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Expression_misc_file.txt rename to src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderMode_Expression_misc_file.txt diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Expression_with_background.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderMode_Expression_with_background.txt similarity index 100% rename from src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Expression_with_background.txt rename to src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderMode_Expression_with_background.txt diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Expression_with_background_misc_file.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderMode_Expression_with_background_misc_file.txt similarity index 100% rename from src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Expression_with_background_misc_file.txt rename to src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderMode_Expression_with_background_misc_file.txt diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Razor9.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderMode_Razor9.txt similarity index 100% rename from src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Razor9.txt rename to src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderMode_Razor9.txt diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_misc_file.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderMode_Razor9_misc_file.txt similarity index 71% rename from src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_misc_file.txt rename to src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderMode_Razor9_misc_file.txt index 2e2f2814a9a..ffac864b56b 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_misc_file.txt +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderMode_Razor9_misc_file.txt @@ -1,17 +1,6 @@ Line Δ, Char Δ, Length, Type, Modifier(s), Text 0 0 1 razorTransition [] [@] 0 1 10 razorDirective [] [rendermode] -0 11 9 namespace name [] [Microsoft] -0 9 1 operator [] [.] -0 1 10 variable [] [AspNetCore] -0 10 1 operator [] [.] -0 1 10 variable [] [Components] -0 10 1 operator [] [.] -0 1 3 variable [] [Web] -0 3 1 operator [] [.] -0 1 10 variable [] [RenderMode] -0 10 1 operator [] [.] -0 1 17 variable [] [InteractiveServer] 2 0 4 markupCommentPunctuation [] [] diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_with_background.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderMode_Razor9_with_background.txt similarity index 100% rename from src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_with_background.txt rename to src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderMode_Razor9_with_background.txt diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_with_background_misc_file.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderMode_Razor9_with_background_misc_file.txt similarity index 72% rename from src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_with_background_misc_file.txt rename to src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderMode_Razor9_with_background_misc_file.txt index ac88a4ec265..4e21ae47ba6 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_with_background_misc_file.txt +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderMode_Razor9_with_background_misc_file.txt @@ -1,17 +1,6 @@ Line Δ, Char Δ, Length, Type, Modifier(s), Text 0 0 1 razorTransition [] [@] 0 1 10 razorDirective [] [rendermode] -0 11 9 namespace name [razorCode] [Microsoft] -0 9 1 operator [razorCode] [.] -0 1 10 variable [razorCode] [AspNetCore] -0 10 1 operator [razorCode] [.] -0 1 10 variable [razorCode] [Components] -0 10 1 operator [razorCode] [.] -0 1 3 variable [razorCode] [Web] -0 3 1 operator [razorCode] [.] -0 1 10 variable [razorCode] [RenderMode] -0 10 1 operator [razorCode] [.] -0 1 17 variable [razorCode] [InteractiveServer] 2 0 4 markupCommentPunctuation [] [] diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_misc_file.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderMode_misc_file.txt similarity index 71% rename from src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_misc_file.txt rename to src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderMode_misc_file.txt index f20b19cfd6d..00903218742 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_misc_file.txt +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderMode_misc_file.txt @@ -1,17 +1,6 @@ Line Δ, Char Δ, Length, Type, Modifier(s), Text 0 0 1 razorTransition [] [@] 0 1 10 razorDirective [] [rendermode] -0 11 9 namespace name [] [Microsoft] -0 9 1 operator [] [.] -0 1 10 variable [] [AspNetCore] -0 10 1 operator [] [.] -0 1 10 variable [] [Components] -0 10 1 operator [] [.] -0 1 3 variable [] [Web] -0 3 1 operator [] [.] -0 1 10 variable [] [RenderMode] -0 10 1 operator [] [.] -0 1 17 variable [] [InteractiveServer] 2 0 4 markupCommentPunctuation [] [] diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_with_background.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderMode_with_background.txt similarity index 100% rename from src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_with_background.txt rename to src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderMode_with_background.txt diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_with_background_misc_file.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderMode_with_background_misc_file.txt similarity index 72% rename from src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_with_background_misc_file.txt rename to src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderMode_with_background_misc_file.txt index f8c0f4e9b84..144c9cc2670 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderFragment_with_background_misc_file.txt +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/RenderMode_with_background_misc_file.txt @@ -1,17 +1,6 @@ Line Δ, Char Δ, Length, Type, Modifier(s), Text 0 0 1 razorTransition [] [@] 0 1 10 razorDirective [] [rendermode] -0 11 9 namespace name [razorCode] [Microsoft] -0 9 1 operator [razorCode] [.] -0 1 10 variable [razorCode] [AspNetCore] -0 10 1 operator [razorCode] [.] -0 1 10 variable [razorCode] [Components] -0 10 1 operator [razorCode] [.] -0 1 3 variable [razorCode] [Web] -0 3 1 operator [razorCode] [.] -0 1 10 variable [razorCode] [RenderMode] -0 10 1 operator [razorCode] [.] -0 1 17 variable [razorCode] [InteractiveServer] 2 0 4 markupCommentPunctuation [] [] diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/Endpoints/Shared/CohostSemanticTokensRangeEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/Endpoints/Shared/CohostSemanticTokensRangeEndpointTest.cs index 76bea26cc22..978d29d830d 100644 --- a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/Endpoints/Shared/CohostSemanticTokensRangeEndpointTest.cs +++ b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/Endpoints/Shared/CohostSemanticTokensRangeEndpointTest.cs @@ -138,7 +138,7 @@ public void M() [Theory] [CombinatorialData] - public async Task RenderFragment(bool colorBackground, bool miscellaneousFile) + public async Task RenderMode(bool colorBackground, bool miscellaneousFile) { var input = """ @rendermode Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer @@ -155,7 +155,7 @@ @rendermode Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer [Theory] [CombinatorialData] - public async Task RenderFragment_Razor9(bool colorBackground, bool miscellaneousFile) + public async Task RenderMode_Razor9(bool colorBackground, bool miscellaneousFile) { var input = """ @rendermode Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer @@ -176,7 +176,7 @@ await VerifySemanticTokensAsync( [Theory] [CombinatorialData] - public async Task RenderFragment_Expression(bool colorBackground, bool miscellaneousFile) + public async Task RenderMode_Expression(bool colorBackground, bool miscellaneousFile) { var input = """ @rendermode @(Microsoft.AspNetCore.Components.Web.RenderMode.InteractiveServer) diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment.txt b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderMode.txt similarity index 100% rename from src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment.txt rename to src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderMode.txt diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Expression.txt b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderMode_Expression.txt similarity index 100% rename from src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Expression.txt rename to src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderMode_Expression.txt diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Expression_misc_file.txt b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderMode_Expression_misc_file.txt similarity index 100% rename from src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Expression_misc_file.txt rename to src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderMode_Expression_misc_file.txt diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Expression_with_background.txt b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderMode_Expression_with_background.txt similarity index 100% rename from src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Expression_with_background.txt rename to src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderMode_Expression_with_background.txt diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Expression_with_background_misc_file.txt b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderMode_Expression_with_background_misc_file.txt similarity index 100% rename from src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Expression_with_background_misc_file.txt rename to src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderMode_Expression_with_background_misc_file.txt diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Razor9.txt b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderMode_Razor9.txt similarity index 100% rename from src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Razor9.txt rename to src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderMode_Razor9.txt diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_misc_file.txt b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderMode_Razor9_misc_file.txt similarity index 71% rename from src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_misc_file.txt rename to src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderMode_Razor9_misc_file.txt index a5c4374ca80..e0835ae4ff3 100644 --- a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_misc_file.txt +++ b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderMode_Razor9_misc_file.txt @@ -1,17 +1,6 @@ Line Δ, Char Δ, Length, Type, Modifier(s), Text 0 0 1 razorTransition [] [@] 0 1 10 razorDirective [] [rendermode] -0 11 9 namespace [] [Microsoft] -0 9 1 operator [] [.] -0 1 10 variable [] [AspNetCore] -0 10 1 operator [] [.] -0 1 10 variable [] [Components] -0 10 1 operator [] [.] -0 1 3 variable [] [Web] -0 3 1 operator [] [.] -0 1 10 variable [] [RenderMode] -0 10 1 operator [] [.] -0 1 17 variable [] [InteractiveServer] 2 0 4 markupCommentPunctuation [] [] diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_with_background.txt b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderMode_Razor9_with_background.txt similarity index 100% rename from src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_with_background.txt rename to src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderMode_Razor9_with_background.txt diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_with_background_misc_file.txt b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderMode_Razor9_with_background_misc_file.txt similarity index 73% rename from src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_with_background_misc_file.txt rename to src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderMode_Razor9_with_background_misc_file.txt index b86e269b4ce..7f717ed7d6e 100644 --- a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_Razor9_with_background_misc_file.txt +++ b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderMode_Razor9_with_background_misc_file.txt @@ -1,17 +1,6 @@ Line Δ, Char Δ, Length, Type, Modifier(s), Text 0 0 1 razorTransition [] [@] 0 1 10 razorDirective [] [rendermode] -0 11 9 namespace [razorCode] [Microsoft] -0 9 1 operator [razorCode] [.] -0 1 10 variable [razorCode] [AspNetCore] -0 10 1 operator [razorCode] [.] -0 1 10 variable [razorCode] [Components] -0 10 1 operator [razorCode] [.] -0 1 3 variable [razorCode] [Web] -0 3 1 operator [razorCode] [.] -0 1 10 variable [razorCode] [RenderMode] -0 10 1 operator [razorCode] [.] -0 1 17 variable [razorCode] [InteractiveServer] 2 0 4 markupCommentPunctuation [] [] diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_misc_file.txt b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderMode_misc_file.txt similarity index 71% rename from src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_misc_file.txt rename to src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderMode_misc_file.txt index f58c30bdcfd..14e50aad65a 100644 --- a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_misc_file.txt +++ b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderMode_misc_file.txt @@ -1,17 +1,6 @@ Line Δ, Char Δ, Length, Type, Modifier(s), Text 0 0 1 razorTransition [] [@] 0 1 10 razorDirective [] [rendermode] -0 11 9 namespace [] [Microsoft] -0 9 1 operator [] [.] -0 1 10 variable [] [AspNetCore] -0 10 1 operator [] [.] -0 1 10 variable [] [Components] -0 10 1 operator [] [.] -0 1 3 variable [] [Web] -0 3 1 operator [] [.] -0 1 10 variable [] [RenderMode] -0 10 1 operator [] [.] -0 1 17 variable [] [InteractiveServer] 2 0 4 markupCommentPunctuation [] [] diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_with_background.txt b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderMode_with_background.txt similarity index 100% rename from src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_with_background.txt rename to src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderMode_with_background.txt diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_with_background_misc_file.txt b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderMode_with_background_misc_file.txt similarity index 72% rename from src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_with_background_misc_file.txt rename to src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderMode_with_background_misc_file.txt index 71d70992bad..efafbb18d7a 100644 --- a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderFragment_with_background_misc_file.txt +++ b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/TestFiles/SemanticTokens/RenderMode_with_background_misc_file.txt @@ -1,17 +1,6 @@ Line Δ, Char Δ, Length, Type, Modifier(s), Text 0 0 1 razorTransition [] [@] 0 1 10 razorDirective [] [rendermode] -0 11 9 namespace [razorCode] [Microsoft] -0 9 1 operator [razorCode] [.] -0 1 10 variable [razorCode] [AspNetCore] -0 10 1 operator [razorCode] [.] -0 1 10 variable [razorCode] [Components] -0 10 1 operator [razorCode] [.] -0 1 3 variable [razorCode] [Web] -0 3 1 operator [razorCode] [.] -0 1 10 variable [razorCode] [RenderMode] -0 10 1 operator [razorCode] [.] -0 1 17 variable [razorCode] [InteractiveServer] 2 0 4 markupCommentPunctuation [] [] From 479f7517f4423d9dcb462a576230c254c91cbf20 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Tue, 16 Dec 2025 22:15:03 +1100 Subject: [PATCH 13/16] Use preview lang version in tests --- .../RazorProjectBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Cohosting/RazorProjectBuilder.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Cohosting/RazorProjectBuilder.cs index 4d33924234c..54de1c57d39 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Cohosting/RazorProjectBuilder.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Cohosting/RazorProjectBuilder.cs @@ -41,7 +41,7 @@ public string? ProjectFilePath public bool GenerateMSBuildProjectDirectory { get; set; } = true; public bool GenerateAdditionalDocumentMetadata { get; set; } = true; - public RazorLanguageVersion RazorLanguageVersion { get; set; } = FallbackRazorConfiguration.Latest.LanguageVersion; + public RazorLanguageVersion RazorLanguageVersion { get; set; } = RazorLanguageVersion.Preview; private readonly List _references = []; private readonly List<(DocumentId id, string name, SourceText text, string filePath)> _documents = []; From d1dacf96dcb3f7a8a3145ec9b9264b9aaa183bd1 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Tue, 16 Dec 2025 22:15:19 +1100 Subject: [PATCH 14/16] Gate the feature behind the right version --- .../src/Language/Components/ComponentRenderModeDirectivePass.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentRenderModeDirectivePass.cs b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentRenderModeDirectivePass.cs index 19005f499f9..68c9ad7fe84 100644 --- a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentRenderModeDirectivePass.cs +++ b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentRenderModeDirectivePass.cs @@ -70,7 +70,7 @@ child is not DirectiveTokenIntermediateNode directiveToken : IntermediateNodeFactory.CSharpToken( content: directiveToken.Content, // To avoid breaking hot reload, we don't map the content back to the source unless we're on Razor 10 or higher - source: codeDocument.ParserOptions.LanguageVersion >= RazorLanguageVersion.Version_10_0 + source: codeDocument.ParserOptions.LanguageVersion >= RazorLanguageVersion.Version_11_0 ? directiveToken.Source : null) } From 0235d10e3b4323d0ae7540b10d75f419b1ae66a0 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Wed, 17 Dec 2025 07:06:30 +1100 Subject: [PATCH 15/16] Update ComponentRenderModeDirectivePass.cs Co-authored-by: Chris Sienkiewicz --- .../src/Language/Components/ComponentRenderModeDirectivePass.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentRenderModeDirectivePass.cs b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentRenderModeDirectivePass.cs index 68c9ad7fe84..10b3c9ee316 100644 --- a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentRenderModeDirectivePass.cs +++ b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentRenderModeDirectivePass.cs @@ -69,7 +69,7 @@ child is not DirectiveTokenIntermediateNode directiveToken ? child : IntermediateNodeFactory.CSharpToken( content: directiveToken.Content, - // To avoid breaking hot reload, we don't map the content back to the source unless we're on Razor 10 or higher + // To avoid breaking hot reload, we don't map the content back to the source unless we're on Razor 11 or higher source: codeDocument.ParserOptions.LanguageVersion >= RazorLanguageVersion.Version_11_0 ? directiveToken.Source : null) From 5051b47edda6856da216b620942175288ca60b60 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Wed, 17 Dec 2025 08:25:20 +1100 Subject: [PATCH 16/16] Cargo cults keep me warm at night --- .../Endpoints/Shared/CohostSemanticTokensRangeEndpointTest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/Endpoints/Shared/CohostSemanticTokensRangeEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/Endpoints/Shared/CohostSemanticTokensRangeEndpointTest.cs index 978d29d830d..bfec9c8c0ea 100644 --- a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/Endpoints/Shared/CohostSemanticTokensRangeEndpointTest.cs +++ b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/Endpoints/Shared/CohostSemanticTokensRangeEndpointTest.cs @@ -196,8 +196,8 @@ private async Task VerifySemanticTokensAsync( bool colorBackground, bool miscellaneousFile, RazorFileKind? fileKind = null, - [CallerMemberName] string? testName = null, - Action? projectConfigure = null) + Action? projectConfigure = null, + [CallerMemberName] string? testName = null) { var document = CreateProjectAndRazorDocument(input, fileKind, miscellaneousFile: miscellaneousFile, projectConfigure: projectConfigure); var sourceText = await document.GetTextAsync(DisposalToken);