diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/Legacy/CSharpPreprocessorTest.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/Legacy/CSharpPreprocessorTest.cs new file mode 100644 index 00000000000..c53d337596a --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/Legacy/CSharpPreprocessorTest.cs @@ -0,0 +1,353 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Immutable; +using Microsoft.CodeAnalysis.CSharp; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy; + +public class CSharpPreprocessorTest() : ParserTestBase(layer: TestProject.Layer.Compiler, validateSpanEditHandlers: true, useLegacyTokenizer: true) +{ + [Fact] + public void Pragmas() + { + ParseDocumentTest(""" + @{ + #pragma warning disable 123 + #pragma warning restore 123 + #pragma checksum "file.cs" "{00000000-0000-0000-0000-000000000000}" "1234" + } + """); + } + + [Fact] + public void NullableDirectives() + { + ParseDocumentTest(""" + @{ + #nullable enable + #nullable disable + #nullable restore + #nullable enable annotations + #nullable disable annotations + #nullable restore annotations + #nullable enable warnings + #nullable disable warnings + #nullable restore warnings + } + """); + } + + [Fact] + public void DefineThenIfDef() + { + ParseDocumentTest(""" + @{ + #define SYMBOL + #if SYMBOL + #undef SYMBOL + #if SYMBOL + var x = 1; + #endif + #else + var x = 1; + #endif + } + """); + } + + [Fact] + public void ErrorWarningLine() + { + ParseDocumentTest(""" + @{ + #line 1 "file.cs" + #error This is an error + #line default + #warning This is a warning + #line hidden + #line (1, 1) - (5, 60) 10 "partial-class.cs" + } + """); + } + + [Fact] + public void Regions() + { + ParseDocumentTest(""" + @{ + #region MyRegion } + #endregion + } + """); + } + + [Fact] + public void SimpleIfDef() + { + ParseDocumentTest(""" + @{ + #if true + var x = 1; + #endif + } + """); + } + + [Fact] + public void IfDefFromParseOptions_Symbol() + { + IfDefFromParseOptions("SYMBOL"); + } + + [Fact] + public void IfDefFromParseOptions_Symbol2() + { + IfDefFromParseOptions("SYMBOL2"); + } + + [Fact] + public void IfDefFromParseOptions_None() + { + IfDefFromParseOptions(null); + } + + private void IfDefFromParseOptions(string? directive) + { + var parseOptions = CSharpParseOptions.Default; + + if (directive != null) + { + parseOptions = parseOptions.WithPreprocessorSymbols(ImmutableArray.Create(directive)); + } + + ParseDocumentTest(""" + @{ + #if SYMBOL + var x = 1; + #elif SYMBOL2 + var x = 2; + #else + var x = 3; + #endif + } + """, parseOptions); + } + + [Fact] + public void IfDefAcrossMultipleBlocks() + { + ParseDocumentTest(""" + @{ + #if false + var x = 1; + } + +
+

Content

+
+ + @{ + var y = 2; + #endif + } + """); + } + + [Fact] + public void IfDefDisabledSectionUnbalanced() + { + ParseDocumentTest(""" + @{ + #if false + void M() { + #endif + } + """); + } + + [Fact] + public void IfDefNotOnNewline_01() + { + ParseDocumentTest(""" + @{ #if false } +
+

Content

+
+ @{ + #endif + } + """); + } + + [Fact] + public void IfDefNotOnNewline_02() + { + ParseDocumentTest(""" + @{#if false } +
+

Content

+
+ @{ + #endif + } + """); + } + + [Fact] + public void ElIfNotOnNewline() + { + ParseDocumentTest(""" + @{ + #if true + } +
+

Content

+
+ @{ #elif false } +
+

Content2

+
+ @{ + #endif + } + """); + } + + [Fact] + public void ElseNotOnNewline() + { + ParseDocumentTest(""" + @{ + #if true + } +
+

Content

+
+ @{ #else } +
+

Content2

+
+ @{ + #endif + } + """); + } + + [Fact] + public void EndIfNotOnNewline() + { + ParseDocumentTest(""" + @{ + #if false + } +
+

Content

+
+ @{ #endif } + """); + } + + [Fact] + public void UsingStatementResults() + { + ParseDocumentTest(""" + @using (var test = blah) + #if true + { + #endif + } + """); + } + + [Fact] + public void IfStatementAfterIf() + { + ParseDocumentTest(""" + @if (true) + #if true + { + #endif + } + """); + } + + [Fact] + public void IfStatementAfterIfBlock() + { + ParseDocumentTest(""" + @if (true) + { + #if true + } + #endif + """); + } + + [Fact] + public void IfStatementAfterIfBeforeElseIf() + { + ParseDocumentTest(""" + @if (true) + { + } + #if true + else if (false) + #endif + { + } + """); + } + + [Fact] + public void IfStatementAfterElseIf() + { + ParseDocumentTest(""" + @if (true) + { + } + else if (false) + #if true + { + #endif + } + """); + } + + [Fact] + public void IfStatementAfterElseIfBeforeElse() + { + ParseDocumentTest(""" + @if (true) + { + } + else if (false) + { + } + #if true + else + #endif + { + } + """); + } + + [Fact] + public void IfStatementAfterElse() + { + ParseDocumentTest(""" + @if (true) + { + } + else if (false) + { + } + else + #if true + { + #endif + } + """); + } +} diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/DefineThenIfDef.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/DefineThenIfDef.cspans.txt new file mode 100644 index 00000000000..8cd45527e93 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/DefineThenIfDef.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [115] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [115] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [115] ) +Code span at (2:0,2 [112] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [115] ) +MetaCode span at (114:10,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [115] ) +Markup span at (115:10,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [115] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/DefineThenIfDef.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/DefineThenIfDef.stree.txt new file mode 100644 index 00000000000..cda11a4ed23 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/DefineThenIfDef.stree.txt @@ -0,0 +1,68 @@ +RazorDocument - [0..115)::115 - [@{LF#define SYMBOLLF#if SYMBOLLF#undef SYMBOLLF#if SYMBOLLF var x = 1;LF#endifLF#elseLF var x = 1;LF#endifLF}] + MarkupBlock - [0..115)::115 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..115)::115 + CSharpStatement - [0..115)::115 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..115)::114 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..114)::112 + CSharpStatementLiteral - [2..114)::112 - [LF#define SYMBOLLF#if SYMBOLLF#undef SYMBOLLF#if SYMBOLLF var x = 1;LF#endifLF#elseLF var x = 1;LF#endifLF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + Hash;[#]; + Identifier;[define]; + Whitespace;[ ]; + Identifier;[SYMBOL]; + NewLine;[LF]; + Hash;[#]; + Keyword;[if]; + Whitespace;[ ]; + Identifier;[SYMBOL]; + NewLine;[LF]; + Hash;[#]; + Identifier;[undef]; + Whitespace;[ ]; + Identifier;[SYMBOL]; + NewLine;[LF]; + Hash;[#]; + Keyword;[if]; + Whitespace;[ ]; + Identifier;[SYMBOL]; + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[1]; + Semicolon;[;]; + NewLine;[LF]; + Hash;[#]; + Identifier;[endif]; + NewLine;[LF]; + Hash;[#]; + Keyword;[else]; + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[1]; + Semicolon;[;]; + NewLine;[LF]; + Hash;[#]; + Identifier;[endif]; + NewLine;[LF]; + RazorMetaCode - [114..115)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [115..115)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/ElIfNotOnNewline.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/ElIfNotOnNewline.cspans.txt new file mode 100644 index 00000000000..1d8c7147aa1 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/ElIfNotOnNewline.cspans.txt @@ -0,0 +1,32 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [119] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [15] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [15] ) +Code span at (2:0,2 [12] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [15] ) +MetaCode span at (14:2,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [15] ) +Markup span at (15:2,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [119] ) +Markup span at (17:3,0 [5] ) (Accepts:Any) - Parent: Tag block at (17:3,0 [5] ) +Markup span at (22:3,5 [6] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [119] ) +Markup span at (28:4,4 [3] ) (Accepts:Any) - Parent: Tag block at (28:4,4 [3] ) +Markup span at (31:4,7 [7] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [119] ) +Markup span at (38:4,14 [4] ) (Accepts:Any) - Parent: Tag block at (38:4,14 [4] ) +Markup span at (42:4,18 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [119] ) +Markup span at (44:5,0 [6] ) (Accepts:Any) - Parent: Tag block at (44:5,0 [6] ) +Markup span at (50:5,6 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [119] ) +Transition span at (52:6,0 [1] ) (Accepts:None) - Parent: Statement block at (52:6,0 [16] ) +MetaCode span at (53:6,1 [1] ) (Accepts:None) - Parent: Statement block at (52:6,0 [16] ) +Code span at (54:6,2 [13] ) (Accepts:Any) - Parent: Statement block at (52:6,0 [16] ) +MetaCode span at (67:6,15 [1] ) (Accepts:None) - Parent: Statement block at (52:6,0 [16] ) +Markup span at (68:6,16 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [119] ) +Markup span at (70:7,0 [5] ) (Accepts:Any) - Parent: Tag block at (70:7,0 [5] ) +Markup span at (75:7,5 [6] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [119] ) +Markup span at (81:8,4 [3] ) (Accepts:Any) - Parent: Tag block at (81:8,4 [3] ) +Markup span at (84:8,7 [8] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [119] ) +Markup span at (92:8,15 [4] ) (Accepts:Any) - Parent: Tag block at (92:8,15 [4] ) +Markup span at (96:8,19 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [119] ) +Markup span at (98:9,0 [6] ) (Accepts:Any) - Parent: Tag block at (98:9,0 [6] ) +Markup span at (104:9,6 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [119] ) +Transition span at (106:10,0 [1] ) (Accepts:None) - Parent: Statement block at (106:10,0 [13] ) +MetaCode span at (107:10,1 [1] ) (Accepts:None) - Parent: Statement block at (106:10,0 [13] ) +Code span at (108:10,2 [10] ) (Accepts:Any) - Parent: Statement block at (106:10,0 [13] ) +MetaCode span at (118:12,0 [1] ) (Accepts:None) - Parent: Statement block at (106:10,0 [13] ) +Markup span at (119:12,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [119] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/ElIfNotOnNewline.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/ElIfNotOnNewline.stree.txt new file mode 100644 index 00000000000..34306d8a670 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/ElIfNotOnNewline.stree.txt @@ -0,0 +1,118 @@ +RazorDocument - [0..119)::119 - [@{LF#if trueLF}LF
LF

Content

LF
LF@{ #elif false }LF
LF

Content2

LF
LF@{LF#endifLF}] + MarkupBlock - [0..119)::119 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..15)::15 + CSharpStatement - [0..15)::15 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..15)::14 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..14)::12 + CSharpStatementLiteral - [2..14)::12 - [LF#if trueLF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + Hash;[#]; + Keyword;[if]; + Whitespace;[ ]; + Keyword;[true]; + NewLine;[LF]; + RazorMetaCode - [14..15)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [15..17)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [17..50)::33 + MarkupStartTag - [17..22)::5 - [
] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [22..28)::6 - [LF ] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Whitespace;[ ]; + MarkupElement - [28..42)::14 + MarkupStartTag - [28..31)::3 - [

] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [31..38)::7 - [Content] - Gen - SpanEditHandler;Accepts:Any + Text;[Content]; + MarkupEndTag - [38..42)::4 - [

] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [42..44)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupEndTag - [44..50)::6 - [
] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [50..52)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [52..68)::16 + CSharpStatement - [52..68)::16 + CSharpTransition - [52..53)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [53..68)::15 + RazorMetaCode - [53..54)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [54..67)::13 + CSharpStatementLiteral - [54..67)::13 - [ #elif false ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Whitespace;[ ]; + Hash;[#]; + Identifier;[elif]; + Whitespace;[ ]; + Keyword;[false]; + Whitespace;[ ]; + RazorMetaCode - [67..68)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [68..70)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [70..104)::34 + MarkupStartTag - [70..75)::5 - [
] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [75..81)::6 - [LF ] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Whitespace;[ ]; + MarkupElement - [81..96)::15 + MarkupStartTag - [81..84)::3 - [

] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [84..92)::8 - [Content2] - Gen - SpanEditHandler;Accepts:Any + Text;[Content2]; + MarkupEndTag - [92..96)::4 - [

] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [96..98)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupEndTag - [98..104)::6 - [
] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [104..106)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [106..119)::13 + CSharpStatement - [106..119)::13 + CSharpTransition - [106..107)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [107..119)::12 + RazorMetaCode - [107..108)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [108..118)::10 + CSharpStatementLiteral - [108..118)::10 - [LF#endifLF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + Hash;[#]; + Identifier;[endif]; + NewLine;[LF]; + RazorMetaCode - [118..119)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [119..119)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/ElseNotOnNewline.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/ElseNotOnNewline.cspans.txt new file mode 100644 index 00000000000..75e276be978 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/ElseNotOnNewline.cspans.txt @@ -0,0 +1,32 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [113] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [15] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [15] ) +Code span at (2:0,2 [12] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [15] ) +MetaCode span at (14:2,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [15] ) +Markup span at (15:2,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [113] ) +Markup span at (17:3,0 [5] ) (Accepts:Any) - Parent: Tag block at (17:3,0 [5] ) +Markup span at (22:3,5 [6] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [113] ) +Markup span at (28:4,4 [3] ) (Accepts:Any) - Parent: Tag block at (28:4,4 [3] ) +Markup span at (31:4,7 [7] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [113] ) +Markup span at (38:4,14 [4] ) (Accepts:Any) - Parent: Tag block at (38:4,14 [4] ) +Markup span at (42:4,18 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [113] ) +Markup span at (44:5,0 [6] ) (Accepts:Any) - Parent: Tag block at (44:5,0 [6] ) +Markup span at (50:5,6 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [113] ) +Transition span at (52:6,0 [1] ) (Accepts:None) - Parent: Statement block at (52:6,0 [10] ) +MetaCode span at (53:6,1 [1] ) (Accepts:None) - Parent: Statement block at (52:6,0 [10] ) +Code span at (54:6,2 [7] ) (Accepts:Any) - Parent: Statement block at (52:6,0 [10] ) +MetaCode span at (61:6,9 [1] ) (Accepts:None) - Parent: Statement block at (52:6,0 [10] ) +Markup span at (62:6,10 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [113] ) +Markup span at (64:7,0 [5] ) (Accepts:Any) - Parent: Tag block at (64:7,0 [5] ) +Markup span at (69:7,5 [6] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [113] ) +Markup span at (75:8,4 [3] ) (Accepts:Any) - Parent: Tag block at (75:8,4 [3] ) +Markup span at (78:8,7 [8] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [113] ) +Markup span at (86:8,15 [4] ) (Accepts:Any) - Parent: Tag block at (86:8,15 [4] ) +Markup span at (90:8,19 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [113] ) +Markup span at (92:9,0 [6] ) (Accepts:Any) - Parent: Tag block at (92:9,0 [6] ) +Markup span at (98:9,6 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [113] ) +Transition span at (100:10,0 [1] ) (Accepts:None) - Parent: Statement block at (100:10,0 [13] ) +MetaCode span at (101:10,1 [1] ) (Accepts:None) - Parent: Statement block at (100:10,0 [13] ) +Code span at (102:10,2 [10] ) (Accepts:Any) - Parent: Statement block at (100:10,0 [13] ) +MetaCode span at (112:12,0 [1] ) (Accepts:None) - Parent: Statement block at (100:10,0 [13] ) +Markup span at (113:12,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [113] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/ElseNotOnNewline.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/ElseNotOnNewline.stree.txt new file mode 100644 index 00000000000..932f1f3050a --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/ElseNotOnNewline.stree.txt @@ -0,0 +1,116 @@ +RazorDocument - [0..113)::113 - [@{LF#if trueLF}LF
LF

Content

LF
LF@{ #else }LF
LF

Content2

LF
LF@{LF#endifLF}] + MarkupBlock - [0..113)::113 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..15)::15 + CSharpStatement - [0..15)::15 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..15)::14 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..14)::12 + CSharpStatementLiteral - [2..14)::12 - [LF#if trueLF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + Hash;[#]; + Keyword;[if]; + Whitespace;[ ]; + Keyword;[true]; + NewLine;[LF]; + RazorMetaCode - [14..15)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [15..17)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [17..50)::33 + MarkupStartTag - [17..22)::5 - [
] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [22..28)::6 - [LF ] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Whitespace;[ ]; + MarkupElement - [28..42)::14 + MarkupStartTag - [28..31)::3 - [

] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [31..38)::7 - [Content] - Gen - SpanEditHandler;Accepts:Any + Text;[Content]; + MarkupEndTag - [38..42)::4 - [

] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [42..44)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupEndTag - [44..50)::6 - [
] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [50..52)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [52..62)::10 + CSharpStatement - [52..62)::10 + CSharpTransition - [52..53)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [53..62)::9 + RazorMetaCode - [53..54)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [54..61)::7 + CSharpStatementLiteral - [54..61)::7 - [ #else ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Whitespace;[ ]; + Hash;[#]; + Keyword;[else]; + Whitespace;[ ]; + RazorMetaCode - [61..62)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [62..64)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [64..98)::34 + MarkupStartTag - [64..69)::5 - [
] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [69..75)::6 - [LF ] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Whitespace;[ ]; + MarkupElement - [75..90)::15 + MarkupStartTag - [75..78)::3 - [

] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [78..86)::8 - [Content2] - Gen - SpanEditHandler;Accepts:Any + Text;[Content2]; + MarkupEndTag - [86..90)::4 - [

] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [90..92)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupEndTag - [92..98)::6 - [
] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [98..100)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [100..113)::13 + CSharpStatement - [100..113)::13 + CSharpTransition - [100..101)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [101..113)::12 + RazorMetaCode - [101..102)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [102..112)::10 + CSharpStatementLiteral - [102..112)::10 - [LF#endifLF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + Hash;[#]; + Identifier;[endif]; + NewLine;[LF]; + RazorMetaCode - [112..113)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [113..113)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/EndIfNotOnNewline.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/EndIfNotOnNewline.cspans.txt new file mode 100644 index 00000000000..c6b068dcd90 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/EndIfNotOnNewline.cspans.txt @@ -0,0 +1,19 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [64] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [16] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [16] ) +Code span at (2:0,2 [13] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [16] ) +MetaCode span at (15:2,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [16] ) +Markup span at (16:2,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [64] ) +Markup span at (18:3,0 [5] ) (Accepts:Any) - Parent: Tag block at (18:3,0 [5] ) +Markup span at (23:3,5 [6] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [64] ) +Markup span at (29:4,4 [3] ) (Accepts:Any) - Parent: Tag block at (29:4,4 [3] ) +Markup span at (32:4,7 [7] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [64] ) +Markup span at (39:4,14 [4] ) (Accepts:Any) - Parent: Tag block at (39:4,14 [4] ) +Markup span at (43:4,18 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [64] ) +Markup span at (45:5,0 [6] ) (Accepts:Any) - Parent: Tag block at (45:5,0 [6] ) +Markup span at (51:5,6 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [64] ) +Transition span at (53:6,0 [1] ) (Accepts:None) - Parent: Statement block at (53:6,0 [11] ) +MetaCode span at (54:6,1 [1] ) (Accepts:None) - Parent: Statement block at (53:6,0 [11] ) +Code span at (55:6,2 [8] ) (Accepts:Any) - Parent: Statement block at (53:6,0 [11] ) +MetaCode span at (63:6,10 [1] ) (Accepts:None) - Parent: Statement block at (53:6,0 [11] ) +Markup span at (64:6,11 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [64] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/EndIfNotOnNewline.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/EndIfNotOnNewline.stree.txt new file mode 100644 index 00000000000..afebdaac89e --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/EndIfNotOnNewline.stree.txt @@ -0,0 +1,70 @@ +RazorDocument - [0..64)::64 - [@{LF#if falseLF}LF
LF

Content

LF
LF@{ #endif }] + MarkupBlock - [0..64)::64 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..16)::16 + CSharpStatement - [0..16)::16 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..16)::15 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..15)::13 + CSharpStatementLiteral - [2..15)::13 - [LF#if falseLF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + Hash;[#]; + Keyword;[if]; + Whitespace;[ ]; + Keyword;[false]; + NewLine;[LF]; + RazorMetaCode - [15..16)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [16..18)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [18..51)::33 + MarkupStartTag - [18..23)::5 - [
] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [23..29)::6 - [LF ] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Whitespace;[ ]; + MarkupElement - [29..43)::14 + MarkupStartTag - [29..32)::3 - [

] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [32..39)::7 - [Content] - Gen - SpanEditHandler;Accepts:Any + Text;[Content]; + MarkupEndTag - [39..43)::4 - [

] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [43..45)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupEndTag - [45..51)::6 - [
] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [51..53)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [53..64)::11 + CSharpStatement - [53..64)::11 + CSharpTransition - [53..54)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [54..64)::10 + RazorMetaCode - [54..55)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [55..63)::8 + CSharpStatementLiteral - [55..63)::8 - [ #endif ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Whitespace;[ ]; + Hash;[#]; + Identifier;[endif]; + Whitespace;[ ]; + RazorMetaCode - [63..64)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [64..64)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/ErrorWarningLine.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/ErrorWarningLine.cspans.txt new file mode 100644 index 00000000000..e4dbe6504c6 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/ErrorWarningLine.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [152] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [152] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [152] ) +Code span at (2:0,2 [149] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [152] ) +MetaCode span at (151:7,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [152] ) +Markup span at (152:7,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [152] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/ErrorWarningLine.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/ErrorWarningLine.stree.txt new file mode 100644 index 00000000000..e73c63e55e0 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/ErrorWarningLine.stree.txt @@ -0,0 +1,81 @@ +RazorDocument - [0..152)::152 - [@{LF#line 1 "file.cs"LF#error This is an errorLF#line defaultLF#warning This is a warningLF#line hiddenLF#line (1, 1) - (5, 60) 10 "partial-class.cs"LF}] + MarkupBlock - [0..152)::152 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..152)::152 + CSharpStatement - [0..152)::152 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..152)::151 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..151)::149 + CSharpStatementLiteral - [2..151)::149 - [LF#line 1 "file.cs"LF#error This is an errorLF#line defaultLF#warning This is a warningLF#line hiddenLF#line (1, 1) - (5, 60) 10 "partial-class.cs"LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + Hash;[#]; + Identifier;[line]; + Whitespace;[ ]; + IntegerLiteral;[1]; + Whitespace;[ ]; + StringLiteral;["file.cs"]; + NewLine;[LF]; + Hash;[#]; + Identifier;[error]; + Whitespace;[ ]; + Identifier;[This]; + Whitespace;[ ]; + Keyword;[is]; + Whitespace;[ ]; + Identifier;[an]; + Whitespace;[ ]; + Identifier;[error]; + NewLine;[LF]; + Hash;[#]; + Identifier;[line]; + Whitespace;[ ]; + Keyword;[default]; + NewLine;[LF]; + Hash;[#]; + Identifier;[warning]; + Whitespace;[ ]; + Identifier;[This]; + Whitespace;[ ]; + Keyword;[is]; + Whitespace;[ ]; + Identifier;[a]; + Whitespace;[ ]; + Identifier;[warning]; + NewLine;[LF]; + Hash;[#]; + Identifier;[line]; + Whitespace;[ ]; + Identifier;[hidden]; + NewLine;[LF]; + Hash;[#]; + Identifier;[line]; + Whitespace;[ ]; + LeftParenthesis;[(]; + IntegerLiteral;[1]; + Comma;[,]; + Whitespace;[ ]; + IntegerLiteral;[1]; + RightParenthesis;[)]; + Whitespace;[ ]; + Minus;[-]; + Whitespace;[ ]; + LeftParenthesis;[(]; + IntegerLiteral;[5]; + Comma;[,]; + Whitespace;[ ]; + IntegerLiteral;[60]; + RightParenthesis;[)]; + Whitespace;[ ]; + IntegerLiteral;[10]; + Whitespace;[ ]; + StringLiteral;["partial-class.cs"]; + NewLine;[LF]; + RazorMetaCode - [151..152)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [152..152)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefAcrossMultipleBlocks.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefAcrossMultipleBlocks.cspans.txt new file mode 100644 index 00000000000..86f66234678 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefAcrossMultipleBlocks.cspans.txt @@ -0,0 +1,20 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [102] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +Code span at (2:0,2 [29] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [32] ) +MetaCode span at (31:3,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +Markup span at (32:3,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [102] ) +Markup span at (34:4,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [102] ) +Markup span at (36:5,0 [5] ) (Accepts:Any) - Parent: Tag block at (36:5,0 [5] ) +Markup span at (41:5,5 [6] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [102] ) +Markup span at (47:6,4 [3] ) (Accepts:Any) - Parent: Tag block at (47:6,4 [3] ) +Markup span at (50:6,7 [7] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [102] ) +Markup span at (57:6,14 [4] ) (Accepts:Any) - Parent: Tag block at (57:6,14 [4] ) +Markup span at (61:6,18 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [102] ) +Markup span at (63:7,0 [6] ) (Accepts:Any) - Parent: Tag block at (63:7,0 [6] ) +Markup span at (69:7,6 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [102] ) +Transition span at (73:9,0 [1] ) (Accepts:None) - Parent: Statement block at (73:9,0 [29] ) +MetaCode span at (74:9,1 [1] ) (Accepts:None) - Parent: Statement block at (73:9,0 [29] ) +Code span at (75:9,2 [26] ) (Accepts:Any) - Parent: Statement block at (73:9,0 [29] ) +MetaCode span at (101:12,0 [1] ) (Accepts:None) - Parent: Statement block at (73:9,0 [29] ) +Markup span at (102:12,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [102] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefAcrossMultipleBlocks.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefAcrossMultipleBlocks.stree.txt new file mode 100644 index 00000000000..e0c1ec3a2b9 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefAcrossMultipleBlocks.stree.txt @@ -0,0 +1,93 @@ +RazorDocument - [0..102)::102 - [@{LF#if falseLF var x = 1;LF}LFLF
LF

Content

LF
LFLF@{LF var y = 2;LF#endifLF}] + MarkupBlock - [0..102)::102 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..32)::32 + CSharpStatement - [0..32)::32 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..32)::31 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..31)::29 + CSharpStatementLiteral - [2..31)::29 - [LF#if falseLF var x = 1;LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + Hash;[#]; + Keyword;[if]; + Whitespace;[ ]; + Keyword;[false]; + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[1]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [31..32)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [32..34)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupTextLiteral - [34..36)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [36..69)::33 + MarkupStartTag - [36..41)::5 - [
] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [41..47)::6 - [LF ] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Whitespace;[ ]; + MarkupElement - [47..61)::14 + MarkupStartTag - [47..50)::3 - [

] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [50..57)::7 - [Content] - Gen - SpanEditHandler;Accepts:Any + Text;[Content]; + MarkupEndTag - [57..61)::4 - [

] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [61..63)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupEndTag - [63..69)::6 - [
] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [69..73)::4 - [LFLF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + NewLine;[LF]; + CSharpCodeBlock - [73..102)::29 + CSharpStatement - [73..102)::29 + CSharpTransition - [73..74)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [74..102)::28 + RazorMetaCode - [74..75)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [75..101)::26 + CSharpStatementLiteral - [75..101)::26 - [LF var y = 2;LF#endifLF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[y]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[2]; + Semicolon;[;]; + NewLine;[LF]; + Hash;[#]; + Identifier;[endif]; + NewLine;[LF]; + RazorMetaCode - [101..102)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [102..102)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefDisabledSectionUnbalanced.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefDisabledSectionUnbalanced.cspans.txt new file mode 100644 index 00000000000..3f334c4b693 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefDisabledSectionUnbalanced.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [40] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [40] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [40] ) +Code span at (2:0,2 [38] ) (Accepts:None) - Parent: Statement block at (0:0,0 [40] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefDisabledSectionUnbalanced.diag.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefDisabledSectionUnbalanced.diag.txt new file mode 100644 index 00000000000..bcd37730bb1 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefDisabledSectionUnbalanced.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefDisabledSectionUnbalanced.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefDisabledSectionUnbalanced.stree.txt new file mode 100644 index 00000000000..9047b79690f --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefDisabledSectionUnbalanced.stree.txt @@ -0,0 +1,35 @@ +RazorDocument - [0..40)::40 - [@{LF#if falseLF void M() {LF#endifLF}] + MarkupBlock - [0..40)::40 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..40)::40 + CSharpStatement - [0..40)::40 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..40)::39 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..40)::38 + CSharpStatementLiteral - [2..40)::38 - [LF#if falseLF void M() {LF#endifLF}] - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[}];AtEOL + NewLine;[LF]; + Hash;[#]; + Keyword;[if]; + Whitespace;[ ]; + Keyword;[false]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[void]; + Whitespace;[ ]; + Identifier;[M]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Hash;[#]; + Identifier;[endif]; + NewLine;[LF]; + RightBrace;[}]; + RazorMetaCode - [40..40)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_None.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_None.cspans.txt new file mode 100644 index 00000000000..bab49e5c914 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_None.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [95] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [95] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [95] ) +Code span at (2:0,2 [92] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [95] ) +MetaCode span at (94:8,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [95] ) +Markup span at (95:8,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [95] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_None.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_None.stree.txt new file mode 100644 index 00000000000..b8ddf401e69 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_None.stree.txt @@ -0,0 +1,65 @@ +RazorDocument - [0..95)::95 - [@{LF#if SYMBOLLF var x = 1;LF#elif SYMBOL2LF var x = 2;LF#elseLF var x = 3;LF#endifLF}] + MarkupBlock - [0..95)::95 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..95)::95 + CSharpStatement - [0..95)::95 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..95)::94 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..94)::92 + CSharpStatementLiteral - [2..94)::92 - [LF#if SYMBOLLF var x = 1;LF#elif SYMBOL2LF var x = 2;LF#elseLF var x = 3;LF#endifLF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + Hash;[#]; + Keyword;[if]; + Whitespace;[ ]; + Identifier;[SYMBOL]; + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[1]; + Semicolon;[;]; + NewLine;[LF]; + Hash;[#]; + Identifier;[elif]; + Whitespace;[ ]; + Identifier;[SYMBOL2]; + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[2]; + Semicolon;[;]; + NewLine;[LF]; + Hash;[#]; + Keyword;[else]; + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[3]; + Semicolon;[;]; + NewLine;[LF]; + Hash;[#]; + Identifier;[endif]; + NewLine;[LF]; + RazorMetaCode - [94..95)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [95..95)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_Symbol.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_Symbol.cspans.txt new file mode 100644 index 00000000000..bab49e5c914 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_Symbol.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [95] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [95] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [95] ) +Code span at (2:0,2 [92] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [95] ) +MetaCode span at (94:8,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [95] ) +Markup span at (95:8,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [95] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_Symbol.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_Symbol.stree.txt new file mode 100644 index 00000000000..b8ddf401e69 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_Symbol.stree.txt @@ -0,0 +1,65 @@ +RazorDocument - [0..95)::95 - [@{LF#if SYMBOLLF var x = 1;LF#elif SYMBOL2LF var x = 2;LF#elseLF var x = 3;LF#endifLF}] + MarkupBlock - [0..95)::95 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..95)::95 + CSharpStatement - [0..95)::95 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..95)::94 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..94)::92 + CSharpStatementLiteral - [2..94)::92 - [LF#if SYMBOLLF var x = 1;LF#elif SYMBOL2LF var x = 2;LF#elseLF var x = 3;LF#endifLF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + Hash;[#]; + Keyword;[if]; + Whitespace;[ ]; + Identifier;[SYMBOL]; + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[1]; + Semicolon;[;]; + NewLine;[LF]; + Hash;[#]; + Identifier;[elif]; + Whitespace;[ ]; + Identifier;[SYMBOL2]; + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[2]; + Semicolon;[;]; + NewLine;[LF]; + Hash;[#]; + Keyword;[else]; + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[3]; + Semicolon;[;]; + NewLine;[LF]; + Hash;[#]; + Identifier;[endif]; + NewLine;[LF]; + RazorMetaCode - [94..95)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [95..95)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_Symbol2.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_Symbol2.cspans.txt new file mode 100644 index 00000000000..bab49e5c914 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_Symbol2.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [95] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [95] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [95] ) +Code span at (2:0,2 [92] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [95] ) +MetaCode span at (94:8,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [95] ) +Markup span at (95:8,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [95] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_Symbol2.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_Symbol2.stree.txt new file mode 100644 index 00000000000..b8ddf401e69 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_Symbol2.stree.txt @@ -0,0 +1,65 @@ +RazorDocument - [0..95)::95 - [@{LF#if SYMBOLLF var x = 1;LF#elif SYMBOL2LF var x = 2;LF#elseLF var x = 3;LF#endifLF}] + MarkupBlock - [0..95)::95 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..95)::95 + CSharpStatement - [0..95)::95 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..95)::94 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..94)::92 + CSharpStatementLiteral - [2..94)::92 - [LF#if SYMBOLLF var x = 1;LF#elif SYMBOL2LF var x = 2;LF#elseLF var x = 3;LF#endifLF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + Hash;[#]; + Keyword;[if]; + Whitespace;[ ]; + Identifier;[SYMBOL]; + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[1]; + Semicolon;[;]; + NewLine;[LF]; + Hash;[#]; + Identifier;[elif]; + Whitespace;[ ]; + Identifier;[SYMBOL2]; + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[2]; + Semicolon;[;]; + NewLine;[LF]; + Hash;[#]; + Keyword;[else]; + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[3]; + Semicolon;[;]; + NewLine;[LF]; + Hash;[#]; + Identifier;[endif]; + NewLine;[LF]; + RazorMetaCode - [94..95)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [95..95)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefNotOnNewline_01.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefNotOnNewline_01.cspans.txt new file mode 100644 index 00000000000..f6dbd66d6df --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefNotOnNewline_01.cspans.txt @@ -0,0 +1,19 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [64] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [14] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [14] ) +Code span at (2:0,2 [11] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [14] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [14] ) +Markup span at (14:0,14 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [64] ) +Markup span at (16:1,0 [5] ) (Accepts:Any) - Parent: Tag block at (16:1,0 [5] ) +Markup span at (21:1,5 [6] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [64] ) +Markup span at (27:2,4 [3] ) (Accepts:Any) - Parent: Tag block at (27:2,4 [3] ) +Markup span at (30:2,7 [7] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [64] ) +Markup span at (37:2,14 [4] ) (Accepts:Any) - Parent: Tag block at (37:2,14 [4] ) +Markup span at (41:2,18 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [64] ) +Markup span at (43:3,0 [6] ) (Accepts:Any) - Parent: Tag block at (43:3,0 [6] ) +Markup span at (49:3,6 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [64] ) +Transition span at (51:4,0 [1] ) (Accepts:None) - Parent: Statement block at (51:4,0 [13] ) +MetaCode span at (52:4,1 [1] ) (Accepts:None) - Parent: Statement block at (51:4,0 [13] ) +Code span at (53:4,2 [10] ) (Accepts:Any) - Parent: Statement block at (51:4,0 [13] ) +MetaCode span at (63:6,0 [1] ) (Accepts:None) - Parent: Statement block at (51:4,0 [13] ) +Markup span at (64:6,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [64] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefNotOnNewline_01.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefNotOnNewline_01.stree.txt new file mode 100644 index 00000000000..4fbdc459b1c --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefNotOnNewline_01.stree.txt @@ -0,0 +1,70 @@ +RazorDocument - [0..64)::64 - [@{ #if false }LF
LF

Content

LF
LF@{LF#endifLF}] + MarkupBlock - [0..64)::64 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..14)::14 + CSharpStatement - [0..14)::14 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..14)::13 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..13)::11 + CSharpStatementLiteral - [2..13)::11 - [ #if false ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Whitespace;[ ]; + Hash;[#]; + Keyword;[if]; + Whitespace;[ ]; + Keyword;[false]; + Whitespace;[ ]; + RazorMetaCode - [13..14)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [14..16)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [16..49)::33 + MarkupStartTag - [16..21)::5 - [
] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [21..27)::6 - [LF ] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Whitespace;[ ]; + MarkupElement - [27..41)::14 + MarkupStartTag - [27..30)::3 - [

] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [30..37)::7 - [Content] - Gen - SpanEditHandler;Accepts:Any + Text;[Content]; + MarkupEndTag - [37..41)::4 - [

] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [41..43)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupEndTag - [43..49)::6 - [
] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [49..51)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [51..64)::13 + CSharpStatement - [51..64)::13 + CSharpTransition - [51..52)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [52..64)::12 + RazorMetaCode - [52..53)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [53..63)::10 + CSharpStatementLiteral - [53..63)::10 - [LF#endifLF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + Hash;[#]; + Identifier;[endif]; + NewLine;[LF]; + RazorMetaCode - [63..64)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [64..64)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefNotOnNewline_02.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefNotOnNewline_02.cspans.txt new file mode 100644 index 00000000000..52bfc2ec6a3 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefNotOnNewline_02.cspans.txt @@ -0,0 +1,19 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [63] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [13] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [13] ) +Code span at (2:0,2 [10] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [13] ) +MetaCode span at (12:0,12 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [13] ) +Markup span at (13:0,13 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [63] ) +Markup span at (15:1,0 [5] ) (Accepts:Any) - Parent: Tag block at (15:1,0 [5] ) +Markup span at (20:1,5 [6] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [63] ) +Markup span at (26:2,4 [3] ) (Accepts:Any) - Parent: Tag block at (26:2,4 [3] ) +Markup span at (29:2,7 [7] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [63] ) +Markup span at (36:2,14 [4] ) (Accepts:Any) - Parent: Tag block at (36:2,14 [4] ) +Markup span at (40:2,18 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [63] ) +Markup span at (42:3,0 [6] ) (Accepts:Any) - Parent: Tag block at (42:3,0 [6] ) +Markup span at (48:3,6 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [63] ) +Transition span at (50:4,0 [1] ) (Accepts:None) - Parent: Statement block at (50:4,0 [13] ) +MetaCode span at (51:4,1 [1] ) (Accepts:None) - Parent: Statement block at (50:4,0 [13] ) +Code span at (52:4,2 [10] ) (Accepts:Any) - Parent: Statement block at (50:4,0 [13] ) +MetaCode span at (62:6,0 [1] ) (Accepts:None) - Parent: Statement block at (50:4,0 [13] ) +Markup span at (63:6,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [63] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefNotOnNewline_02.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefNotOnNewline_02.stree.txt new file mode 100644 index 00000000000..1b29732e43b --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefNotOnNewline_02.stree.txt @@ -0,0 +1,69 @@ +RazorDocument - [0..63)::63 - [@{#if false }LF
LF

Content

LF
LF@{LF#endifLF}] + MarkupBlock - [0..63)::63 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..13)::13 + CSharpStatement - [0..13)::13 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..13)::12 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..12)::10 + CSharpStatementLiteral - [2..12)::10 - [#if false ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Hash;[#]; + Keyword;[if]; + Whitespace;[ ]; + Keyword;[false]; + Whitespace;[ ]; + RazorMetaCode - [12..13)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [13..15)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [15..48)::33 + MarkupStartTag - [15..20)::5 - [
] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [20..26)::6 - [LF ] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Whitespace;[ ]; + MarkupElement - [26..40)::14 + MarkupStartTag - [26..29)::3 - [

] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [29..36)::7 - [Content] - Gen - SpanEditHandler;Accepts:Any + Text;[Content]; + MarkupEndTag - [36..40)::4 - [

] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [40..42)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupEndTag - [42..48)::6 - [
] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [48..50)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [50..63)::13 + CSharpStatement - [50..63)::13 + CSharpTransition - [50..51)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [51..63)::12 + RazorMetaCode - [51..52)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [52..62)::10 + CSharpStatementLiteral - [52..62)::10 - [LF#endifLF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + Hash;[#]; + Identifier;[endif]; + NewLine;[LF]; + RazorMetaCode - [62..63)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [63..63)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElse.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElse.cspans.txt new file mode 100644 index 00000000000..5c3780c6317 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElse.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [69] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [57] ) +Code span at (1:0,1 [56] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [57] ) +Markup span at (57:8,0 [12] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [69] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElse.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElse.stree.txt new file mode 100644 index 00000000000..6db464fbb2e --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElse.stree.txt @@ -0,0 +1,44 @@ +RazorDocument - [0..69)::69 - [@if (true)LF{LF}LFelse if (false)LF{LF}LFelseLF#if trueLF{LF#endifLF}] + MarkupBlock - [0..69)::69 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..57)::57 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..57)::56 - [if (true)LF{LF}LFelse if (false)LF{LF}LFelseLF#if trueLF] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + NewLine;[LF]; + LeftBrace;[{]; + NewLine;[LF]; + RightBrace;[}]; + NewLine;[LF]; + Keyword;[else]; + Whitespace;[ ]; + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[false]; + RightParenthesis;[)]; + NewLine;[LF]; + LeftBrace;[{]; + NewLine;[LF]; + RightBrace;[}]; + NewLine;[LF]; + Keyword;[else]; + NewLine;[LF]; + Hash;[#]; + Keyword;[if]; + Whitespace;[ ]; + Keyword;[true]; + NewLine;[LF]; + MarkupTextLiteral - [57..69)::12 - [{LF#endifLF}] - Gen - SpanEditHandler;Accepts:Any + Text;[{]; + NewLine;[LF]; + Text;[#endif]; + NewLine;[LF]; + Text;[}]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElseIf.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElseIf.cspans.txt new file mode 100644 index 00000000000..f98b24371df --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElseIf.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [57] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [45] ) +Code span at (1:0,1 [44] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [45] ) +Markup span at (45:5,0 [12] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [57] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElseIf.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElseIf.stree.txt new file mode 100644 index 00000000000..ebfa5880cdf --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElseIf.stree.txt @@ -0,0 +1,38 @@ +RazorDocument - [0..57)::57 - [@if (true)LF{LF}LFelse if (false)LF#if trueLF{LF#endifLF}] + MarkupBlock - [0..57)::57 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..45)::45 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..45)::44 - [if (true)LF{LF}LFelse if (false)LF#if trueLF] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + NewLine;[LF]; + LeftBrace;[{]; + NewLine;[LF]; + RightBrace;[}]; + NewLine;[LF]; + Keyword;[else]; + Whitespace;[ ]; + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[false]; + RightParenthesis;[)]; + NewLine;[LF]; + Hash;[#]; + Keyword;[if]; + Whitespace;[ ]; + Keyword;[true]; + NewLine;[LF]; + MarkupTextLiteral - [45..57)::12 - [{LF#endifLF}] - Gen - SpanEditHandler;Accepts:Any + Text;[{]; + NewLine;[LF]; + Text;[#endif]; + NewLine;[LF]; + Text;[}]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElseIfBeforeElse.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElseIfBeforeElse.cspans.txt new file mode 100644 index 00000000000..5b4a8d617b9 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElseIfBeforeElse.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [69] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [41] ) +Code span at (1:0,1 [40] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [41] ) +Markup span at (41:6,0 [28] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [69] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElseIfBeforeElse.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElseIfBeforeElse.stree.txt new file mode 100644 index 00000000000..71c8f5ca1e5 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElseIfBeforeElse.stree.txt @@ -0,0 +1,43 @@ +RazorDocument - [0..69)::69 - [@if (true)LF{LF}LFelse if (false)LF{LF}LF#if trueLFelseLF#endifLF{LF}] + MarkupBlock - [0..69)::69 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..41)::41 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..41)::40 - [if (true)LF{LF}LFelse if (false)LF{LF}LF] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + NewLine;[LF]; + LeftBrace;[{]; + NewLine;[LF]; + RightBrace;[}]; + NewLine;[LF]; + Keyword;[else]; + Whitespace;[ ]; + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[false]; + RightParenthesis;[)]; + NewLine;[LF]; + LeftBrace;[{]; + NewLine;[LF]; + RightBrace;[}]; + NewLine;[LF]; + MarkupTextLiteral - [41..69)::28 - [#if trueLFelseLF#endifLF{LF}] - Gen - SpanEditHandler;Accepts:Any + Text;[#if]; + Whitespace;[ ]; + Text;[true]; + NewLine;[LF]; + Text;[else]; + NewLine;[LF]; + Text;[#endif]; + NewLine;[LF]; + Text;[{]; + NewLine;[LF]; + Text;[}]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIf.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIf.cspans.txt new file mode 100644 index 00000000000..bd30712ae49 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIf.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +Code span at (1:0,1 [21] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [22] ) +Markup span at (22:2,0 [12] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIf.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIf.stree.txt new file mode 100644 index 00000000000..ef03fd013ea --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIf.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..34)::34 - [@if (true)LF#if trueLF{LF#endifLF}] + MarkupBlock - [0..34)::34 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..22)::22 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..22)::21 - [if (true)LF#if trueLF] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + NewLine;[LF]; + Hash;[#]; + Keyword;[if]; + Whitespace;[ ]; + Keyword;[true]; + NewLine;[LF]; + MarkupTextLiteral - [22..34)::12 - [{LF#endifLF}] - Gen - SpanEditHandler;Accepts:Any + Text;[{]; + NewLine;[LF]; + Text;[#endif]; + NewLine;[LF]; + Text;[}]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIfBeforeElseIf.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIfBeforeElseIf.cspans.txt new file mode 100644 index 00000000000..facddafe9dc --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIfBeforeElseIf.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [57] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [18] ) +Code span at (1:0,1 [17] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [18] ) +Markup span at (18:3,0 [39] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [57] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIfBeforeElseIf.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIfBeforeElseIf.stree.txt new file mode 100644 index 00000000000..fce961f4227 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIfBeforeElseIf.stree.txt @@ -0,0 +1,35 @@ +RazorDocument - [0..57)::57 - [@if (true)LF{LF}LF#if trueLFelse if (false)LF#endifLF{LF}] + MarkupBlock - [0..57)::57 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..18)::18 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..18)::17 - [if (true)LF{LF}LF] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + NewLine;[LF]; + LeftBrace;[{]; + NewLine;[LF]; + RightBrace;[}]; + NewLine;[LF]; + MarkupTextLiteral - [18..57)::39 - [#if trueLFelse if (false)LF#endifLF{LF}] - Gen - SpanEditHandler;Accepts:Any + Text;[#if]; + Whitespace;[ ]; + Text;[true]; + NewLine;[LF]; + Text;[else]; + Whitespace;[ ]; + Text;[if]; + Whitespace;[ ]; + Text;[(false)]; + NewLine;[LF]; + Text;[#endif]; + NewLine;[LF]; + Text;[{]; + NewLine;[LF]; + Text;[}]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIfBlock.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIfBlock.cspans.txt new file mode 100644 index 00000000000..8f7da2fe51a --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIfBlock.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [28] ) +Code span at (1:0,1 [27] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [28] ) +Markup span at (28:4,0 [6] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIfBlock.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIfBlock.stree.txt new file mode 100644 index 00000000000..99893d9ef14 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIfBlock.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..34)::34 - [@if (true)LF{LF#if trueLF}LF#endif] + MarkupBlock - [0..34)::34 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..28)::28 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..28)::27 - [if (true)LF{LF#if trueLF}LF] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + NewLine;[LF]; + LeftBrace;[{]; + NewLine;[LF]; + Hash;[#]; + Keyword;[if]; + Whitespace;[ ]; + Keyword;[true]; + NewLine;[LF]; + RightBrace;[}]; + NewLine;[LF]; + MarkupTextLiteral - [28..34)::6 - [#endif] - Gen - SpanEditHandler;Accepts:Any + Text;[#endif]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/NullableDirectives.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/NullableDirectives.cspans.txt new file mode 100644 index 00000000000..efe37cdab5e --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/NullableDirectives.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [236] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [236] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [236] ) +Code span at (2:0,2 [233] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [236] ) +MetaCode span at (235:10,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [236] ) +Markup span at (236:10,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [236] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/NullableDirectives.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/NullableDirectives.stree.txt new file mode 100644 index 00000000000..e4b1bd5d08f --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/NullableDirectives.stree.txt @@ -0,0 +1,76 @@ +RazorDocument - [0..236)::236 - [@{LF#nullable enableLF#nullable disableLF#nullable restoreLF#nullable enable annotationsLF#nullable disable annotationsLF#nullable restore annotationsLF#nullable enable warningsLF#nullable disable warningsLF#nullable restore warningsLF}] + MarkupBlock - [0..236)::236 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..236)::236 + CSharpStatement - [0..236)::236 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..236)::235 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..235)::233 + CSharpStatementLiteral - [2..235)::233 - [LF#nullable enableLF#nullable disableLF#nullable restoreLF#nullable enable annotationsLF#nullable disable annotationsLF#nullable restore annotationsLF#nullable enable warningsLF#nullable disable warningsLF#nullable restore warningsLF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + Hash;[#]; + Identifier;[nullable]; + Whitespace;[ ]; + Identifier;[enable]; + NewLine;[LF]; + Hash;[#]; + Identifier;[nullable]; + Whitespace;[ ]; + Identifier;[disable]; + NewLine;[LF]; + Hash;[#]; + Identifier;[nullable]; + Whitespace;[ ]; + Identifier;[restore]; + NewLine;[LF]; + Hash;[#]; + Identifier;[nullable]; + Whitespace;[ ]; + Identifier;[enable]; + Whitespace;[ ]; + Identifier;[annotations]; + NewLine;[LF]; + Hash;[#]; + Identifier;[nullable]; + Whitespace;[ ]; + Identifier;[disable]; + Whitespace;[ ]; + Identifier;[annotations]; + NewLine;[LF]; + Hash;[#]; + Identifier;[nullable]; + Whitespace;[ ]; + Identifier;[restore]; + Whitespace;[ ]; + Identifier;[annotations]; + NewLine;[LF]; + Hash;[#]; + Identifier;[nullable]; + Whitespace;[ ]; + Identifier;[enable]; + Whitespace;[ ]; + Identifier;[warnings]; + NewLine;[LF]; + Hash;[#]; + Identifier;[nullable]; + Whitespace;[ ]; + Identifier;[disable]; + Whitespace;[ ]; + Identifier;[warnings]; + NewLine;[LF]; + Hash;[#]; + Identifier;[nullable]; + Whitespace;[ ]; + Identifier;[restore]; + Whitespace;[ ]; + Identifier;[warnings]; + NewLine;[LF]; + RazorMetaCode - [235..236)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [236..236)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/Pragmas.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/Pragmas.cspans.txt new file mode 100644 index 00000000000..d7bb090cc94 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/Pragmas.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [139] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [139] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [139] ) +Code span at (2:0,2 [136] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [139] ) +MetaCode span at (138:4,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [139] ) +Markup span at (139:4,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [139] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/Pragmas.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/Pragmas.stree.txt new file mode 100644 index 00000000000..24663ee2a78 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/Pragmas.stree.txt @@ -0,0 +1,48 @@ +RazorDocument - [0..139)::139 - [@{LF#pragma warning disable 123LF#pragma warning restore 123LF#pragma checksum "file.cs" "{00000000-0000-0000-0000-000000000000}" "1234"LF}] + MarkupBlock - [0..139)::139 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..139)::139 + CSharpStatement - [0..139)::139 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..139)::138 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..138)::136 + CSharpStatementLiteral - [2..138)::136 - [LF#pragma warning disable 123LF#pragma warning restore 123LF#pragma checksum "file.cs" "{00000000-0000-0000-0000-000000000000}" "1234"LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + Hash;[#]; + Identifier;[pragma]; + Whitespace;[ ]; + Identifier;[warning]; + Whitespace;[ ]; + Identifier;[disable]; + Whitespace;[ ]; + IntegerLiteral;[123]; + NewLine;[LF]; + Hash;[#]; + Identifier;[pragma]; + Whitespace;[ ]; + Identifier;[warning]; + Whitespace;[ ]; + Identifier;[restore]; + Whitespace;[ ]; + IntegerLiteral;[123]; + NewLine;[LF]; + Hash;[#]; + Identifier;[pragma]; + Whitespace;[ ]; + Identifier;[checksum]; + Whitespace;[ ]; + StringLiteral;["file.cs"]; + Whitespace;[ ]; + StringLiteral;["{00000000-0000-0000-0000-000000000000}"]; + Whitespace;[ ]; + StringLiteral;["1234"]; + NewLine;[LF]; + RazorMetaCode - [138..139)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [139..139)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/Regions.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/Regions.cspans.txt new file mode 100644 index 00000000000..01206b67bb7 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/Regions.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [37] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +Code span at (2:0,2 [19] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [22] ) +MetaCode span at (21:1,17 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +Markup span at (22:1,18 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [37] ) +Markup span at (24:2,0 [13] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [37] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/Regions.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/Regions.stree.txt new file mode 100644 index 00000000000..4327a893ed3 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/Regions.stree.txt @@ -0,0 +1,28 @@ +RazorDocument - [0..37)::37 - [@{LF#region MyRegion }LF#endregionLF}] + MarkupBlock - [0..37)::37 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..22)::22 + CSharpStatement - [0..22)::22 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..22)::21 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..21)::19 + CSharpStatementLiteral - [2..21)::19 - [LF#region MyRegion ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + Hash;[#]; + Identifier;[region]; + Whitespace;[ ]; + Identifier;[MyRegion]; + Whitespace;[ ]; + RazorMetaCode - [21..22)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [22..24)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupTextLiteral - [24..37)::13 - [#endregionLF}] - Gen - SpanEditHandler;Accepts:Any + Text;[#endregion]; + NewLine;[LF]; + Text;[}]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/SimpleIfDef.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/SimpleIfDef.cspans.txt new file mode 100644 index 00000000000..7c279cf6e0f --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/SimpleIfDef.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [39] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [39] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [39] ) +Code span at (2:0,2 [36] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [39] ) +MetaCode span at (38:4,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [39] ) +Markup span at (39:4,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [39] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/SimpleIfDef.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/SimpleIfDef.stree.txt new file mode 100644 index 00000000000..ee3229aa41d --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/SimpleIfDef.stree.txt @@ -0,0 +1,37 @@ +RazorDocument - [0..39)::39 - [@{LF#if trueLF var x = 1;LF#endifLF}] + MarkupBlock - [0..39)::39 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..39)::39 + CSharpStatement - [0..39)::39 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..39)::38 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..38)::36 + CSharpStatementLiteral - [2..38)::36 - [LF#if trueLF var x = 1;LF#endifLF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + Hash;[#]; + Keyword;[if]; + Whitespace;[ ]; + Keyword;[true]; + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[1]; + Semicolon;[;]; + NewLine;[LF]; + Hash;[#]; + Identifier;[endif]; + NewLine;[LF]; + RazorMetaCode - [38..39)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [39..39)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/SimplePragma.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/SimplePragma.cspans.txt new file mode 100644 index 00000000000..460e15b3757 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/SimplePragma.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [38] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [38] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [38] ) +Code span at (2:0,2 [35] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [38] ) +MetaCode span at (37:2,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [38] ) +Markup span at (38:2,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [38] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/SimplePragma.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/SimplePragma.stree.txt new file mode 100644 index 00000000000..8008e1d6fd9 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/SimplePragma.stree.txt @@ -0,0 +1,29 @@ +RazorDocument - [0..38)::38 - [@{LF #pragma warning disable 123LF}] + MarkupBlock - [0..38)::38 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..38)::38 + CSharpStatement - [0..38)::38 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..38)::37 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..37)::35 + CSharpStatementLiteral - [2..37)::35 - [LF #pragma warning disable 123LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + Whitespace;[ ]; + Hash;[#]; + Identifier;[pragma]; + Whitespace;[ ]; + Identifier;[warning]; + Whitespace;[ ]; + Identifier;[disable]; + Whitespace;[ ]; + IntegerLiteral;[123]; + NewLine;[LF]; + RazorMetaCode - [37..38)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [38..38)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/UsingStatementResults.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/UsingStatementResults.cspans.txt new file mode 100644 index 00000000000..6e714cb473c --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/UsingStatementResults.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [48] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [36] ) +Code span at (1:0,1 [35] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [36] ) +Markup span at (36:2,0 [12] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [48] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/UsingStatementResults.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/UsingStatementResults.stree.txt new file mode 100644 index 00000000000..62d5ec951d8 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/TestFiles/ParserTests/CSharpPreprocessorTest/UsingStatementResults.stree.txt @@ -0,0 +1,32 @@ +RazorDocument - [0..48)::48 - [@using (var test = blah)LF#if trueLF{LF#endifLF}] + MarkupBlock - [0..48)::48 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..36)::36 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..36)::35 - [using (var test = blah)LF#if trueLF] - Gen - SpanEditHandler;Accepts:Any + Keyword;[using]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[test]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[blah]; + RightParenthesis;[)]; + NewLine;[LF]; + Hash;[#]; + Keyword;[if]; + Whitespace;[ ]; + Keyword;[true]; + NewLine;[LF]; + MarkupTextLiteral - [36..48)::12 - [{LF#endifLF}] - Gen - SpanEditHandler;Accepts:Any + Text;[{]; + NewLine;[LF]; + Text;[#endif]; + NewLine;[LF]; + Text;[}]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentPreprocessorDirectiveTest.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentPreprocessorDirectiveTest.cs new file mode 100644 index 00000000000..75bb678b39d --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentPreprocessorDirectiveTest.cs @@ -0,0 +1,719 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.AspNetCore.Razor.Test.Common; +using Microsoft.CodeAnalysis; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests; + +public class ComponentPreprocessorDirectiveTest(bool designTime = false) + : RazorBaselineIntegrationTestBase(layer: TestProject.Layer.Compiler) +{ + internal override string FileKind => FileKinds.Component; + + internal override bool UseTwoPhaseCompilation => true; + + internal string ComponentName = "TestComponent"; + + internal override string DefaultFileName => ComponentName + ".razor"; + + internal override bool DesignTime => designTime; + + protected override string GetDirectoryPath(string testName) + { + var directory = DesignTime ? "ComponentDesignTimePreprocessorDirectiveTest" : "ComponentRuntimePreprocessorDirectiveTest"; + return $"TestFiles/IntegrationTests/{directory}/{testName}"; + } + + [IntegrationTestFact] + public void IfDefAndPragma() + { + var generated = CompileToCSharp(""" + @{ + #pragma warning disable 219 // variable declared but not used + #if true + var x = 1; + #endif + } + """); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [IntegrationTestFact] + public void DisabledText_01() + { + var generated = CompileToCSharp(""" + @{ + #if false +

Some text

+ #endif + } + """); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [IntegrationTestFact] + public void PassParseOptionsThrough_01() + { + var parseOptions = CSharpParseOptions.WithPreprocessorSymbols("SomeSymbol"); + + var generated = CompileToCSharp(""" + @{ + #if SomeSymbol +

Some text

+ #endif + } + """, + csharpParseOptions: parseOptions); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [IntegrationTestFact] + public void PassParseOptionsThrough_02() + { + var parseOptions = CSharpParseOptions.WithPreprocessorSymbols("SomeSymbol"); + + var generated = CompileToCSharp(""" + @{ + #if !SomeSymbol +

Some text

+ #endif + } + """, + csharpParseOptions: parseOptions); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [IntegrationTestFact] + public void DefineAndUndef() + { + var generated = CompileToCSharp(""" + @{ + #define SomeSymbol + #undef SomeSymbol + } + """); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated, + // x:\dir\subdir\Test\TestComponent.cshtml(2,2): error CS1032: Cannot define/undefine preprocessor symbols after first token in file + // #define SomeSymbol + Diagnostic(ErrorCode.ERR_PPDefFollowsToken, "define").WithLocation(2, 2), + // x:\dir\subdir\Test\TestComponent.cshtml(3,2): error CS1032: Cannot define/undefine preprocessor symbols after first token in file + // #undef SomeSymbol + Diagnostic(ErrorCode.ERR_PPDefFollowsToken, "undef").WithLocation(3, 2) + ); + } + + [IntegrationTestFact] + public void AfterTag() + { + var generated = CompileToCSharp(""" + @{ +
+ #if true +
+ } + @{ + #endif + } + """); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument, verifyLinePragmas: false); + CompileToAssembly(generated, + // x:\dir\subdir\Test\TestComponent.cshtml(7,1): error CS1028: Unexpected preprocessor directive + // #endif + Diagnostic(ErrorCode.ERR_UnexpectedDirective, "#endif").WithLocation(7, 1)); + } + + [IntegrationTestFact] + public void StartOfLine_01() + { + var generated = CompileToCSharp(""" + @{ #if true } + @{ #endif } + """); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated, + // x:\dir\subdir\Test\TestComponent.cshtml(1,13): error CS1025: Single-line comment or end-of-line expected + // #if true } + Diagnostic(ErrorCode.ERR_EndOfPPLineExpected, "}").WithLocation(1, 13), + // x:\dir\subdir\Test\TestComponent.cshtml(2,11): error CS1025: Single-line comment or end-of-line expected + // #endif } + Diagnostic(ErrorCode.ERR_EndOfPPLineExpected, "}").WithLocation(2, 11)); + } + + [IntegrationTestFact] + public void StartOfLine_02() + { + var generated = CompileToCSharp(""" + @{ + /* test */ #if true + } + @{ + /* test */ #endif + } + """); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated, + // x:\dir\subdir\Test\TestComponent.cshtml(2,12): error CS1040: Preprocessor directives must appear as the first non-whitespace character on a line + // /* test */ #if true + Diagnostic(ErrorCode.ERR_BadDirectivePlacement, "#").WithLocation(2, 12), + // x:\dir\subdir\Test\TestComponent.cshtml(5,12): error CS1040: Preprocessor directives must appear as the first non-whitespace character on a line + // /* test */ #endif + Diagnostic(ErrorCode.ERR_BadDirectivePlacement, "#").WithLocation(5, 12)); + } + + [IntegrationTestFact] + public void StartOfLine_03() + { + var generated = CompileToCSharp(""" + @{ + #pragma warning disable 219 + var x = 1; #if true + } + @{ + var y = 2; #endif + } + """); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated, + // x:\dir\subdir\Test\TestComponent.cshtml(3,12): error CS1040: Preprocessor directives must appear as the first non-whitespace character on a line + // var x = 1; #if true + Diagnostic(ErrorCode.ERR_BadDirectivePlacement, "#").WithLocation(3, 12), + // x:\dir\subdir\Test\TestComponent.cshtml(6,12): error CS1040: Preprocessor directives must appear as the first non-whitespace character on a line + // var y = 2; #endif + Diagnostic(ErrorCode.ERR_BadDirectivePlacement, "#").WithLocation(6, 12)); + } + + [IntegrationTestFact] + public void StartOfLine_04() + { + var generated = CompileToCSharp(""" + @{ + var x = #if true; + } + @{ + x #endif; + } + """); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated, + // x:\dir\subdir\Test\TestComponent.cshtml(2,9): error CS1040: Preprocessor directives must appear as the first non-whitespace character on a line + // var x = #if true; + Diagnostic(ErrorCode.ERR_BadDirectivePlacement, "#").WithLocation(2, 9), + // x:\dir\subdir\Test\TestComponent.cshtml(2,17): error CS1025: Single-line comment or end-of-line expected + // var x = #if true; + Diagnostic(ErrorCode.ERR_EndOfPPLineExpected, ";").WithLocation(2, 17), + // x:\dir\subdir\Test\TestComponent.cshtml(5,1): error CS0841: Cannot use local variable 'x' before it is declared + // x #endif; + Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "x").WithArguments("x").WithLocation(5, 1), + // x:\dir\subdir\Test\TestComponent.cshtml(5,2): error CS1002: ; expected + // x #endif; + Diagnostic(ErrorCode.ERR_SemicolonExpected, "").WithLocation(5, 2), + // x:\dir\subdir\Test\TestComponent.cshtml(5,3): error CS1040: Preprocessor directives must appear as the first non-whitespace character on a line + // x #endif; + Diagnostic(ErrorCode.ERR_BadDirectivePlacement, "#").WithLocation(5, 3), + // x:\dir\subdir\Test\TestComponent.cshtml(5,9): error CS1025: Single-line comment or end-of-line expected + // x #endif; + Diagnostic(ErrorCode.ERR_EndOfPPLineExpected, ";").WithLocation(5, 9)); + } + + [IntegrationTestFact] + public void StartOfLine_05() + { + var generated = CompileToCSharp(""" + @{ +
#if true
+ } + @{ +
#endif
+ } + """); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument, verifyLinePragmas: false); + CompileToAssembly(generated); + } + + [IntegrationTestFact] + public void StartOfLine_06() + { + var generated = CompileToCSharp(""" + @{ + #if true + } + @{ + #endif + } + """); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [IntegrationTestFact] + public void StartOfLine_07() + { + // This test uses tabs as the leading whitespace + var generated = CompileToCSharp(""" + @{ + #if true + } + @{ + #endif + } + """); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [IntegrationTestFact] + public void StartOfLine_08() + { + // vertical tab + var generated = CompileToCSharp($$""" + @{ + {{'\v'}}#if true + } + @{ + {{'\v'}}#endif + } + """); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [IntegrationTestFact] + public void StartOfLine_09() + { + // Form feed + var generated = CompileToCSharp($$""" + @{ + {{'\f'}}#if true + } + @{ + {{'\f'}}#endif + } + """); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [IntegrationTestFact] + public void StartOfLine_10() + { + // NBSP + var generated = CompileToCSharp($$""" + @{ + {{'\u00A0'}}#if true + } + @{ + {{'\u00A0'}}#endif + } + """); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [IntegrationTestFact] + public void StartOfLine_11() + { + // ZWNBSP + var generated = CompileToCSharp($$""" + @{ + {{'\uFEFF'}}#if true + } + @{ + {{'\uFEFF'}}#endif + } + """); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [IntegrationTestFact] + public void MisplacedEndingDirective_01() + { + var generated = CompileToCSharp(""" + @{ + #if false + } + @{ #endif } + """); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + var expectedDiagnostic = DesignTime ? + new[] + { + // x:\dir\subdir\Test\TestComponent.cshtml(14,1): error CS1027: #endif directive expected + // + Diagnostic(ErrorCode.ERR_EndifDirectiveExpected, "").WithLocation(14, 1), + // (26,10): error CS1513: } expected + // { + Diagnostic(ErrorCode.ERR_RbraceExpected, "").WithLocation(26, 10), + // (26,10): error CS1513: } expected + // { + Diagnostic(ErrorCode.ERR_RbraceExpected, "").WithLocation(26, 10), + // (26,10): error CS1513: } expected + // { + Diagnostic(ErrorCode.ERR_RbraceExpected, "").WithLocation(26, 10) + } + : + new[] + { + + // x:\dir\subdir\Test\TestComponent.cshtml(15,1): error CS1027: #endif directive expected + // + Diagnostic(ErrorCode.ERR_EndifDirectiveExpected, "").WithLocation(15, 1), + // (19,10): error CS1513: } expected + // { + Diagnostic(ErrorCode.ERR_RbraceExpected, "").WithLocation(19, 10), + // (19,10): error CS1513: } expected + // { + Diagnostic(ErrorCode.ERR_RbraceExpected, "").WithLocation(19, 10), + // (19,10): error CS1513: } expected + // { + Diagnostic(ErrorCode.ERR_RbraceExpected, "").WithLocation(19, 10) + }; + + CompileToAssembly(generated, expectedDiagnostic); + } + + [IntegrationTestFact] + public void MisplacedEndingDirective_02() + { + var generated = CompileToCSharp(""" + @{ + #if false + } + @{ Test #endif } + """); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + var expectedDiagnostics = DesignTime ? + new[] + { + // x:\dir\subdir\Test\TestComponent.cshtml(14,1): error CS1027: #endif directive expected + // + Diagnostic(ErrorCode.ERR_EndifDirectiveExpected, "").WithLocation(14, 1), + // (26,10): error CS1513: } expected + // { + Diagnostic(ErrorCode.ERR_RbraceExpected, "").WithLocation(26, 10), + // (26,10): error CS1513: } expected + // { + Diagnostic(ErrorCode.ERR_RbraceExpected, "").WithLocation(26, 10), + // (26,10): error CS1513: } expected + // { + Diagnostic(ErrorCode.ERR_RbraceExpected, "").WithLocation(26, 10) + } + : + new[] + { + // x:\dir\subdir\Test\TestComponent.cshtml(15,1): error CS1027: #endif directive expected + // + Diagnostic(ErrorCode.ERR_EndifDirectiveExpected, "").WithLocation(15, 1), + // (19,10): error CS1513: } expected + // { + Diagnostic(ErrorCode.ERR_RbraceExpected, "").WithLocation(19, 10), + // (19,10): error CS1513: } expected + // { + Diagnostic(ErrorCode.ERR_RbraceExpected, "").WithLocation(19, 10), + // (19,10): error CS1513: } expected + // { + Diagnostic(ErrorCode.ERR_RbraceExpected, "").WithLocation(19, 10) + }; + + CompileToAssembly(generated, expectedDiagnostics); + } + + [IntegrationTestFact] + public void MisplacedEndingDirective_03() + { + var generated = CompileToCSharp(""" + @{ + #if false + } + @{ + /* test */ #endif + } + """); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + var expectedDiagnostics = DesignTime ? + new[] + { + // x:\dir\subdir\Test\TestComponent.cshtml(16,1): error CS1027: #endif directive expected + // + Diagnostic(ErrorCode.ERR_EndifDirectiveExpected, "").WithLocation(16, 1), + // (26,10): error CS1513: } expected + // { + Diagnostic(ErrorCode.ERR_RbraceExpected, "").WithLocation(26, 10), + // (26,10): error CS1513: } expected + // { + Diagnostic(ErrorCode.ERR_RbraceExpected, "").WithLocation(26, 10), + // (26,10): error CS1513: } expected + // { + Diagnostic(ErrorCode.ERR_RbraceExpected, "").WithLocation(26, 10) + } + : + new[] + { + // x:\dir\subdir\Test\TestComponent.cshtml(17,1): error CS1027: #endif directive expected + // + Diagnostic(ErrorCode.ERR_EndifDirectiveExpected, "").WithLocation(17, 1), + // (19,10): error CS1513: } expected + // { + Diagnostic(ErrorCode.ERR_RbraceExpected, "").WithLocation(19, 10), + // (19,10): error CS1513: } expected + // { + Diagnostic(ErrorCode.ERR_RbraceExpected, "").WithLocation(19, 10), + // (19,10): error CS1513: } expected + // { + Diagnostic(ErrorCode.ERR_RbraceExpected, "").WithLocation(19, 10) + }; + + CompileToAssembly(generated, expectedDiagnostics); + } + + [IntegrationTestFact] + public void MisplacedEndingDirective_04() + { + var generated = CompileToCSharp(""" + @{ + #if false + } + @{ + /* test */ #endif + } + """); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + var expectedDiagnostics = DesignTime ? + new[] + { + // x:\dir\subdir\Test\TestComponent.cshtml(16,1): error CS1027: #endif directive expected + // + Diagnostic(ErrorCode.ERR_EndifDirectiveExpected, "").WithLocation(16, 1), + // (26,10): error CS1513: } expected + // { + Diagnostic(ErrorCode.ERR_RbraceExpected, "").WithLocation(26, 10), + // (26,10): error CS1513: } expected + // { + Diagnostic(ErrorCode.ERR_RbraceExpected, "").WithLocation(26, 10), + // (26,10): error CS1513: } expected + // { + Diagnostic(ErrorCode.ERR_RbraceExpected, "").WithLocation(26, 10) + } + : + new[] + { + // x:\dir\subdir\Test\TestComponent.cshtml(17,1): error CS1027: #endif directive expected + // + Diagnostic(ErrorCode.ERR_EndifDirectiveExpected, "").WithLocation(17, 1), + // (19,10): error CS1513: } expected + // { + Diagnostic(ErrorCode.ERR_RbraceExpected, "").WithLocation(19, 10), + // (19,10): error CS1513: } expected + // { + Diagnostic(ErrorCode.ERR_RbraceExpected, "").WithLocation(19, 10), + // (19,10): error CS1513: } expected + // { + Diagnostic(ErrorCode.ERR_RbraceExpected, "").WithLocation(19, 10) + }; + + CompileToAssembly(generated, expectedDiagnostics); + } + + [IntegrationTestFact] + public void MisplacedEndingDirective_05() + { + var generated = CompileToCSharp(""" + @{ + #if false + } + @{ +
#endif
+ } + """); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + var expectedDiagnostics = DesignTime ? + new[] + { + // x:\dir\subdir\Test\TestComponent.cshtml(16,1): error CS1027: #endif directive expected + // + Diagnostic(ErrorCode.ERR_EndifDirectiveExpected, "").WithLocation(16, 1), + // (26,10): error CS1513: } expected + // { + Diagnostic(ErrorCode.ERR_RbraceExpected, "").WithLocation(26, 10), + // (26,10): error CS1513: } expected + // { + Diagnostic(ErrorCode.ERR_RbraceExpected, "").WithLocation(26, 10), + // (26,10): error CS1513: } expected + // { + Diagnostic(ErrorCode.ERR_RbraceExpected, "").WithLocation(26, 10) + } + : + new[] + { + // x:\dir\subdir\Test\TestComponent.cshtml(17,1): error CS1027: #endif directive expected + // + Diagnostic(ErrorCode.ERR_EndifDirectiveExpected, "").WithLocation(17, 1), + // (19,10): error CS1513: } expected + // { + Diagnostic(ErrorCode.ERR_RbraceExpected, "").WithLocation(19, 10), + // (19,10): error CS1513: } expected + // { + Diagnostic(ErrorCode.ERR_RbraceExpected, "").WithLocation(19, 10), + // (19,10): error CS1513: } expected + // { + Diagnostic(ErrorCode.ERR_RbraceExpected, "").WithLocation(19, 10) + }; + + CompileToAssembly(generated, expectedDiagnostics); + } + + [IntegrationTestFact] + public void MisplacedEndingDirective_06() + { + var generated = CompileToCSharp(""" + @{ + #if false + } + @{ #else } + @{ + #endif + } + """); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + CompileToAssembly(generated); + } + + [IntegrationTestFact] + public void MisplacedEndingDirective_07() + { + var generated = CompileToCSharp(""" + @{ + #if false + } + @{ Test #else } + @{ + #endif + } + """); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + CompileToAssembly(generated); + } + + [IntegrationTestFact] + public void MisplacedEndingDirective_08() + { + var generated = CompileToCSharp(""" + @{ + #if false + } + @{ + /* test */ #else + } + @{ + #endif + } + """); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + CompileToAssembly(generated); + } + + [IntegrationTestFact] + public void MisplacedEndingDirective_09() + { + var generated = CompileToCSharp(""" + @{ + #if false + } + @{ + /* test */ #else + } + @{ + #endif + } + """); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [IntegrationTestFact] + public void MisplacedEndingDirective_10() + { + var generated = CompileToCSharp(""" + @{ + #if false + } + @{ +
#else
+ } + @{ + #endif + } + """); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + CompileToAssembly(generated); + } +} diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpBlockTest.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpBlockTest.cs index e1fa97a2bcf..d858ef1df4e 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpBlockTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpBlockTest.cs @@ -906,6 +906,20 @@ public void EscapedIdentifiers_13() """); } + [Fact] + public void Usings() + { + ParseDocumentTest(""" + { + @using global::System + @using global::System.Collections.Generic + @using global::System.Linq + @using global::System.Threading.Tasks + @using global::Microsoft.AspNetCore.Components + } + """); + } + private void RunRazorCommentBetweenClausesTest(string preComment, string postComment, AcceptedCharactersInternal acceptedCharacters = AcceptedCharactersInternal.Any) { ParseDocumentTest(preComment + "@* Foo *@ @* Bar *@" + postComment); diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpPreprocessorTest.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpPreprocessorTest.cs new file mode 100644 index 00000000000..8653c45f23b --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpPreprocessorTest.cs @@ -0,0 +1,365 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Immutable; +using Microsoft.CodeAnalysis.CSharp; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy; + +public class CSharpPreprocessorTest() : ParserTestBase(layer: TestProject.Layer.Compiler) +{ + [Fact] + public void Pragmas() + { + ParseDocumentTest(""" + @{ + #pragma warning disable 123 + #pragma warning restore 123 + #pragma checksum "file.cs" "{00000000-0000-0000-0000-000000000000}" "1234" + } + """); + } + + [Fact] + public void NullableDirectives() + { + ParseDocumentTest(""" + @{ + #nullable enable + #nullable disable + #nullable restore + #nullable enable annotations + #nullable disable annotations + #nullable restore annotations + #nullable enable warnings + #nullable disable warnings + #nullable restore warnings + } + """); + } + + [Fact] + public void DefineThenIfDef() + { + ParseDocumentTest(""" + @{ + #define SYMBOL + #if SYMBOL + #undef SYMBOL + #if SYMBOL + var x = 1; + #endif + #else + var x = 1; + #endif + } + """); + } + + [Fact] + public void ErrorWarningLine() + { + ParseDocumentTest(""" + @{ + #line 1 "file.cs" + #error This is an error + #line default + #warning This is a warning + #line hidden + #line (1, 1) - (5, 60) 10 "partial-class.cs" + } + """); + } + + [Fact] + public void Regions() + { + ParseDocumentTest(""" + @{ + #region MyRegion } + #endregion + } + """); + } + + [Fact] + public void SimpleIfDef_01() + { + ParseDocumentTest(""" + @{ + #if true + var x = 1; + #endif + } + """); + } + + [Fact] + public void SimpleIfDef_02() + { + ParseDocumentTest(""" + @{ + #if true +

Some text

+ #endif + } + """); + } + + [Fact] + public void IfDefFromParseOptions_Symbol() + { + IfDefFromParseOptions("SYMBOL"); + } + + [Fact] + public void IfDefFromParseOptions_Symbol2() + { + IfDefFromParseOptions("SYMBOL2"); + } + + [Fact] + public void IfDefFromParseOptions_None() + { + IfDefFromParseOptions(null); + } + + private void IfDefFromParseOptions(string? directive) + { + var parseOptions = CSharpParseOptions.Default; + + if (directive != null) + { + parseOptions = parseOptions.WithPreprocessorSymbols(ImmutableArray.Create(directive)); + } + + ParseDocumentTest(""" + @{ + #if SYMBOL + var x = 1; + #elif SYMBOL2 + var x = 2; + #else + var x = 3; + #endif + } + """, parseOptions); + } + + [Fact] + public void IfDefAcrossMultipleBlocks() + { + ParseDocumentTest(""" + @{ + #if false + var x = 1; + } + +
+

Content

+
+ + @{ + var y = 2; + #endif + } + """); + } + + [Fact] + public void IfDefDisabledSectionUnbalanced() + { + ParseDocumentTest(""" + @{ + #if false + void M() { + #endif + } + """); + } + + [Fact] + public void IfDefNotOnNewline_01() + { + ParseDocumentTest(""" + @{ #if false } +
+

Content

+
+ @{ + #endif + } + """); + } + + [Fact] + public void IfDefNotOnNewline_02() + { + ParseDocumentTest(""" + @{#if false } +
+

Content

+
+ @{ + #endif + } + """); + } + + [Fact] + public void ElIfNotOnNewline() + { + ParseDocumentTest(""" + @{ + #if true + } +
+

Content

+
+ @{ #elif false } +
+

Content2

+
+ @{ + #endif + } + """); + } + + [Fact] + public void ElseNotOnNewline() + { + ParseDocumentTest(""" + @{ + #if true + } +
+

Content

+
+ @{ #else } +
+

Content2

+
+ @{ + #endif + } + """); + } + + [Fact] + public void EndIfNotOnNewline() + { + ParseDocumentTest(""" + @{ + #if false + } +
+

Content

+
+ @{ #endif } + """); + } + + [Fact] + public void UsingStatementResults() + { + ParseDocumentTest(""" + @using (var test = blah) + #if true + { + #endif + } + """); + } + + [Fact] + public void IfStatementAfterIf() + { + ParseDocumentTest(""" + @if (true) + #if true + { + #endif + } + """); + } + + [Fact] + public void IfStatementAfterIfBlock() + { + ParseDocumentTest(""" + @if (true) + { + #if true + } + #endif + """); + } + + [Fact] + public void IfStatementAfterIfBeforeElseIf() + { + ParseDocumentTest(""" + @if (true) + { + } + #if true + else if (false) + #endif + { + } + """); + } + + [Fact] + public void IfStatementAfterElseIf() + { + ParseDocumentTest(""" + @if (true) + { + } + else if (false) + #if true + { + #endif + } + """); + } + + [Fact] + public void IfStatementAfterElseIfBeforeElse() + { + ParseDocumentTest(""" + @if (true) + { + } + else if (false) + { + } + #if true + else + #endif + { + } + """); + } + + [Fact] + public void IfStatementAfterElse() + { + ParseDocumentTest(""" + @if (true) + { + } + else if (false) + { + } + else + #if true + { + #endif + } + """); + } +} diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpTokenizerOperatorsTest.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpTokenizerOperatorsTest.cs index 05120b41887..677119d077b 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpTokenizerOperatorsTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpTokenizerOperatorsTest.cs @@ -287,11 +287,4 @@ public void RightShift_Is_Not_Specially_Recognized() SyntaxFactory.Token(SyntaxKind.GreaterThan, ">"), SyntaxFactory.Token(SyntaxKind.GreaterThan, ">")); } - - // PROTOTYPE: Re-enable - // [Fact] - // public void Hash_Is_Recognized() - // { - // TestSingleToken("#", SyntaxKind.Hash); - // } } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/RazorDiagnosticDescriptorTest.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/RazorDiagnosticDescriptorTest.cs index 23d6e2f4b75..d57ad2cc813 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/RazorDiagnosticDescriptorTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/RazorDiagnosticDescriptorTest.cs @@ -1,6 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; +using System.Collections.Generic; +using System.Linq; using Xunit; namespace Microsoft.AspNetCore.Razor.Language; @@ -74,4 +77,30 @@ public void RazorDiagnosticDescriptor_HashCodesNotEqual() // Assert Assert.False(result); } + + [Fact] + public void NoDuplicateDiagnosticIds() + { + var ids = new HashSet(StringComparer.Ordinal); + var factoryType = typeof(RazorDiagnosticFactory); + + addAllDescriptors(ids, factoryType, typeof(AspNetCore.Razor.Language.RazorDiagnosticDescriptor)); + addAllDescriptors(ids, factoryType, typeof(CodeAnalysis.Razor.RazorDiagnosticFactory)); + addAllDescriptors(ids, factoryType, typeof(AspNetCore.Razor.Language.Components.ComponentDiagnosticFactory)); + addAllDescriptors(ids, factoryType, typeof(AspNetCore.Mvc.Razor.Extensions.RazorExtensionsDiagnosticFactory)); + + static void addAllDescriptors(HashSet ids, Type factoryType, Type diagnosticDescriptorType) + { + foreach (var field in factoryType.GetFields(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).Where(f => f.FieldType == diagnosticDescriptorType)) + { + var descriptor = (RazorDiagnosticDescriptor)field.GetValue(null)!; + if (ids.Contains(descriptor.Id)) + { + Assert.Fail($"Duplicate diagnostic id '{descriptor.Id}' found."); + } + + ids.Add(descriptor.Id); + } + } + } } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/AfterTag/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/AfterTag/TestComponent.codegen.cs new file mode 100644 index 00000000000..405ead4942a --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/AfterTag/TestComponent.codegen.cs @@ -0,0 +1,42 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #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) + { + + +#nullable restore +#line 6 "x:\dir\subdir\Test\TestComponent.razor" + +#endif + +#line default +#line hidden +#nullable disable + + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/AfterTag/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/AfterTag/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..39bfbdef6f6 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/AfterTag/TestComponent.diagnostics.txt @@ -0,0 +1,4 @@ +x:\dir\subdir\Test\TestComponent.razor(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +x:\dir\subdir\Test\TestComponent.razor(2,5): Error RZ9980: Unclosed tag 'div' with no matching end tag. +x:\dir\subdir\Test\TestComponent.razor(2,6): Error RZ1025: The "div" element was not closed. All elements must be either self-closing or have a matching end tag. +x:\dir\subdir\Test\TestComponent.razor(4,5): Error RZ9980: Unclosed tag 'div' with no matching end tag. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/AfterTag/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/AfterTag/TestComponent.ir.txt new file mode 100644 index 00000000000..1c33749dbb5 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/AfterTag/TestComponent.ir.txt @@ -0,0 +1,28 @@ +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 + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + 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 + CSharpCode - (2:0,2 [6] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [6] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n + MarkupElement - (8:1,4 [44] x:\dir\subdir\Test\TestComponent.razor) - div + HtmlContent - (13:1,9 [16] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (13:1,9 [16] x:\dir\subdir\Test\TestComponent.razor) - Html - \n#if true\n + MarkupElement - (29:3,4 [23] x:\dir\subdir\Test\TestComponent.razor) - div + HtmlContent - (34:3,9 [5] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (34:3,9 [5] x:\dir\subdir\Test\TestComponent.razor) - Html - \n}\n + CSharpCode - (41:5,2 [10] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (41:5,2 [10] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#endif\n + CSharpCode - (52:7,1 [0] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (52:7,1 [0] x:\dir\subdir\Test\TestComponent.razor) - CSharp - diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/AfterTag/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/AfterTag/TestComponent.mappings.txt new file mode 100644 index 00000000000..98f3dd79d12 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/AfterTag/TestComponent.mappings.txt @@ -0,0 +1,21 @@ +Source Location: (2:0,2 [6] x:\dir\subdir\Test\TestComponent.razor) +| + | +Generated Location: (917:26,2 [6] ) +| + | + +Source Location: (41:5,2 [10] x:\dir\subdir\Test\TestComponent.razor) +| +#endif +| +Generated Location: (996:30,2 [10] ) +| +#endif +| + +Source Location: (52:7,1 [0] x:\dir\subdir\Test\TestComponent.razor) +|| +Generated Location: (1057:36,1 [0] ) +|| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/DefineAndUndef/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/DefineAndUndef/TestComponent.codegen.cs new file mode 100644 index 00000000000..15bb25bb7cc --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/DefineAndUndef/TestComponent.codegen.cs @@ -0,0 +1,40 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #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) + { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.razor" + +#define SomeSymbol +#undef SomeSymbol + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/DefineAndUndef/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/DefineAndUndef/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..81e184a8cb9 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/DefineAndUndef/TestComponent.diagnostics.txt @@ -0,0 +1,2 @@ +x:\dir\subdir\Test\TestComponent.razor(2,1): Error RZ1042: '#define' and '#undef' cannot be used in razor markup. +x:\dir\subdir\Test\TestComponent.razor(3,1): Error RZ1042: '#define' and '#undef' cannot be used in razor markup. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/DefineAndUndef/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/DefineAndUndef/TestComponent.ir.txt new file mode 100644 index 00000000000..beaf2a3c125 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/DefineAndUndef/TestComponent.ir.txt @@ -0,0 +1,18 @@ +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 + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + 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 + CSharpCode - (2:0,2 [41] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [41] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#define SomeSymbol\n#undef SomeSymbol\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/DefineAndUndef/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/DefineAndUndef/TestComponent.mappings.txt new file mode 100644 index 00000000000..6260a12aa65 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/DefineAndUndef/TestComponent.mappings.txt @@ -0,0 +1,11 @@ +Source Location: (2:0,2 [41] x:\dir\subdir\Test\TestComponent.razor) +| +#define SomeSymbol +#undef SomeSymbol +| +Generated Location: (986:28,2 [41] ) +| +#define SomeSymbol +#undef SomeSymbol +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/DisabledText_01/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/DisabledText_01/TestComponent.codegen.cs new file mode 100644 index 00000000000..ea917289677 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/DisabledText_01/TestComponent.codegen.cs @@ -0,0 +1,41 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #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) + { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.razor" + +#if false +

Some text

+#endif + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/DisabledText_01/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/DisabledText_01/TestComponent.ir.txt new file mode 100644 index 00000000000..843d40d0fe9 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/DisabledText_01/TestComponent.ir.txt @@ -0,0 +1,18 @@ +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 + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + 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 + CSharpCode - (2:0,2 [43] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [43] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#if false\n

Some text

\n#endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/DisabledText_01/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/DisabledText_01/TestComponent.mappings.txt new file mode 100644 index 00000000000..0e191edb0d4 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/DisabledText_01/TestComponent.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (2:0,2 [43] x:\dir\subdir\Test\TestComponent.razor) +| +#if false +

Some text

+#endif +| +Generated Location: (986:28,2 [43] ) +| +#if false +

Some text

+#endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/IfDefAndPragma/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/IfDefAndPragma/TestComponent.codegen.cs new file mode 100644 index 00000000000..c9504c2833d --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/IfDefAndPragma/TestComponent.codegen.cs @@ -0,0 +1,42 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #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) + { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.razor" + +#pragma warning disable 219 // variable declared but not used +#if true + var x = 1; +#endif + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/IfDefAndPragma/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/IfDefAndPragma/TestComponent.ir.txt new file mode 100644 index 00000000000..4f53dbddb70 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/IfDefAndPragma/TestComponent.ir.txt @@ -0,0 +1,18 @@ +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 + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + 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 + CSharpCode - (2:0,2 [99] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [99] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#pragma warning disable 219 // variable declared but not used\n#if true\n var x = 1;\n#endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/IfDefAndPragma/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/IfDefAndPragma/TestComponent.mappings.txt new file mode 100644 index 00000000000..6af2997bec9 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/IfDefAndPragma/TestComponent.mappings.txt @@ -0,0 +1,15 @@ +Source Location: (2:0,2 [99] x:\dir\subdir\Test\TestComponent.razor) +| +#pragma warning disable 219 // variable declared but not used +#if true + var x = 1; +#endif +| +Generated Location: (986:28,2 [99] ) +| +#pragma warning disable 219 // variable declared but not used +#if true + var x = 1; +#endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_01/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_01/TestComponent.codegen.cs new file mode 100644 index 00000000000..2a21d32d6c3 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_01/TestComponent.codegen.cs @@ -0,0 +1,41 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #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) + { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.razor" + +#if false +} +@{ #endif } + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_01/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_01/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..3e562b47dce --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_01/TestComponent.diagnostics.txt @@ -0,0 +1,2 @@ +x:\dir\subdir\Test\TestComponent.razor(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(4,4): Warning RZ1044: Possible C# preprocessor directive is misplaced. C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_01/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_01/TestComponent.ir.txt new file mode 100644 index 00000000000..d5521d4f438 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_01/TestComponent.ir.txt @@ -0,0 +1,18 @@ +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 + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + 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 + CSharpCode - (2:0,2 [27] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [27] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#if false\n}\n@{ #endif } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_01/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_01/TestComponent.mappings.txt new file mode 100644 index 00000000000..f437cfc9844 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_01/TestComponent.mappings.txt @@ -0,0 +1,11 @@ +Source Location: (2:0,2 [27] x:\dir\subdir\Test\TestComponent.razor) +| +#if false +} +@{ #endif }| +Generated Location: (986:28,2 [27] ) +| +#if false +} +@{ #endif }| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_02/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_02/TestComponent.codegen.cs new file mode 100644 index 00000000000..44ecb3e9fe8 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_02/TestComponent.codegen.cs @@ -0,0 +1,41 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #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) + { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.razor" + +#if false +} +@{ Test #endif } + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_02/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_02/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..795fd53013a --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_02/TestComponent.diagnostics.txt @@ -0,0 +1,2 @@ +x:\dir\subdir\Test\TestComponent.razor(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(4,9): Warning RZ1044: Possible C# preprocessor directive is misplaced. C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_02/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_02/TestComponent.ir.txt new file mode 100644 index 00000000000..9880e71b4f4 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_02/TestComponent.ir.txt @@ -0,0 +1,18 @@ +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 + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + 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 + CSharpCode - (2:0,2 [32] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [32] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#if false\n}\n@{ Test #endif } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_02/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_02/TestComponent.mappings.txt new file mode 100644 index 00000000000..08e68598ca3 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_02/TestComponent.mappings.txt @@ -0,0 +1,11 @@ +Source Location: (2:0,2 [32] x:\dir\subdir\Test\TestComponent.razor) +| +#if false +} +@{ Test #endif }| +Generated Location: (986:28,2 [32] ) +| +#if false +} +@{ Test #endif }| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_03/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_03/TestComponent.codegen.cs new file mode 100644 index 00000000000..5d1b22dc58a --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_03/TestComponent.codegen.cs @@ -0,0 +1,43 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #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) + { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.razor" + +#if false +} +@{ +/* test */ #endif +} + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_03/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_03/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..9ec9ceea358 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_03/TestComponent.diagnostics.txt @@ -0,0 +1,2 @@ +x:\dir\subdir\Test\TestComponent.razor(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(5,12): Warning RZ1044: Possible C# preprocessor directive is misplaced. C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_03/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_03/TestComponent.ir.txt new file mode 100644 index 00000000000..27d684786c3 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_03/TestComponent.ir.txt @@ -0,0 +1,18 @@ +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 + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + 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 + CSharpCode - (2:0,2 [40] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [40] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#if false\n}\n@{\n/* test */ #endif\n} diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_03/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_03/TestComponent.mappings.txt new file mode 100644 index 00000000000..0ce431c3ca2 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_03/TestComponent.mappings.txt @@ -0,0 +1,15 @@ +Source Location: (2:0,2 [40] x:\dir\subdir\Test\TestComponent.razor) +| +#if false +} +@{ +/* test */ #endif +}| +Generated Location: (986:28,2 [40] ) +| +#if false +} +@{ +/* test */ #endif +}| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_04/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_04/TestComponent.codegen.cs new file mode 100644 index 00000000000..5d1b22dc58a --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_04/TestComponent.codegen.cs @@ -0,0 +1,43 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #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) + { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.razor" + +#if false +} +@{ +/* test */ #endif +} + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_04/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_04/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..9ec9ceea358 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_04/TestComponent.diagnostics.txt @@ -0,0 +1,2 @@ +x:\dir\subdir\Test\TestComponent.razor(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(5,12): Warning RZ1044: Possible C# preprocessor directive is misplaced. C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_04/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_04/TestComponent.ir.txt new file mode 100644 index 00000000000..27d684786c3 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_04/TestComponent.ir.txt @@ -0,0 +1,18 @@ +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 + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + 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 + CSharpCode - (2:0,2 [40] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [40] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#if false\n}\n@{\n/* test */ #endif\n} diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_04/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_04/TestComponent.mappings.txt new file mode 100644 index 00000000000..0ce431c3ca2 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_04/TestComponent.mappings.txt @@ -0,0 +1,15 @@ +Source Location: (2:0,2 [40] x:\dir\subdir\Test\TestComponent.razor) +| +#if false +} +@{ +/* test */ #endif +}| +Generated Location: (986:28,2 [40] ) +| +#if false +} +@{ +/* test */ #endif +}| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_05/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_05/TestComponent.codegen.cs new file mode 100644 index 00000000000..715d0e79901 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_05/TestComponent.codegen.cs @@ -0,0 +1,43 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #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) + { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.razor" + +#if false +} +@{ +
#endif
+} + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_05/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_05/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..8cace6a0b73 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_05/TestComponent.diagnostics.txt @@ -0,0 +1,2 @@ +x:\dir\subdir\Test\TestComponent.razor(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(5,6): Warning RZ1044: Possible C# preprocessor directive is misplaced. C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_05/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_05/TestComponent.ir.txt new file mode 100644 index 00000000000..1bce84ebbe6 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_05/TestComponent.ir.txt @@ -0,0 +1,18 @@ +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 + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + 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 + CSharpCode - (2:0,2 [40] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [40] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#if false\n}\n@{\n
#endif
\n} diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_05/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_05/TestComponent.mappings.txt new file mode 100644 index 00000000000..1cc3d69178b --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_05/TestComponent.mappings.txt @@ -0,0 +1,15 @@ +Source Location: (2:0,2 [40] x:\dir\subdir\Test\TestComponent.razor) +| +#if false +} +@{ +
#endif
+}| +Generated Location: (986:28,2 [40] ) +| +#if false +} +@{ +
#endif
+}| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_06/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_06/TestComponent.codegen.cs new file mode 100644 index 00000000000..8c67dbe862d --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_06/TestComponent.codegen.cs @@ -0,0 +1,43 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #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) + { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.razor" + +#if false +} +@{ #else } +@{ +#endif + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_06/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_06/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..e769081ec2d --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_06/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +(4,4): Warning RZ1044: Possible C# preprocessor directive is misplaced. C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_06/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_06/TestComponent.ir.txt new file mode 100644 index 00000000000..caa3f6f9b40 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_06/TestComponent.ir.txt @@ -0,0 +1,18 @@ +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 + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + 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 + CSharpCode - (2:0,2 [40] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [40] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#if false\n}\n@{ #else }\n@{\n#endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_06/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_06/TestComponent.mappings.txt new file mode 100644 index 00000000000..0758141e7fb --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_06/TestComponent.mappings.txt @@ -0,0 +1,17 @@ +Source Location: (2:0,2 [40] x:\dir\subdir\Test\TestComponent.razor) +| +#if false +} +@{ #else } +@{ +#endif +| +Generated Location: (986:28,2 [40] ) +| +#if false +} +@{ #else } +@{ +#endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_07/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_07/TestComponent.codegen.cs new file mode 100644 index 00000000000..88b92bb4700 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_07/TestComponent.codegen.cs @@ -0,0 +1,43 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #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) + { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.razor" + +#if false +} +@{ Test #else } +@{ +#endif + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_07/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_07/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..9db7a3b206f --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_07/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +(4,9): Warning RZ1044: Possible C# preprocessor directive is misplaced. C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_07/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_07/TestComponent.ir.txt new file mode 100644 index 00000000000..363ef118761 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_07/TestComponent.ir.txt @@ -0,0 +1,18 @@ +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 + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + 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 + CSharpCode - (2:0,2 [45] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [45] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#if false\n}\n@{ Test #else }\n@{\n#endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_07/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_07/TestComponent.mappings.txt new file mode 100644 index 00000000000..b8a607a0208 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_07/TestComponent.mappings.txt @@ -0,0 +1,17 @@ +Source Location: (2:0,2 [45] x:\dir\subdir\Test\TestComponent.razor) +| +#if false +} +@{ Test #else } +@{ +#endif +| +Generated Location: (986:28,2 [45] ) +| +#if false +} +@{ Test #else } +@{ +#endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_08/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_08/TestComponent.codegen.cs new file mode 100644 index 00000000000..197093fcb6d --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_08/TestComponent.codegen.cs @@ -0,0 +1,45 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #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) + { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.razor" + +#if false +} +@{ +/* test */ #else +} +@{ +#endif + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_08/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_08/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..d07194cdc17 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_08/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +(5,12): Warning RZ1044: Possible C# preprocessor directive is misplaced. C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_08/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_08/TestComponent.ir.txt new file mode 100644 index 00000000000..5feff7e6515 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_08/TestComponent.ir.txt @@ -0,0 +1,18 @@ +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 + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + 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 + CSharpCode - (2:0,2 [53] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [53] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#if false\n}\n@{\n/* test */ #else\n}\n@{\n#endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_08/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_08/TestComponent.mappings.txt new file mode 100644 index 00000000000..16ffa33a721 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_08/TestComponent.mappings.txt @@ -0,0 +1,21 @@ +Source Location: (2:0,2 [53] x:\dir\subdir\Test\TestComponent.razor) +| +#if false +} +@{ +/* test */ #else +} +@{ +#endif +| +Generated Location: (986:28,2 [53] ) +| +#if false +} +@{ +/* test */ #else +} +@{ +#endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_09/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_09/TestComponent.codegen.cs new file mode 100644 index 00000000000..197093fcb6d --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_09/TestComponent.codegen.cs @@ -0,0 +1,45 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #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) + { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.razor" + +#if false +} +@{ +/* test */ #else +} +@{ +#endif + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_09/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_09/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..d07194cdc17 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_09/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +(5,12): Warning RZ1044: Possible C# preprocessor directive is misplaced. C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_09/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_09/TestComponent.ir.txt new file mode 100644 index 00000000000..5feff7e6515 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_09/TestComponent.ir.txt @@ -0,0 +1,18 @@ +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 + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + 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 + CSharpCode - (2:0,2 [53] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [53] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#if false\n}\n@{\n/* test */ #else\n}\n@{\n#endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_09/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_09/TestComponent.mappings.txt new file mode 100644 index 00000000000..16ffa33a721 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_09/TestComponent.mappings.txt @@ -0,0 +1,21 @@ +Source Location: (2:0,2 [53] x:\dir\subdir\Test\TestComponent.razor) +| +#if false +} +@{ +/* test */ #else +} +@{ +#endif +| +Generated Location: (986:28,2 [53] ) +| +#if false +} +@{ +/* test */ #else +} +@{ +#endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_10/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_10/TestComponent.codegen.cs new file mode 100644 index 00000000000..b2e6def9652 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_10/TestComponent.codegen.cs @@ -0,0 +1,45 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #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) + { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.razor" + +#if false +} +@{ +
#else
+} +@{ +#endif + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_10/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_10/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..bf174dea560 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_10/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +(5,6): Warning RZ1044: Possible C# preprocessor directive is misplaced. C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_10/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_10/TestComponent.ir.txt new file mode 100644 index 00000000000..067b646a506 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_10/TestComponent.ir.txt @@ -0,0 +1,18 @@ +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 + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + 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 + CSharpCode - (2:0,2 [53] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [53] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#if false\n}\n@{\n
#else
\n}\n@{\n#endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_10/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_10/TestComponent.mappings.txt new file mode 100644 index 00000000000..798ba23bd06 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/MisplacedEndingDirective_10/TestComponent.mappings.txt @@ -0,0 +1,21 @@ +Source Location: (2:0,2 [53] x:\dir\subdir\Test\TestComponent.razor) +| +#if false +} +@{ +
#else
+} +@{ +#endif +| +Generated Location: (986:28,2 [53] ) +| +#if false +} +@{ +
#else
+} +@{ +#endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/PassParseOptionsThrough_01/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/PassParseOptionsThrough_01/TestComponent.codegen.cs new file mode 100644 index 00000000000..ec7ffa458df --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/PassParseOptionsThrough_01/TestComponent.codegen.cs @@ -0,0 +1,48 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #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) + { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.razor" + +#if SomeSymbol + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.razor" + +#endif + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/PassParseOptionsThrough_01/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/PassParseOptionsThrough_01/TestComponent.ir.txt new file mode 100644 index 00000000000..7f8a293ae41 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/PassParseOptionsThrough_01/TestComponent.ir.txt @@ -0,0 +1,23 @@ +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 + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + 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 + CSharpCode - (2:0,2 [22] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [22] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#if SomeSymbol\n + MarkupElement - (24:2,4 [16] x:\dir\subdir\Test\TestComponent.razor) - p + HtmlContent - (27:2,7 [9] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (27:2,7 [9] x:\dir\subdir\Test\TestComponent.razor) - Html - Some text + CSharpCode - (40:2,20 [10] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (40:2,20 [10] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/PassParseOptionsThrough_01/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/PassParseOptionsThrough_01/TestComponent.mappings.txt new file mode 100644 index 00000000000..5ebdaa2d252 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/PassParseOptionsThrough_01/TestComponent.mappings.txt @@ -0,0 +1,18 @@ +Source Location: (2:0,2 [22] x:\dir\subdir\Test\TestComponent.razor) +| +#if SomeSymbol + | +Generated Location: (986:28,2 [22] ) +| +#if SomeSymbol + | + +Source Location: (40:2,20 [10] x:\dir\subdir\Test\TestComponent.razor) +| +#endif +| +Generated Location: (1149:37,20 [10] ) +| +#endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/PassParseOptionsThrough_02/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/PassParseOptionsThrough_02/TestComponent.codegen.cs new file mode 100644 index 00000000000..8f48a7307e1 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/PassParseOptionsThrough_02/TestComponent.codegen.cs @@ -0,0 +1,41 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #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) + { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.razor" + +#if !SomeSymbol +

Some text

+#endif + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/PassParseOptionsThrough_02/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/PassParseOptionsThrough_02/TestComponent.ir.txt new file mode 100644 index 00000000000..d470dcea5a0 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/PassParseOptionsThrough_02/TestComponent.ir.txt @@ -0,0 +1,18 @@ +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 + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + 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 + CSharpCode - (2:0,2 [49] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [49] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#if !SomeSymbol\n

Some text

\n#endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/PassParseOptionsThrough_02/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/PassParseOptionsThrough_02/TestComponent.mappings.txt new file mode 100644 index 00000000000..272a4fa2199 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/PassParseOptionsThrough_02/TestComponent.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (2:0,2 [49] x:\dir\subdir\Test\TestComponent.razor) +| +#if !SomeSymbol +

Some text

+#endif +| +Generated Location: (986:28,2 [49] ) +| +#if !SomeSymbol +

Some text

+#endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/SimpleIfDef/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/SimpleIfDef/TestComponent.codegen.cs new file mode 100644 index 00000000000..6298cd47cd3 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/SimpleIfDef/TestComponent.codegen.cs @@ -0,0 +1,42 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #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) + { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + +#pragma warning disable 219 // variable declared but not used +#if true + var x = 1; +#endif + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/SimpleIfDef/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/SimpleIfDef/TestComponent.ir.txt new file mode 100644 index 00000000000..28c85a2cf76 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/SimpleIfDef/TestComponent.ir.txt @@ -0,0 +1,18 @@ +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 + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + 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 + CSharpCode - (2:0,2 [99] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (2:0,2 [99] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n#pragma warning disable 219 // variable declared but not used\n#if true\n var x = 1;\n#endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/SimpleIfDef/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/SimpleIfDef/TestComponent.mappings.txt new file mode 100644 index 00000000000..bfb65e81c94 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/SimpleIfDef/TestComponent.mappings.txt @@ -0,0 +1,15 @@ +Source Location: (2:0,2 [99] x:\dir\subdir\Test\TestComponent.cshtml) +| +#pragma warning disable 219 // variable declared but not used +#if true + var x = 1; +#endif +| +Generated Location: (987:28,2 [99] ) +| +#pragma warning disable 219 // variable declared but not used +#if true + var x = 1; +#endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_01/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_01/TestComponent.codegen.cs new file mode 100644 index 00000000000..b217c3d0b0f --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_01/TestComponent.codegen.cs @@ -0,0 +1,45 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #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) + { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.razor" + #if true } + +#line default +#line hidden +#nullable disable +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.razor" + #endif } + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_01/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_01/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..ade23f6812a --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_01/TestComponent.diagnostics.txt @@ -0,0 +1,5 @@ +x:\dir\subdir\Test\TestComponent.razor(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +x:\dir\subdir\Test\TestComponent.razor(1,4): Error RZ1043: C# preprocessor directives must be at the start of the line, except for whitespace. +x:\dir\subdir\Test\TestComponent.razor(2,2): Error RZ1010: Unexpected "{" after "@" character. Once inside the body of a code block (@if {}, @{}, etc.) you do not need to use "@{" to switch to code. +x:\dir\subdir\Test\TestComponent.razor(2,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +x:\dir\subdir\Test\TestComponent.razor(2,4): Error RZ1043: C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_01/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_01/TestComponent.ir.txt new file mode 100644 index 00000000000..8fed836a353 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_01/TestComponent.ir.txt @@ -0,0 +1,20 @@ +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 + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + 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 + CSharpCode - (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) - CSharp - #if true }\n + CSharpCode - (17:1,2 [9] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (17:1,2 [9] x:\dir\subdir\Test\TestComponent.razor) - CSharp - #endif } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_01/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_01/TestComponent.mappings.txt new file mode 100644 index 00000000000..7838fb06523 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_01/TestComponent.mappings.txt @@ -0,0 +1,12 @@ +Source Location: (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) +| #if true } +| +Generated Location: (986:28,2 [13] ) +| #if true } +| + +Source Location: (17:1,2 [9] x:\dir\subdir\Test\TestComponent.razor) +| #endif }| +Generated Location: (1120:35,2 [9] ) +| #endif }| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_02/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_02/TestComponent.codegen.cs new file mode 100644 index 00000000000..edb7b50d9e3 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_02/TestComponent.codegen.cs @@ -0,0 +1,47 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #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) + { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.razor" + +/* test */ #if true + +#line default +#line hidden +#nullable disable +#nullable restore +#line 4 "x:\dir\subdir\Test\TestComponent.razor" + +/* test */ #endif + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_02/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_02/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..dcc476581b2 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_02/TestComponent.diagnostics.txt @@ -0,0 +1,2 @@ +x:\dir\subdir\Test\TestComponent.razor(2,12): Error RZ1043: C# preprocessor directives must be at the start of the line, except for whitespace. +x:\dir\subdir\Test\TestComponent.razor(5,12): Error RZ1043: C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_02/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_02/TestComponent.ir.txt new file mode 100644 index 00000000000..1d84332d429 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_02/TestComponent.ir.txt @@ -0,0 +1,20 @@ +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 + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + 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 + CSharpCode - (2:0,2 [23] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [23] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n/* test */ #if true\n + CSharpCode - (30:3,2 [21] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (30:3,2 [21] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n/* test */ #endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_02/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_02/TestComponent.mappings.txt new file mode 100644 index 00000000000..1c39848192d --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_02/TestComponent.mappings.txt @@ -0,0 +1,18 @@ +Source Location: (2:0,2 [23] x:\dir\subdir\Test\TestComponent.razor) +| +/* test */ #if true +| +Generated Location: (986:28,2 [23] ) +| +/* test */ #if true +| + +Source Location: (30:3,2 [21] x:\dir\subdir\Test\TestComponent.razor) +| +/* test */ #endif +| +Generated Location: (1130:36,2 [21] ) +| +/* test */ #endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_03/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_03/TestComponent.codegen.cs new file mode 100644 index 00000000000..a03adf625fc --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_03/TestComponent.codegen.cs @@ -0,0 +1,48 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #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) + { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.razor" + +#pragma warning disable 219 +var x = 1; #if true + +#line default +#line hidden +#nullable disable +#nullable restore +#line 5 "x:\dir\subdir\Test\TestComponent.razor" + +var y = 2; #endif + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_03/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_03/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..6de12f462d9 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_03/TestComponent.diagnostics.txt @@ -0,0 +1,2 @@ +x:\dir\subdir\Test\TestComponent.razor(3,12): Error RZ1043: C# preprocessor directives must be at the start of the line, except for whitespace. +x:\dir\subdir\Test\TestComponent.razor(6,12): Error RZ1043: C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_03/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_03/TestComponent.ir.txt new file mode 100644 index 00000000000..f204c8c132d --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_03/TestComponent.ir.txt @@ -0,0 +1,20 @@ +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 + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + 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 + CSharpCode - (2:0,2 [52] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [52] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#pragma warning disable 219\nvar x = 1; #if true\n + CSharpCode - (59:4,2 [21] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (59:4,2 [21] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \nvar y = 2; #endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_03/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_03/TestComponent.mappings.txt new file mode 100644 index 00000000000..c14b49d007d --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_03/TestComponent.mappings.txt @@ -0,0 +1,20 @@ +Source Location: (2:0,2 [52] x:\dir\subdir\Test\TestComponent.razor) +| +#pragma warning disable 219 +var x = 1; #if true +| +Generated Location: (986:28,2 [52] ) +| +#pragma warning disable 219 +var x = 1; #if true +| + +Source Location: (59:4,2 [21] x:\dir\subdir\Test\TestComponent.razor) +| +var y = 2; #endif +| +Generated Location: (1159:37,2 [21] ) +| +var y = 2; #endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_04/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_04/TestComponent.codegen.cs new file mode 100644 index 00000000000..49dca9ea6d1 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_04/TestComponent.codegen.cs @@ -0,0 +1,47 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #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) + { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.razor" + +var x = #if true; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 4 "x:\dir\subdir\Test\TestComponent.razor" + +x #endif; + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_04/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_04/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..a09c47e3599 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_04/TestComponent.diagnostics.txt @@ -0,0 +1,2 @@ +x:\dir\subdir\Test\TestComponent.razor(2,9): Error RZ1043: C# preprocessor directives must be at the start of the line, except for whitespace. +x:\dir\subdir\Test\TestComponent.razor(5,3): Error RZ1043: C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_04/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_04/TestComponent.ir.txt new file mode 100644 index 00000000000..910d6a080f9 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_04/TestComponent.ir.txt @@ -0,0 +1,20 @@ +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 + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + 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 + CSharpCode - (2:0,2 [21] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [21] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \nvar x = #if true;\n + CSharpCode - (28:3,2 [13] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (28:3,2 [13] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \nx #endif;\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_04/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_04/TestComponent.mappings.txt new file mode 100644 index 00000000000..8391296cbf0 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_04/TestComponent.mappings.txt @@ -0,0 +1,18 @@ +Source Location: (2:0,2 [21] x:\dir\subdir\Test\TestComponent.razor) +| +var x = #if true; +| +Generated Location: (986:28,2 [21] ) +| +var x = #if true; +| + +Source Location: (28:3,2 [13] x:\dir\subdir\Test\TestComponent.razor) +| +x #endif; +| +Generated Location: (1128:36,2 [13] ) +| +x #endif; +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_05/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_05/TestComponent.codegen.cs new file mode 100644 index 00000000000..42c6a1923df --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_05/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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #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 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_05/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_05/TestComponent.ir.txt new file mode 100644 index 00000000000..ffff14e63e4 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_05/TestComponent.ir.txt @@ -0,0 +1,30 @@ +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 + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + 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 + CSharpCode - (2:0,2 [2] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [2] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n + MarkupElement - (4:1,0 [19] x:\dir\subdir\Test\TestComponent.razor) - div + HtmlContent - (9:1,5 [8] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (9:1,5 [8] x:\dir\subdir\Test\TestComponent.razor) - Html - #if true + CSharpCode - (23:1,19 [2] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (23:1,19 [2] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n + CSharpCode - (30:3,2 [2] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (30:3,2 [2] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n + MarkupElement - (32:4,0 [17] x:\dir\subdir\Test\TestComponent.razor) - div + HtmlContent - (37:4,5 [6] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (37:4,5 [6] x:\dir\subdir\Test\TestComponent.razor) - Html - #endif + CSharpCode - (49:4,17 [2] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (49:4,17 [2] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_05/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_05/TestComponent.mappings.txt new file mode 100644 index 00000000000..183e10af207 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_05/TestComponent.mappings.txt @@ -0,0 +1,28 @@ +Source Location: (2:0,2 [2] x:\dir\subdir\Test\TestComponent.razor) +| +| +Generated Location: (917:26,2 [2] ) +| +| + +Source Location: (23:1,19 [2] x:\dir\subdir\Test\TestComponent.razor) +| +| +Generated Location: (940:28,19 [2] ) +| +| + +Source Location: (30:3,2 [2] x:\dir\subdir\Test\TestComponent.razor) +| +| +Generated Location: (946:30,2 [2] ) +| +| + +Source Location: (49:4,17 [2] x:\dir\subdir\Test\TestComponent.razor) +| +| +Generated Location: (967:32,17 [2] ) +| +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_06/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_06/TestComponent.codegen.cs new file mode 100644 index 00000000000..94fc45e7c01 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_06/TestComponent.codegen.cs @@ -0,0 +1,47 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #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) + { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.razor" + + #if true + +#line default +#line hidden +#nullable disable +#nullable restore +#line 4 "x:\dir\subdir\Test\TestComponent.razor" + + #endif + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_06/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_06/TestComponent.ir.txt new file mode 100644 index 00000000000..1d780c999d9 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_06/TestComponent.ir.txt @@ -0,0 +1,20 @@ +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 + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + 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 + CSharpCode - (2:0,2 [16] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [16] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n #if true\n + CSharpCode - (23:3,2 [14] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (23:3,2 [14] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n #endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_06/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_06/TestComponent.mappings.txt new file mode 100644 index 00000000000..ce6ca81474b --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_06/TestComponent.mappings.txt @@ -0,0 +1,18 @@ +Source Location: (2:0,2 [16] x:\dir\subdir\Test\TestComponent.razor) +| + #if true +| +Generated Location: (986:28,2 [16] ) +| + #if true +| + +Source Location: (23:3,2 [14] x:\dir\subdir\Test\TestComponent.razor) +| + #endif +| +Generated Location: (1123:36,2 [14] ) +| + #endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_07/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_07/TestComponent.codegen.cs new file mode 100644 index 00000000000..80d4fbdda4f --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_07/TestComponent.codegen.cs @@ -0,0 +1,47 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #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) + { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.razor" + + #if true + +#line default +#line hidden +#nullable disable +#nullable restore +#line 4 "x:\dir\subdir\Test\TestComponent.razor" + + #endif + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_07/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_07/TestComponent.ir.txt new file mode 100644 index 00000000000..98194fc9a04 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_07/TestComponent.ir.txt @@ -0,0 +1,20 @@ +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 + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + 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 + CSharpCode - (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n #if true\n + CSharpCode - (20:3,2 [11] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (20:3,2 [11] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n #endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_07/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_07/TestComponent.mappings.txt new file mode 100644 index 00000000000..29c562ba298 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_07/TestComponent.mappings.txt @@ -0,0 +1,18 @@ +Source Location: (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) +| + #if true +| +Generated Location: (986:28,2 [13] ) +| + #if true +| + +Source Location: (20:3,2 [11] x:\dir\subdir\Test\TestComponent.razor) +| + #endif +| +Generated Location: (1120:36,2 [11] ) +| + #endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_08/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_08/TestComponent.codegen.cs new file mode 100644 index 00000000000..72ed1bdfbd0 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_08/TestComponent.codegen.cs @@ -0,0 +1,47 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #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) + { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.razor" + + #if true + +#line default +#line hidden +#nullable disable +#nullable restore +#line 4 "x:\dir\subdir\Test\TestComponent.razor" + + #endif + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_08/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_08/TestComponent.ir.txt new file mode 100644 index 00000000000..8244fbe10c0 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_08/TestComponent.ir.txt @@ -0,0 +1,20 @@ +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 + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + 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 + CSharpCode - (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n #if true\n + CSharpCode - (20:3,2 [11] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (20:3,2 [11] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n #endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_08/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_08/TestComponent.mappings.txt new file mode 100644 index 00000000000..ce5560674bc --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_08/TestComponent.mappings.txt @@ -0,0 +1,18 @@ +Source Location: (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) +| + #if true +| +Generated Location: (986:28,2 [13] ) +| + #if true +| + +Source Location: (20:3,2 [11] x:\dir\subdir\Test\TestComponent.razor) +| + #endif +| +Generated Location: (1120:36,2 [11] ) +| + #endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_09/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_09/TestComponent.codegen.cs new file mode 100644 index 00000000000..7e0ebf2640f --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_09/TestComponent.codegen.cs @@ -0,0 +1,47 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #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) + { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.razor" + + #if true + +#line default +#line hidden +#nullable disable +#nullable restore +#line 4 "x:\dir\subdir\Test\TestComponent.razor" + + #endif + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_09/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_09/TestComponent.ir.txt new file mode 100644 index 00000000000..0eaeefd504f --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_09/TestComponent.ir.txt @@ -0,0 +1,20 @@ +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 + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + 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 + CSharpCode - (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n #if true\n + CSharpCode - (20:3,2 [11] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (20:3,2 [11] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n #endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_09/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_09/TestComponent.mappings.txt new file mode 100644 index 00000000000..592b6e8123b --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_09/TestComponent.mappings.txt @@ -0,0 +1,18 @@ +Source Location: (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) +| + #if true +| +Generated Location: (986:28,2 [13] ) +| + #if true +| + +Source Location: (20:3,2 [11] x:\dir\subdir\Test\TestComponent.razor) +| + #endif +| +Generated Location: (1120:36,2 [11] ) +| + #endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_10/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_10/TestComponent.codegen.cs new file mode 100644 index 00000000000..d83115e7e7e --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_10/TestComponent.codegen.cs @@ -0,0 +1,47 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #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) + { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.razor" + + #if true + +#line default +#line hidden +#nullable disable +#nullable restore +#line 4 "x:\dir\subdir\Test\TestComponent.razor" + + #endif + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_10/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_10/TestComponent.ir.txt new file mode 100644 index 00000000000..d72229e802f --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_10/TestComponent.ir.txt @@ -0,0 +1,20 @@ +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 + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + 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 + CSharpCode - (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n #if true\n + CSharpCode - (20:3,2 [11] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (20:3,2 [11] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n #endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_10/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_10/TestComponent.mappings.txt new file mode 100644 index 00000000000..517205df2d8 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_10/TestComponent.mappings.txt @@ -0,0 +1,18 @@ +Source Location: (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) +| + #if true +| +Generated Location: (986:28,2 [13] ) +| + #if true +| + +Source Location: (20:3,2 [11] x:\dir\subdir\Test\TestComponent.razor) +| + #endif +| +Generated Location: (1120:36,2 [11] ) +| + #endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_11/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_11/TestComponent.codegen.cs new file mode 100644 index 00000000000..daaada0827c --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_11/TestComponent.codegen.cs @@ -0,0 +1,47 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #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) + { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.razor" + +#if true + +#line default +#line hidden +#nullable disable +#nullable restore +#line 4 "x:\dir\subdir\Test\TestComponent.razor" + +#endif + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_11/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_11/TestComponent.ir.txt new file mode 100644 index 00000000000..d0b53f8a00b --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_11/TestComponent.ir.txt @@ -0,0 +1,20 @@ +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 + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + 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 + CSharpCode - (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#if true\n + CSharpCode - (20:3,2 [11] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (20:3,2 [11] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_11/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_11/TestComponent.mappings.txt new file mode 100644 index 00000000000..af59ae9a61b --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimePreprocessorDirectiveTest/StartOfLine_11/TestComponent.mappings.txt @@ -0,0 +1,18 @@ +Source Location: (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) +| +#if true +| +Generated Location: (986:28,2 [13] ) +| +#if true +| + +Source Location: (20:3,2 [11] x:\dir\subdir\Test\TestComponent.razor) +| +#endif +| +Generated Location: (1120:36,2 [11] ) +| +#endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/AfterTag/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/AfterTag/TestComponent.codegen.cs new file mode 100644 index 00000000000..9613e830339 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/AfterTag/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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenElement(0, "div"); + __builder.AddMarkupContent(1, "\r\n#if true\r\n "); + __builder.OpenElement(2, "div"); + __builder.AddMarkupContent(3, "\r\n}\r\n"); +#nullable restore +#line (6,3)-(8,1) "x:\dir\subdir\Test\TestComponent.razor" + +#endif + +#line default +#line hidden +#nullable disable + + __builder.CloseElement(); + __builder.CloseElement(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/AfterTag/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/AfterTag/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..39bfbdef6f6 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/AfterTag/TestComponent.diagnostics.txt @@ -0,0 +1,4 @@ +x:\dir\subdir\Test\TestComponent.razor(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +x:\dir\subdir\Test\TestComponent.razor(2,5): Error RZ9980: Unclosed tag 'div' with no matching end tag. +x:\dir\subdir\Test\TestComponent.razor(2,6): Error RZ1025: The "div" element was not closed. All elements must be either self-closing or have a matching end tag. +x:\dir\subdir\Test\TestComponent.razor(4,5): Error RZ9980: Unclosed tag 'div' with no matching end tag. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/AfterTag/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/AfterTag/TestComponent.ir.txt new file mode 100644 index 00000000000..186b30ac122 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/AfterTag/TestComponent.ir.txt @@ -0,0 +1,21 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [22] ) - global::System + UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [27] ) - global::System.Linq + UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - (2:0,2 [2] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [2] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n + MarkupElement - (8:1,4 [44] x:\dir\subdir\Test\TestComponent.razor) - div + HtmlContent - (13:1,9 [16] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (13:1,9 [16] x:\dir\subdir\Test\TestComponent.razor) - Html - \n#if true\n + MarkupElement - (29:3,4 [23] x:\dir\subdir\Test\TestComponent.razor) - div + HtmlContent - (34:3,9 [5] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (34:3,9 [5] x:\dir\subdir\Test\TestComponent.razor) - Html - \n}\n + CSharpCode - (41:5,2 [10] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (41:5,2 [10] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#endif\n + CSharpCode - (52:7,1 [0] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (52:7,1 [0] x:\dir\subdir\Test\TestComponent.razor) - CSharp - diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/AfterTag/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/AfterTag/TestComponent.mappings.txt new file mode 100644 index 00000000000..01c3cd890a1 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/AfterTag/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (41:5,2 [10] x:\dir\subdir\Test\TestComponent.razor) +| +#endif +| +Generated Location: (950:25,0 [10] ) +| +#endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/DefineAndUndef/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/DefineAndUndef/TestComponent.codegen.cs new file mode 100644 index 00000000000..6a97aed820c --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/DefineAndUndef/TestComponent.codegen.cs @@ -0,0 +1,34 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line (1,3)-(4,1) "x:\dir\subdir\Test\TestComponent.razor" + +#define SomeSymbol +#undef SomeSymbol + +#line default +#line hidden +#nullable disable + + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/DefineAndUndef/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/DefineAndUndef/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..81e184a8cb9 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/DefineAndUndef/TestComponent.diagnostics.txt @@ -0,0 +1,2 @@ +x:\dir\subdir\Test\TestComponent.razor(2,1): Error RZ1042: '#define' and '#undef' cannot be used in razor markup. +x:\dir\subdir\Test\TestComponent.razor(3,1): Error RZ1042: '#define' and '#undef' cannot be used in razor markup. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/DefineAndUndef/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/DefineAndUndef/TestComponent.ir.txt new file mode 100644 index 00000000000..1462fdf0a9c --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/DefineAndUndef/TestComponent.ir.txt @@ -0,0 +1,11 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [22] ) - global::System + UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [27] ) - global::System.Linq + UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - (2:0,2 [41] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [41] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#define SomeSymbol\n#undef SomeSymbol\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/DefineAndUndef/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/DefineAndUndef/TestComponent.mappings.txt new file mode 100644 index 00000000000..0854d1e069e --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/DefineAndUndef/TestComponent.mappings.txt @@ -0,0 +1,11 @@ +Source Location: (2:0,2 [41] x:\dir\subdir\Test\TestComponent.razor) +| +#define SomeSymbol +#undef SomeSymbol +| +Generated Location: (733:21,0 [41] ) +| +#define SomeSymbol +#undef SomeSymbol +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/DisabledText_01/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/DisabledText_01/TestComponent.codegen.cs new file mode 100644 index 00000000000..5568a7f490d --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/DisabledText_01/TestComponent.codegen.cs @@ -0,0 +1,35 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line (1,3)-(5,1) "x:\dir\subdir\Test\TestComponent.razor" + +#if false +

Some text

+#endif + +#line default +#line hidden +#nullable disable + + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/DisabledText_01/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/DisabledText_01/TestComponent.ir.txt new file mode 100644 index 00000000000..1ecf1ca0ae7 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/DisabledText_01/TestComponent.ir.txt @@ -0,0 +1,11 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [22] ) - global::System + UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [27] ) - global::System.Linq + UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - (2:0,2 [43] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [43] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#if false\n

Some text

\n#endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/DisabledText_01/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/DisabledText_01/TestComponent.mappings.txt new file mode 100644 index 00000000000..ffbabab12a7 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/DisabledText_01/TestComponent.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (2:0,2 [43] x:\dir\subdir\Test\TestComponent.razor) +| +#if false +

Some text

+#endif +| +Generated Location: (733:21,0 [43] ) +| +#if false +

Some text

+#endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/IfDefAndPragma/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/IfDefAndPragma/TestComponent.codegen.cs new file mode 100644 index 00000000000..50ddb6130fd --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/IfDefAndPragma/TestComponent.codegen.cs @@ -0,0 +1,36 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line (1,3)-(6,1) "x:\dir\subdir\Test\TestComponent.razor" + +#pragma warning disable 219 // variable declared but not used +#if true + var x = 1; +#endif + +#line default +#line hidden +#nullable disable + + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/IfDefAndPragma/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/IfDefAndPragma/TestComponent.ir.txt new file mode 100644 index 00000000000..f6b185b6770 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/IfDefAndPragma/TestComponent.ir.txt @@ -0,0 +1,11 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [22] ) - global::System + UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [27] ) - global::System.Linq + UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - (2:0,2 [99] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [99] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#pragma warning disable 219 // variable declared but not used\n#if true\n var x = 1;\n#endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/IfDefAndPragma/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/IfDefAndPragma/TestComponent.mappings.txt new file mode 100644 index 00000000000..489aba5e808 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/IfDefAndPragma/TestComponent.mappings.txt @@ -0,0 +1,15 @@ +Source Location: (2:0,2 [99] x:\dir\subdir\Test\TestComponent.razor) +| +#pragma warning disable 219 // variable declared but not used +#if true + var x = 1; +#endif +| +Generated Location: (733:21,0 [99] ) +| +#pragma warning disable 219 // variable declared but not used +#if true + var x = 1; +#endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_01/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_01/TestComponent.codegen.cs new file mode 100644 index 00000000000..2cf10985bc2 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_01/TestComponent.codegen.cs @@ -0,0 +1,35 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line (1,3)-(4,12) "x:\dir\subdir\Test\TestComponent.razor" + +#if false +} +@{ #endif } + +#line default +#line hidden +#nullable disable + + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_01/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_01/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..3e562b47dce --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_01/TestComponent.diagnostics.txt @@ -0,0 +1,2 @@ +x:\dir\subdir\Test\TestComponent.razor(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(4,4): Warning RZ1044: Possible C# preprocessor directive is misplaced. C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_01/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_01/TestComponent.ir.txt new file mode 100644 index 00000000000..7eae833c8a7 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_01/TestComponent.ir.txt @@ -0,0 +1,11 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [22] ) - global::System + UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [27] ) - global::System.Linq + UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - (2:0,2 [27] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [27] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#if false\n}\n@{ #endif } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_01/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_01/TestComponent.mappings.txt new file mode 100644 index 00000000000..43cc84b0f22 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_01/TestComponent.mappings.txt @@ -0,0 +1,11 @@ +Source Location: (2:0,2 [27] x:\dir\subdir\Test\TestComponent.razor) +| +#if false +} +@{ #endif }| +Generated Location: (734:21,0 [27] ) +| +#if false +} +@{ #endif }| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_02/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_02/TestComponent.codegen.cs new file mode 100644 index 00000000000..ac2513aaaf9 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_02/TestComponent.codegen.cs @@ -0,0 +1,35 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line (1,3)-(4,17) "x:\dir\subdir\Test\TestComponent.razor" + +#if false +} +@{ Test #endif } + +#line default +#line hidden +#nullable disable + + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_02/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_02/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..795fd53013a --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_02/TestComponent.diagnostics.txt @@ -0,0 +1,2 @@ +x:\dir\subdir\Test\TestComponent.razor(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(4,9): Warning RZ1044: Possible C# preprocessor directive is misplaced. C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_02/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_02/TestComponent.ir.txt new file mode 100644 index 00000000000..e2ad2dfaa46 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_02/TestComponent.ir.txt @@ -0,0 +1,11 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [22] ) - global::System + UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [27] ) - global::System.Linq + UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - (2:0,2 [32] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [32] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#if false\n}\n@{ Test #endif } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_02/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_02/TestComponent.mappings.txt new file mode 100644 index 00000000000..b7de6df6b30 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_02/TestComponent.mappings.txt @@ -0,0 +1,11 @@ +Source Location: (2:0,2 [32] x:\dir\subdir\Test\TestComponent.razor) +| +#if false +} +@{ Test #endif }| +Generated Location: (734:21,0 [32] ) +| +#if false +} +@{ Test #endif }| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_03/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_03/TestComponent.codegen.cs new file mode 100644 index 00000000000..6b7ca7766df --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_03/TestComponent.codegen.cs @@ -0,0 +1,37 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line (1,3)-(6,2) "x:\dir\subdir\Test\TestComponent.razor" + +#if false +} +@{ +/* test */ #endif +} + +#line default +#line hidden +#nullable disable + + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_03/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_03/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..9ec9ceea358 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_03/TestComponent.diagnostics.txt @@ -0,0 +1,2 @@ +x:\dir\subdir\Test\TestComponent.razor(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(5,12): Warning RZ1044: Possible C# preprocessor directive is misplaced. C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_03/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_03/TestComponent.ir.txt new file mode 100644 index 00000000000..31c3f899f5c --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_03/TestComponent.ir.txt @@ -0,0 +1,11 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [22] ) - global::System + UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [27] ) - global::System.Linq + UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - (2:0,2 [40] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [40] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#if false\n}\n@{\n/* test */ #endif\n} diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_03/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_03/TestComponent.mappings.txt new file mode 100644 index 00000000000..f36f5d6f500 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_03/TestComponent.mappings.txt @@ -0,0 +1,15 @@ +Source Location: (2:0,2 [40] x:\dir\subdir\Test\TestComponent.razor) +| +#if false +} +@{ +/* test */ #endif +}| +Generated Location: (733:21,0 [40] ) +| +#if false +} +@{ +/* test */ #endif +}| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_04/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_04/TestComponent.codegen.cs new file mode 100644 index 00000000000..6b7ca7766df --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_04/TestComponent.codegen.cs @@ -0,0 +1,37 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line (1,3)-(6,2) "x:\dir\subdir\Test\TestComponent.razor" + +#if false +} +@{ +/* test */ #endif +} + +#line default +#line hidden +#nullable disable + + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_04/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_04/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..9ec9ceea358 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_04/TestComponent.diagnostics.txt @@ -0,0 +1,2 @@ +x:\dir\subdir\Test\TestComponent.razor(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(5,12): Warning RZ1044: Possible C# preprocessor directive is misplaced. C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_04/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_04/TestComponent.ir.txt new file mode 100644 index 00000000000..31c3f899f5c --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_04/TestComponent.ir.txt @@ -0,0 +1,11 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [22] ) - global::System + UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [27] ) - global::System.Linq + UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - (2:0,2 [40] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [40] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#if false\n}\n@{\n/* test */ #endif\n} diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_04/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_04/TestComponent.mappings.txt new file mode 100644 index 00000000000..f36f5d6f500 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_04/TestComponent.mappings.txt @@ -0,0 +1,15 @@ +Source Location: (2:0,2 [40] x:\dir\subdir\Test\TestComponent.razor) +| +#if false +} +@{ +/* test */ #endif +}| +Generated Location: (733:21,0 [40] ) +| +#if false +} +@{ +/* test */ #endif +}| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_05/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_05/TestComponent.codegen.cs new file mode 100644 index 00000000000..eb224d3fd6e --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_05/TestComponent.codegen.cs @@ -0,0 +1,37 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line (1,3)-(6,2) "x:\dir\subdir\Test\TestComponent.razor" + +#if false +} +@{ +
#endif
+} + +#line default +#line hidden +#nullable disable + + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_05/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_05/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..8cace6a0b73 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_05/TestComponent.diagnostics.txt @@ -0,0 +1,2 @@ +x:\dir\subdir\Test\TestComponent.razor(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(5,6): Warning RZ1044: Possible C# preprocessor directive is misplaced. C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_05/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_05/TestComponent.ir.txt new file mode 100644 index 00000000000..6be3cef0d86 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_05/TestComponent.ir.txt @@ -0,0 +1,11 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [22] ) - global::System + UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [27] ) - global::System.Linq + UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - (2:0,2 [40] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [40] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#if false\n}\n@{\n
#endif
\n} diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_05/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_05/TestComponent.mappings.txt new file mode 100644 index 00000000000..a52ce5c7e6f --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_05/TestComponent.mappings.txt @@ -0,0 +1,15 @@ +Source Location: (2:0,2 [40] x:\dir\subdir\Test\TestComponent.razor) +| +#if false +} +@{ +
#endif
+}| +Generated Location: (733:21,0 [40] ) +| +#if false +} +@{ +
#endif
+}| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_06/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_06/TestComponent.codegen.cs new file mode 100644 index 00000000000..834e98a511f --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_06/TestComponent.codegen.cs @@ -0,0 +1,37 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line (1,3)-(7,1) "x:\dir\subdir\Test\TestComponent.razor" + +#if false +} +@{ #else } +@{ +#endif + +#line default +#line hidden +#nullable disable + + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_06/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_06/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..e769081ec2d --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_06/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +(4,4): Warning RZ1044: Possible C# preprocessor directive is misplaced. C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_06/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_06/TestComponent.ir.txt new file mode 100644 index 00000000000..316a30d5518 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_06/TestComponent.ir.txt @@ -0,0 +1,11 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [22] ) - global::System + UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [27] ) - global::System.Linq + UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - (2:0,2 [40] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [40] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#if false\n}\n@{ #else }\n@{\n#endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_06/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_06/TestComponent.mappings.txt new file mode 100644 index 00000000000..b72da18fca7 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_06/TestComponent.mappings.txt @@ -0,0 +1,17 @@ +Source Location: (2:0,2 [40] x:\dir\subdir\Test\TestComponent.razor) +| +#if false +} +@{ #else } +@{ +#endif +| +Generated Location: (733:21,0 [40] ) +| +#if false +} +@{ #else } +@{ +#endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_07/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_07/TestComponent.codegen.cs new file mode 100644 index 00000000000..014a01a24a7 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_07/TestComponent.codegen.cs @@ -0,0 +1,37 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line (1,3)-(7,1) "x:\dir\subdir\Test\TestComponent.razor" + +#if false +} +@{ Test #else } +@{ +#endif + +#line default +#line hidden +#nullable disable + + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_07/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_07/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..9db7a3b206f --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_07/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +(4,9): Warning RZ1044: Possible C# preprocessor directive is misplaced. C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_07/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_07/TestComponent.ir.txt new file mode 100644 index 00000000000..90e8d9a6750 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_07/TestComponent.ir.txt @@ -0,0 +1,11 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [22] ) - global::System + UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [27] ) - global::System.Linq + UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - (2:0,2 [45] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [45] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#if false\n}\n@{ Test #else }\n@{\n#endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_07/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_07/TestComponent.mappings.txt new file mode 100644 index 00000000000..3a5b52af815 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_07/TestComponent.mappings.txt @@ -0,0 +1,17 @@ +Source Location: (2:0,2 [45] x:\dir\subdir\Test\TestComponent.razor) +| +#if false +} +@{ Test #else } +@{ +#endif +| +Generated Location: (733:21,0 [45] ) +| +#if false +} +@{ Test #else } +@{ +#endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_08/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_08/TestComponent.codegen.cs new file mode 100644 index 00000000000..e7c8942510b --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_08/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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line (1,3)-(9,1) "x:\dir\subdir\Test\TestComponent.razor" + +#if false +} +@{ +/* test */ #else +} +@{ +#endif + +#line default +#line hidden +#nullable disable + + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_08/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_08/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..d07194cdc17 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_08/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +(5,12): Warning RZ1044: Possible C# preprocessor directive is misplaced. C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_08/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_08/TestComponent.ir.txt new file mode 100644 index 00000000000..b9ef95c30f1 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_08/TestComponent.ir.txt @@ -0,0 +1,11 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [22] ) - global::System + UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [27] ) - global::System.Linq + UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - (2:0,2 [53] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [53] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#if false\n}\n@{\n/* test */ #else\n}\n@{\n#endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_08/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_08/TestComponent.mappings.txt new file mode 100644 index 00000000000..65438e0a422 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_08/TestComponent.mappings.txt @@ -0,0 +1,21 @@ +Source Location: (2:0,2 [53] x:\dir\subdir\Test\TestComponent.razor) +| +#if false +} +@{ +/* test */ #else +} +@{ +#endif +| +Generated Location: (733:21,0 [53] ) +| +#if false +} +@{ +/* test */ #else +} +@{ +#endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_09/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_09/TestComponent.codegen.cs new file mode 100644 index 00000000000..e7c8942510b --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_09/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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line (1,3)-(9,1) "x:\dir\subdir\Test\TestComponent.razor" + +#if false +} +@{ +/* test */ #else +} +@{ +#endif + +#line default +#line hidden +#nullable disable + + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_09/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_09/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..d07194cdc17 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_09/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +(5,12): Warning RZ1044: Possible C# preprocessor directive is misplaced. C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_09/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_09/TestComponent.ir.txt new file mode 100644 index 00000000000..b9ef95c30f1 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_09/TestComponent.ir.txt @@ -0,0 +1,11 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [22] ) - global::System + UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [27] ) - global::System.Linq + UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - (2:0,2 [53] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [53] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#if false\n}\n@{\n/* test */ #else\n}\n@{\n#endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_09/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_09/TestComponent.mappings.txt new file mode 100644 index 00000000000..65438e0a422 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_09/TestComponent.mappings.txt @@ -0,0 +1,21 @@ +Source Location: (2:0,2 [53] x:\dir\subdir\Test\TestComponent.razor) +| +#if false +} +@{ +/* test */ #else +} +@{ +#endif +| +Generated Location: (733:21,0 [53] ) +| +#if false +} +@{ +/* test */ #else +} +@{ +#endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_10/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_10/TestComponent.codegen.cs new file mode 100644 index 00000000000..b2926415380 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_10/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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line (1,3)-(9,1) "x:\dir\subdir\Test\TestComponent.razor" + +#if false +} +@{ +
#else
+} +@{ +#endif + +#line default +#line hidden +#nullable disable + + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_10/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_10/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..bf174dea560 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_10/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +(5,6): Warning RZ1044: Possible C# preprocessor directive is misplaced. C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_10/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_10/TestComponent.ir.txt new file mode 100644 index 00000000000..91895f6af8a --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_10/TestComponent.ir.txt @@ -0,0 +1,11 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [22] ) - global::System + UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [27] ) - global::System.Linq + UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - (2:0,2 [53] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [53] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#if false\n}\n@{\n
#else
\n}\n@{\n#endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_10/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_10/TestComponent.mappings.txt new file mode 100644 index 00000000000..b8bdbffc560 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/MisplacedEndingDirective_10/TestComponent.mappings.txt @@ -0,0 +1,21 @@ +Source Location: (2:0,2 [53] x:\dir\subdir\Test\TestComponent.razor) +| +#if false +} +@{ +
#else
+} +@{ +#endif +| +Generated Location: (733:21,0 [53] ) +| +#if false +} +@{ +
#else
+} +@{ +#endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/PassParseOptionsThrough_01/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/PassParseOptionsThrough_01/TestComponent.codegen.cs new file mode 100644 index 00000000000..e4fcc29928b --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/PassParseOptionsThrough_01/TestComponent.codegen.cs @@ -0,0 +1,42 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line (1,3)-(3,1) "x:\dir\subdir\Test\TestComponent.razor" + +#if SomeSymbol + +#line default +#line hidden +#nullable disable + + __builder.AddMarkupContent(0, "

Some text

"); +#nullable restore +#line (4,1)-(5,1) "x:\dir\subdir\Test\TestComponent.razor" +#endif + +#line default +#line hidden +#nullable disable + + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/PassParseOptionsThrough_01/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/PassParseOptionsThrough_01/TestComponent.ir.txt new file mode 100644 index 00000000000..0d148ccbb3b --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/PassParseOptionsThrough_01/TestComponent.ir.txt @@ -0,0 +1,14 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [22] ) - global::System + UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [27] ) - global::System.Linq + UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - (2:0,2 [18] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [18] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#if SomeSymbol\n + MarkupBlock - -

Some text

+ CSharpCode - (42:3,0 [8] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (42:3,0 [8] x:\dir\subdir\Test\TestComponent.razor) - CSharp - #endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/PassParseOptionsThrough_01/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/PassParseOptionsThrough_01/TestComponent.mappings.txt new file mode 100644 index 00000000000..d46ad129417 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/PassParseOptionsThrough_01/TestComponent.mappings.txt @@ -0,0 +1,16 @@ +Source Location: (2:0,2 [18] x:\dir\subdir\Test\TestComponent.razor) +| +#if SomeSymbol +| +Generated Location: (733:21,0 [18] ) +| +#if SomeSymbol +| + +Source Location: (42:3,0 [8] x:\dir\subdir\Test\TestComponent.razor) +|#endif +| +Generated Location: (946:31,0 [8] ) +|#endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/PassParseOptionsThrough_02/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/PassParseOptionsThrough_02/TestComponent.codegen.cs new file mode 100644 index 00000000000..c9ba698b168 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/PassParseOptionsThrough_02/TestComponent.codegen.cs @@ -0,0 +1,35 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line (1,3)-(5,1) "x:\dir\subdir\Test\TestComponent.razor" + +#if !SomeSymbol +

Some text

+#endif + +#line default +#line hidden +#nullable disable + + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/PassParseOptionsThrough_02/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/PassParseOptionsThrough_02/TestComponent.ir.txt new file mode 100644 index 00000000000..075038c3ac4 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/PassParseOptionsThrough_02/TestComponent.ir.txt @@ -0,0 +1,11 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [22] ) - global::System + UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [27] ) - global::System.Linq + UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - (2:0,2 [49] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [49] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#if !SomeSymbol\n

Some text

\n#endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/PassParseOptionsThrough_02/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/PassParseOptionsThrough_02/TestComponent.mappings.txt new file mode 100644 index 00000000000..39078215500 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/PassParseOptionsThrough_02/TestComponent.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (2:0,2 [49] x:\dir\subdir\Test\TestComponent.razor) +| +#if !SomeSymbol +

Some text

+#endif +| +Generated Location: (733:21,0 [49] ) +| +#if !SomeSymbol +

Some text

+#endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/SimpleIfDef/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/SimpleIfDef/TestComponent.codegen.cs new file mode 100644 index 00000000000..20d5f19ac3b --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/SimpleIfDef/TestComponent.codegen.cs @@ -0,0 +1,36 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line (1,3)-(6,1) "x:\dir\subdir\Test\TestComponent.cshtml" + +#pragma warning disable 219 // variable declared but not used +#if true + var x = 1; +#endif + +#line default +#line hidden +#nullable disable + + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/SimpleIfDef/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/SimpleIfDef/TestComponent.ir.txt new file mode 100644 index 00000000000..e2d04e8a6c6 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/SimpleIfDef/TestComponent.ir.txt @@ -0,0 +1,11 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [22] ) - global::System + UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [27] ) - global::System.Linq + UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - (2:0,2 [99] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (2:0,2 [99] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n#pragma warning disable 219 // variable declared but not used\n#if true\n var x = 1;\n#endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/SimpleIfDef/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/SimpleIfDef/TestComponent.mappings.txt new file mode 100644 index 00000000000..a241e826801 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/SimpleIfDef/TestComponent.mappings.txt @@ -0,0 +1,15 @@ +Source Location: (2:0,2 [99] x:\dir\subdir\Test\TestComponent.cshtml) +| +#pragma warning disable 219 // variable declared but not used +#if true + var x = 1; +#endif +| +Generated Location: (734:21,0 [99] ) +| +#pragma warning disable 219 // variable declared but not used +#if true + var x = 1; +#endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_01/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_01/TestComponent.codegen.cs new file mode 100644 index 00000000000..9652333b2e7 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_01/TestComponent.codegen.cs @@ -0,0 +1,40 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line (1,3)-(2,1) "x:\dir\subdir\Test\TestComponent.razor" + #if true } + +#line default +#line hidden +#nullable disable + +#nullable restore +#line (2,3)-(2,12) "x:\dir\subdir\Test\TestComponent.razor" + #endif } + +#line default +#line hidden +#nullable disable + + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_01/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_01/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..ade23f6812a --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_01/TestComponent.diagnostics.txt @@ -0,0 +1,5 @@ +x:\dir\subdir\Test\TestComponent.razor(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +x:\dir\subdir\Test\TestComponent.razor(1,4): Error RZ1043: C# preprocessor directives must be at the start of the line, except for whitespace. +x:\dir\subdir\Test\TestComponent.razor(2,2): Error RZ1010: Unexpected "{" after "@" character. Once inside the body of a code block (@if {}, @{}, etc.) you do not need to use "@{" to switch to code. +x:\dir\subdir\Test\TestComponent.razor(2,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +x:\dir\subdir\Test\TestComponent.razor(2,4): Error RZ1043: C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_01/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_01/TestComponent.ir.txt new file mode 100644 index 00000000000..bce548ad9f9 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_01/TestComponent.ir.txt @@ -0,0 +1,13 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [22] ) - global::System + UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [27] ) - global::System.Linq + UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) - CSharp - #if true }\n + CSharpCode - (17:1,2 [9] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (17:1,2 [9] x:\dir\subdir\Test\TestComponent.razor) - CSharp - #endif } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_01/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_01/TestComponent.mappings.txt new file mode 100644 index 00000000000..161c58ca33b --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_01/TestComponent.mappings.txt @@ -0,0 +1,12 @@ +Source Location: (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) +| #if true } +| +Generated Location: (733:21,0 [13] ) +| #if true } +| + +Source Location: (17:1,2 [9] x:\dir\subdir\Test\TestComponent.razor) +| #endif }| +Generated Location: (878:29,0 [9] ) +| #endif }| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_02/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_02/TestComponent.codegen.cs new file mode 100644 index 00000000000..def2f0c3863 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_02/TestComponent.codegen.cs @@ -0,0 +1,42 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line (1,3)-(3,1) "x:\dir\subdir\Test\TestComponent.razor" + +/* test */ #if true + +#line default +#line hidden +#nullable disable + +#nullable restore +#line (4,3)-(6,1) "x:\dir\subdir\Test\TestComponent.razor" + +/* test */ #endif + +#line default +#line hidden +#nullable disable + + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_02/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_02/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..dcc476581b2 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_02/TestComponent.diagnostics.txt @@ -0,0 +1,2 @@ +x:\dir\subdir\Test\TestComponent.razor(2,12): Error RZ1043: C# preprocessor directives must be at the start of the line, except for whitespace. +x:\dir\subdir\Test\TestComponent.razor(5,12): Error RZ1043: C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_02/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_02/TestComponent.ir.txt new file mode 100644 index 00000000000..3c9fcaeedc0 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_02/TestComponent.ir.txt @@ -0,0 +1,13 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [22] ) - global::System + UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [27] ) - global::System.Linq + UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - (2:0,2 [23] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [23] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n/* test */ #if true\n + CSharpCode - (30:3,2 [21] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (30:3,2 [21] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n/* test */ #endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_02/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_02/TestComponent.mappings.txt new file mode 100644 index 00000000000..1824c4f5964 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_02/TestComponent.mappings.txt @@ -0,0 +1,18 @@ +Source Location: (2:0,2 [23] x:\dir\subdir\Test\TestComponent.razor) +| +/* test */ #if true +| +Generated Location: (733:21,0 [23] ) +| +/* test */ #if true +| + +Source Location: (30:3,2 [21] x:\dir\subdir\Test\TestComponent.razor) +| +/* test */ #endif +| +Generated Location: (887:30,0 [21] ) +| +/* test */ #endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_03/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_03/TestComponent.codegen.cs new file mode 100644 index 00000000000..2053d765d2d --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_03/TestComponent.codegen.cs @@ -0,0 +1,43 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line (1,3)-(4,1) "x:\dir\subdir\Test\TestComponent.razor" + +#pragma warning disable 219 +var x = 1; #if true + +#line default +#line hidden +#nullable disable + +#nullable restore +#line (5,3)-(7,1) "x:\dir\subdir\Test\TestComponent.razor" + +var y = 2; #endif + +#line default +#line hidden +#nullable disable + + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_03/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_03/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..6de12f462d9 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_03/TestComponent.diagnostics.txt @@ -0,0 +1,2 @@ +x:\dir\subdir\Test\TestComponent.razor(3,12): Error RZ1043: C# preprocessor directives must be at the start of the line, except for whitespace. +x:\dir\subdir\Test\TestComponent.razor(6,12): Error RZ1043: C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_03/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_03/TestComponent.ir.txt new file mode 100644 index 00000000000..f1937989b55 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_03/TestComponent.ir.txt @@ -0,0 +1,13 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [22] ) - global::System + UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [27] ) - global::System.Linq + UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - (2:0,2 [52] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [52] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#pragma warning disable 219\nvar x = 1; #if true\n + CSharpCode - (59:4,2 [21] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (59:4,2 [21] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \nvar y = 2; #endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_03/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_03/TestComponent.mappings.txt new file mode 100644 index 00000000000..a866c00ca44 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_03/TestComponent.mappings.txt @@ -0,0 +1,20 @@ +Source Location: (2:0,2 [52] x:\dir\subdir\Test\TestComponent.razor) +| +#pragma warning disable 219 +var x = 1; #if true +| +Generated Location: (733:21,0 [52] ) +| +#pragma warning disable 219 +var x = 1; #if true +| + +Source Location: (59:4,2 [21] x:\dir\subdir\Test\TestComponent.razor) +| +var y = 2; #endif +| +Generated Location: (916:31,0 [21] ) +| +var y = 2; #endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_04/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_04/TestComponent.codegen.cs new file mode 100644 index 00000000000..39097fea388 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_04/TestComponent.codegen.cs @@ -0,0 +1,42 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line (1,3)-(3,1) "x:\dir\subdir\Test\TestComponent.razor" + +var x = #if true; + +#line default +#line hidden +#nullable disable + +#nullable restore +#line (4,3)-(6,1) "x:\dir\subdir\Test\TestComponent.razor" + +x #endif; + +#line default +#line hidden +#nullable disable + + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_04/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_04/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..a09c47e3599 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_04/TestComponent.diagnostics.txt @@ -0,0 +1,2 @@ +x:\dir\subdir\Test\TestComponent.razor(2,9): Error RZ1043: C# preprocessor directives must be at the start of the line, except for whitespace. +x:\dir\subdir\Test\TestComponent.razor(5,3): Error RZ1043: C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_04/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_04/TestComponent.ir.txt new file mode 100644 index 00000000000..91597324ca3 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_04/TestComponent.ir.txt @@ -0,0 +1,13 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [22] ) - global::System + UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [27] ) - global::System.Linq + UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - (2:0,2 [21] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [21] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \nvar x = #if true;\n + CSharpCode - (28:3,2 [13] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (28:3,2 [13] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \nx #endif;\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_04/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_04/TestComponent.mappings.txt new file mode 100644 index 00000000000..ba6d1d7c4a6 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_04/TestComponent.mappings.txt @@ -0,0 +1,18 @@ +Source Location: (2:0,2 [21] x:\dir\subdir\Test\TestComponent.razor) +| +var x = #if true; +| +Generated Location: (733:21,0 [21] ) +| +var x = #if true; +| + +Source Location: (28:3,2 [13] x:\dir\subdir\Test\TestComponent.razor) +| +x #endif; +| +Generated Location: (885:30,0 [13] ) +| +x #endif; +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_05/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_05/TestComponent.codegen.cs new file mode 100644 index 00000000000..817ee0b2819 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_05/TestComponent.codegen.cs @@ -0,0 +1,26 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.AddMarkupContent(0, "
#if true
"); + __builder.AddMarkupContent(1, "
#endif
"); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_05/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_05/TestComponent.ir.txt new file mode 100644 index 00000000000..ca778d3c2a6 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_05/TestComponent.ir.txt @@ -0,0 +1,19 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [22] ) - global::System + UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [27] ) - global::System.Linq + UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - (2:0,2 [2] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [2] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n + MarkupBlock - -
#if true
+ CSharpCode - (25:2,0 [0] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (25:2,0 [0] x:\dir\subdir\Test\TestComponent.razor) - CSharp - + CSharpCode - (30:3,2 [2] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (30:3,2 [2] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n + MarkupBlock - -
#endif
+ CSharpCode - (51:5,0 [0] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (51:5,0 [0] x:\dir\subdir\Test\TestComponent.razor) - CSharp - diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_06/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_06/TestComponent.codegen.cs new file mode 100644 index 00000000000..348f0fbd367 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_06/TestComponent.codegen.cs @@ -0,0 +1,42 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line (1,3)-(3,1) "x:\dir\subdir\Test\TestComponent.razor" + + #if true + +#line default +#line hidden +#nullable disable + +#nullable restore +#line (4,3)-(6,1) "x:\dir\subdir\Test\TestComponent.razor" + + #endif + +#line default +#line hidden +#nullable disable + + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_06/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_06/TestComponent.ir.txt new file mode 100644 index 00000000000..8eb6874d305 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_06/TestComponent.ir.txt @@ -0,0 +1,13 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [22] ) - global::System + UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [27] ) - global::System.Linq + UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - (2:0,2 [16] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [16] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n #if true\n + CSharpCode - (23:3,2 [14] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (23:3,2 [14] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n #endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_06/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_06/TestComponent.mappings.txt new file mode 100644 index 00000000000..c7c3889d0dd --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_06/TestComponent.mappings.txt @@ -0,0 +1,18 @@ +Source Location: (2:0,2 [16] x:\dir\subdir\Test\TestComponent.razor) +| + #if true +| +Generated Location: (733:21,0 [16] ) +| + #if true +| + +Source Location: (23:3,2 [14] x:\dir\subdir\Test\TestComponent.razor) +| + #endif +| +Generated Location: (880:30,0 [14] ) +| + #endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_07/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_07/TestComponent.codegen.cs new file mode 100644 index 00000000000..644109899ab --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_07/TestComponent.codegen.cs @@ -0,0 +1,42 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line (1,3)-(3,1) "x:\dir\subdir\Test\TestComponent.razor" + + #if true + +#line default +#line hidden +#nullable disable + +#nullable restore +#line (4,3)-(6,1) "x:\dir\subdir\Test\TestComponent.razor" + + #endif + +#line default +#line hidden +#nullable disable + + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_07/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_07/TestComponent.ir.txt new file mode 100644 index 00000000000..9c602d9198a --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_07/TestComponent.ir.txt @@ -0,0 +1,13 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [22] ) - global::System + UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [27] ) - global::System.Linq + UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n #if true\n + CSharpCode - (20:3,2 [11] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (20:3,2 [11] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n #endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_07/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_07/TestComponent.mappings.txt new file mode 100644 index 00000000000..75ae62ff45b --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_07/TestComponent.mappings.txt @@ -0,0 +1,18 @@ +Source Location: (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) +| + #if true +| +Generated Location: (733:21,0 [13] ) +| + #if true +| + +Source Location: (20:3,2 [11] x:\dir\subdir\Test\TestComponent.razor) +| + #endif +| +Generated Location: (877:30,0 [11] ) +| + #endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_08/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_08/TestComponent.codegen.cs new file mode 100644 index 00000000000..d24b5e3ed3c --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_08/TestComponent.codegen.cs @@ -0,0 +1,42 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line (1,3)-(3,1) "x:\dir\subdir\Test\TestComponent.razor" + + #if true + +#line default +#line hidden +#nullable disable + +#nullable restore +#line (4,3)-(6,1) "x:\dir\subdir\Test\TestComponent.razor" + + #endif + +#line default +#line hidden +#nullable disable + + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_08/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_08/TestComponent.ir.txt new file mode 100644 index 00000000000..b18b7c73b1c --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_08/TestComponent.ir.txt @@ -0,0 +1,13 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [22] ) - global::System + UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [27] ) - global::System.Linq + UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n #if true\n + CSharpCode - (20:3,2 [11] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (20:3,2 [11] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n #endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_08/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_08/TestComponent.mappings.txt new file mode 100644 index 00000000000..c146d0ee00e --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_08/TestComponent.mappings.txt @@ -0,0 +1,18 @@ +Source Location: (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) +| + #if true +| +Generated Location: (733:21,0 [13] ) +| + #if true +| + +Source Location: (20:3,2 [11] x:\dir\subdir\Test\TestComponent.razor) +| + #endif +| +Generated Location: (877:30,0 [11] ) +| + #endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_09/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_09/TestComponent.codegen.cs new file mode 100644 index 00000000000..86e70a81f85 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_09/TestComponent.codegen.cs @@ -0,0 +1,42 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line (1,3)-(3,1) "x:\dir\subdir\Test\TestComponent.razor" + + #if true + +#line default +#line hidden +#nullable disable + +#nullable restore +#line (4,3)-(6,1) "x:\dir\subdir\Test\TestComponent.razor" + + #endif + +#line default +#line hidden +#nullable disable + + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_09/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_09/TestComponent.ir.txt new file mode 100644 index 00000000000..9335b08dd84 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_09/TestComponent.ir.txt @@ -0,0 +1,13 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [22] ) - global::System + UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [27] ) - global::System.Linq + UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n #if true\n + CSharpCode - (20:3,2 [11] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (20:3,2 [11] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n #endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_09/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_09/TestComponent.mappings.txt new file mode 100644 index 00000000000..737b2e28fa0 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_09/TestComponent.mappings.txt @@ -0,0 +1,18 @@ +Source Location: (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) +| + #if true +| +Generated Location: (733:21,0 [13] ) +| + #if true +| + +Source Location: (20:3,2 [11] x:\dir\subdir\Test\TestComponent.razor) +| + #endif +| +Generated Location: (877:30,0 [11] ) +| + #endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_10/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_10/TestComponent.codegen.cs new file mode 100644 index 00000000000..8830d18b6a7 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_10/TestComponent.codegen.cs @@ -0,0 +1,42 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line (1,3)-(3,1) "x:\dir\subdir\Test\TestComponent.razor" + + #if true + +#line default +#line hidden +#nullable disable + +#nullable restore +#line (4,3)-(6,1) "x:\dir\subdir\Test\TestComponent.razor" + + #endif + +#line default +#line hidden +#nullable disable + + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_10/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_10/TestComponent.ir.txt new file mode 100644 index 00000000000..b3f7754173e --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_10/TestComponent.ir.txt @@ -0,0 +1,13 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [22] ) - global::System + UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [27] ) - global::System.Linq + UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n #if true\n + CSharpCode - (20:3,2 [11] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (20:3,2 [11] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n #endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_10/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_10/TestComponent.mappings.txt new file mode 100644 index 00000000000..deb6998c322 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_10/TestComponent.mappings.txt @@ -0,0 +1,18 @@ +Source Location: (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) +| + #if true +| +Generated Location: (733:21,0 [13] ) +| + #if true +| + +Source Location: (20:3,2 [11] x:\dir\subdir\Test\TestComponent.razor) +| + #endif +| +Generated Location: (877:30,0 [11] ) +| + #endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_11/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_11/TestComponent.codegen.cs new file mode 100644 index 00000000000..a9c77e6b364 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_11/TestComponent.codegen.cs @@ -0,0 +1,42 @@ +// +#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 + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line (1,3)-(3,1) "x:\dir\subdir\Test\TestComponent.razor" + +#if true + +#line default +#line hidden +#nullable disable + +#nullable restore +#line (4,3)-(6,1) "x:\dir\subdir\Test\TestComponent.razor" + +#endif + +#line default +#line hidden +#nullable disable + + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_11/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_11/TestComponent.ir.txt new file mode 100644 index 00000000000..c50aed42b07 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_11/TestComponent.ir.txt @@ -0,0 +1,13 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [22] ) - global::System + UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [27] ) - global::System.Linq + UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#if true\n + CSharpCode - (20:3,2 [11] x:\dir\subdir\Test\TestComponent.razor) + LazyIntermediateToken - (20:3,2 [11] x:\dir\subdir\Test\TestComponent.razor) - CSharp - \n#endif\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_11/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_11/TestComponent.mappings.txt new file mode 100644 index 00000000000..594291e5e53 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimePreprocessorDirectiveTest/StartOfLine_11/TestComponent.mappings.txt @@ -0,0 +1,18 @@ +Source Location: (2:0,2 [13] x:\dir\subdir\Test\TestComponent.razor) +| +#if true +| +Generated Location: (733:21,0 [13] ) +| +#if true +| + +Source Location: (20:3,2 [11] x:\dir\subdir\Test\TestComponent.razor) +| +#endif +| +Generated Location: (877:30,0 [11] ) +| +#endif +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/Usings.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/Usings.cspans.txt new file mode 100644 index 00000000000..99a22954242 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/Usings.cspans.txt @@ -0,0 +1,16 @@ +Markup span at (0:0,0 [3] ) - Parent: Markup block at (0:0,0 [185] ) +Transition span at (3:1,0 [1] ) - Parent: Directive block at (3:1,0 [23] ) +Code span at (4:1,1 [22] ) - Parent: Directive block at (3:1,0 [23] ) +Markup span at (26:2,0 [0] ) - Parent: Markup block at (0:0,0 [185] ) +Transition span at (26:2,0 [1] ) - Parent: Directive block at (26:2,0 [43] ) +Code span at (27:2,1 [42] ) - Parent: Directive block at (26:2,0 [43] ) +Markup span at (69:3,0 [0] ) - Parent: Markup block at (0:0,0 [185] ) +Transition span at (69:3,0 [1] ) - Parent: Directive block at (69:3,0 [28] ) +Code span at (70:3,1 [27] ) - Parent: Directive block at (69:3,0 [28] ) +Markup span at (97:4,0 [0] ) - Parent: Markup block at (0:0,0 [185] ) +Transition span at (97:4,0 [1] ) - Parent: Directive block at (97:4,0 [39] ) +Code span at (98:4,1 [38] ) - Parent: Directive block at (97:4,0 [39] ) +Markup span at (136:5,0 [0] ) - Parent: Markup block at (0:0,0 [185] ) +Transition span at (136:5,0 [1] ) - Parent: Directive block at (136:5,0 [48] ) +Code span at (137:5,1 [47] ) - Parent: Directive block at (136:5,0 [48] ) +Markup span at (184:6,0 [1] ) - Parent: Markup block at (0:0,0 [185] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/Usings.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/Usings.stree.txt new file mode 100644 index 00000000000..447016add4e --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/Usings.stree.txt @@ -0,0 +1,90 @@ +RazorDocument - [0..185)::185 - [{LF@using global::SystemLF@using global::System.Collections.GenericLF@using global::System.LinqLF@using global::System.Threading.TasksLF@using global::Microsoft.AspNetCore.ComponentsLF}] + MarkupBlock - [0..185)::185 + MarkupTextLiteral - [0..3)::3 - [{LF] - Gen + Text;[{]; + NewLine;[LF]; + CSharpCodeBlock - [3..26)::23 + RazorDirective - [3..26)::23 + CSharpTransition - [3..4)::1 - Gen + Transition;[@]; + RazorDirectiveBody - [4..26)::22 + CSharpStatementLiteral - [4..26)::22 - [using global::SystemLF] - Gen + Keyword;[using]; + Whitespace;[ ]; + Keyword;[global]; + DoubleColon;[::]; + Identifier;[System]; + NewLine;[LF]; + MarkupTextLiteral - [26..26)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [26..69)::43 + RazorDirective - [26..69)::43 + CSharpTransition - [26..27)::1 - Gen + Transition;[@]; + RazorDirectiveBody - [27..69)::42 + CSharpStatementLiteral - [27..69)::42 - [using global::System.Collections.GenericLF] - Gen + Keyword;[using]; + Whitespace;[ ]; + Keyword;[global]; + DoubleColon;[::]; + Identifier;[System]; + Dot;[.]; + Identifier;[Collections]; + Dot;[.]; + Identifier;[Generic]; + NewLine;[LF]; + MarkupTextLiteral - [69..69)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [69..97)::28 + RazorDirective - [69..97)::28 + CSharpTransition - [69..70)::1 - Gen + Transition;[@]; + RazorDirectiveBody - [70..97)::27 + CSharpStatementLiteral - [70..97)::27 - [using global::System.LinqLF] - Gen + Keyword;[using]; + Whitespace;[ ]; + Keyword;[global]; + DoubleColon;[::]; + Identifier;[System]; + Dot;[.]; + Identifier;[Linq]; + NewLine;[LF]; + MarkupTextLiteral - [97..97)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [97..136)::39 + RazorDirective - [97..136)::39 + CSharpTransition - [97..98)::1 - Gen + Transition;[@]; + RazorDirectiveBody - [98..136)::38 + CSharpStatementLiteral - [98..136)::38 - [using global::System.Threading.TasksLF] - Gen + Keyword;[using]; + Whitespace;[ ]; + Keyword;[global]; + DoubleColon;[::]; + Identifier;[System]; + Dot;[.]; + Identifier;[Threading]; + Dot;[.]; + Identifier;[Tasks]; + NewLine;[LF]; + MarkupTextLiteral - [136..136)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [136..184)::48 + RazorDirective - [136..184)::48 + CSharpTransition - [136..137)::1 - Gen + Transition;[@]; + RazorDirectiveBody - [137..184)::47 + CSharpStatementLiteral - [137..184)::47 - [using global::Microsoft.AspNetCore.ComponentsLF] - Gen + Keyword;[using]; + Whitespace;[ ]; + Keyword;[global]; + DoubleColon;[::]; + Identifier;[Microsoft]; + Dot;[.]; + Identifier;[AspNetCore]; + Dot;[.]; + Identifier;[Components]; + NewLine;[LF]; + MarkupTextLiteral - [184..185)::1 - [}] - Gen + Text;[}]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/DefineThenIfDef.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/DefineThenIfDef.cspans.txt new file mode 100644 index 00000000000..efde9d0ccc4 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/DefineThenIfDef.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [115] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [115] ) +MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [115] ) +Code span at (2:0,2 [112] ) - Parent: Statement block at (0:0,0 [115] ) +MetaCode span at (114:10,0 [1] ) - Parent: Statement block at (0:0,0 [115] ) +Markup span at (115:10,1 [0] ) - Parent: Markup block at (0:0,0 [115] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/DefineThenIfDef.diag.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/DefineThenIfDef.diag.txt new file mode 100644 index 00000000000..5b5e80a91b9 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/DefineThenIfDef.diag.txt @@ -0,0 +1,2 @@ +(2,1): Error RZ1042: '#define' and '#undef' cannot be used in razor markup. +(4,1): Error RZ1042: '#define' and '#undef' cannot be used in razor markup. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/DefineThenIfDef.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/DefineThenIfDef.stree.txt new file mode 100644 index 00000000000..b929d9f69d5 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/DefineThenIfDef.stree.txt @@ -0,0 +1,28 @@ +RazorDocument - [0..115)::115 - [@{LF#define SYMBOLLF#if SYMBOLLF#undef SYMBOLLF#if SYMBOLLF var x = 1;LF#endifLF#elseLF var x = 1;LF#endifLF}] + MarkupBlock - [0..115)::115 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..115)::115 + CSharpStatement - [0..115)::115 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementBody - [1..115)::114 + RazorMetaCode - [1..2)::1 - Gen + LeftBrace;[{]; + CSharpCodeBlock - [2..114)::112 + CSharpStatementLiteral - [2..114)::112 - [LF#define SYMBOLLF#if SYMBOLLF#undef SYMBOLLF#if SYMBOLLF var x = 1;LF#endifLF#elseLF var x = 1;LF#endifLF] - Gen + NewLine;[LF]; + CSharpDirective;[#define SYMBOLLF];RZ1042(4:1,0 [16] ) + CSharpDirective;[#if SYMBOLLF]; + CSharpDirective;[#undef SYMBOLLF];RZ1042(32:3,0 [15] ) + CSharpDirective;[#if SYMBOLLF]; + CSharpDisabledText;[ var x = 1;LF]; + CSharpDirective;[#endifLF]; + CSharpDirective;[#elseLF]; + CSharpDisabledText;[ var x = 1;LF]; + CSharpDirective;[#endifLF]; + RazorMetaCode - [114..115)::1 - Gen + RightBrace;[}]; + MarkupTextLiteral - [115..115)::0 - [] - Gen + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/ElIfNotOnNewline.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/ElIfNotOnNewline.cspans.txt new file mode 100644 index 00000000000..13049e42f47 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/ElIfNotOnNewline.cspans.txt @@ -0,0 +1,19 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [119] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [15] ) +MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [15] ) +Code span at (2:0,2 [12] ) - Parent: Statement block at (0:0,0 [15] ) +MetaCode span at (14:2,0 [1] ) - Parent: Statement block at (0:0,0 [15] ) +Markup span at (15:2,1 [2] ) - Parent: Markup block at (0:0,0 [119] ) +Markup span at (17:3,0 [5] ) - Parent: Tag block at (17:3,0 [5] ) +Markup span at (22:3,5 [6] ) - Parent: Markup block at (0:0,0 [119] ) +Markup span at (28:4,4 [3] ) - Parent: Tag block at (28:4,4 [3] ) +Markup span at (31:4,7 [7] ) - Parent: Markup block at (0:0,0 [119] ) +Markup span at (38:4,14 [4] ) - Parent: Tag block at (38:4,14 [4] ) +Markup span at (42:4,18 [2] ) - Parent: Markup block at (0:0,0 [119] ) +Markup span at (44:5,0 [6] ) - Parent: Tag block at (44:5,0 [6] ) +Markup span at (50:5,6 [2] ) - Parent: Markup block at (0:0,0 [119] ) +Transition span at (52:6,0 [1] ) - Parent: Statement block at (52:6,0 [67] ) +MetaCode span at (53:6,1 [1] ) - Parent: Statement block at (52:6,0 [67] ) +Code span at (54:6,2 [64] ) - Parent: Statement block at (52:6,0 [67] ) +MetaCode span at (118:12,0 [1] ) - Parent: Statement block at (52:6,0 [67] ) +Markup span at (119:12,1 [0] ) - Parent: Markup block at (0:0,0 [119] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/ElIfNotOnNewline.diag.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/ElIfNotOnNewline.diag.txt new file mode 100644 index 00000000000..b9fdc01f017 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/ElIfNotOnNewline.diag.txt @@ -0,0 +1 @@ +(7,4): Error RZ1043: C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/ElIfNotOnNewline.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/ElIfNotOnNewline.stree.txt new file mode 100644 index 00000000000..a7741d6001c --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/ElIfNotOnNewline.stree.txt @@ -0,0 +1,66 @@ +RazorDocument - [0..119)::119 - [@{LF#if trueLF}LF
LF

Content

LF
LF@{ #elif false }LF
LF

Content2

LF
LF@{LF#endifLF}] + MarkupBlock - [0..119)::119 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..15)::15 + CSharpStatement - [0..15)::15 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementBody - [1..15)::14 + RazorMetaCode - [1..2)::1 - Gen + LeftBrace;[{]; + CSharpCodeBlock - [2..14)::12 + CSharpStatementLiteral - [2..14)::12 - [LF#if trueLF] - Gen + NewLine;[LF]; + CSharpDirective;[#if trueLF]; + RazorMetaCode - [14..15)::1 - Gen + RightBrace;[}]; + MarkupEphemeralTextLiteral - [15..17)::2 - [LF] - Gen + NewLine;[LF]; + MarkupElement - [17..50)::33 + MarkupStartTag - [17..22)::5 - [
] - Gen + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [22..28)::6 - [LF ] - Gen + NewLine;[LF]; + Whitespace;[ ]; + MarkupElement - [28..42)::14 + MarkupStartTag - [28..31)::3 - [

] - Gen + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [31..38)::7 - [Content] - Gen + Text;[Content]; + MarkupEndTag - [38..42)::4 - [

] - Gen + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [42..44)::2 - [LF] - Gen + NewLine;[LF]; + MarkupEndTag - [44..50)::6 - [
] - Gen + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [50..52)::2 - [LF] - Gen + NewLine;[LF]; + CSharpCodeBlock - [52..119)::67 + CSharpStatement - [52..119)::67 + CSharpTransition - [52..53)::1 - Gen + Transition;[@]; + CSharpStatementBody - [53..119)::66 + RazorMetaCode - [53..54)::1 - Gen + LeftBrace;[{]; + CSharpCodeBlock - [54..118)::64 + CSharpStatementLiteral - [54..118)::64 - [ #elif false }LF
LF

Content2

LF
LF@{LF#endifLF] - Gen + Whitespace;[ ]; + CSharpDirective;[#elif false }LF];RZ1043(55:6,3 [15] ) + CSharpDisabledText;[
LF

Content2

LF
LF@{LF]; + CSharpDirective;[#endifLF]; + RazorMetaCode - [118..119)::1 - Gen + RightBrace;[}]; + MarkupTextLiteral - [119..119)::0 - [] - Gen + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/ElseNotOnNewline.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/ElseNotOnNewline.cspans.txt new file mode 100644 index 00000000000..4fe5d939370 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/ElseNotOnNewline.cspans.txt @@ -0,0 +1,19 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [113] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [15] ) +MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [15] ) +Code span at (2:0,2 [12] ) - Parent: Statement block at (0:0,0 [15] ) +MetaCode span at (14:2,0 [1] ) - Parent: Statement block at (0:0,0 [15] ) +Markup span at (15:2,1 [2] ) - Parent: Markup block at (0:0,0 [113] ) +Markup span at (17:3,0 [5] ) - Parent: Tag block at (17:3,0 [5] ) +Markup span at (22:3,5 [6] ) - Parent: Markup block at (0:0,0 [113] ) +Markup span at (28:4,4 [3] ) - Parent: Tag block at (28:4,4 [3] ) +Markup span at (31:4,7 [7] ) - Parent: Markup block at (0:0,0 [113] ) +Markup span at (38:4,14 [4] ) - Parent: Tag block at (38:4,14 [4] ) +Markup span at (42:4,18 [2] ) - Parent: Markup block at (0:0,0 [113] ) +Markup span at (44:5,0 [6] ) - Parent: Tag block at (44:5,0 [6] ) +Markup span at (50:5,6 [2] ) - Parent: Markup block at (0:0,0 [113] ) +Transition span at (52:6,0 [1] ) - Parent: Statement block at (52:6,0 [61] ) +MetaCode span at (53:6,1 [1] ) - Parent: Statement block at (52:6,0 [61] ) +Code span at (54:6,2 [58] ) - Parent: Statement block at (52:6,0 [61] ) +MetaCode span at (112:12,0 [1] ) - Parent: Statement block at (52:6,0 [61] ) +Markup span at (113:12,1 [0] ) - Parent: Markup block at (0:0,0 [113] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/ElseNotOnNewline.diag.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/ElseNotOnNewline.diag.txt new file mode 100644 index 00000000000..b9fdc01f017 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/ElseNotOnNewline.diag.txt @@ -0,0 +1 @@ +(7,4): Error RZ1043: C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/ElseNotOnNewline.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/ElseNotOnNewline.stree.txt new file mode 100644 index 00000000000..86f86073ad4 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/ElseNotOnNewline.stree.txt @@ -0,0 +1,66 @@ +RazorDocument - [0..113)::113 - [@{LF#if trueLF}LF
LF

Content

LF
LF@{ #else }LF
LF

Content2

LF
LF@{LF#endifLF}] + MarkupBlock - [0..113)::113 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..15)::15 + CSharpStatement - [0..15)::15 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementBody - [1..15)::14 + RazorMetaCode - [1..2)::1 - Gen + LeftBrace;[{]; + CSharpCodeBlock - [2..14)::12 + CSharpStatementLiteral - [2..14)::12 - [LF#if trueLF] - Gen + NewLine;[LF]; + CSharpDirective;[#if trueLF]; + RazorMetaCode - [14..15)::1 - Gen + RightBrace;[}]; + MarkupEphemeralTextLiteral - [15..17)::2 - [LF] - Gen + NewLine;[LF]; + MarkupElement - [17..50)::33 + MarkupStartTag - [17..22)::5 - [
] - Gen + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [22..28)::6 - [LF ] - Gen + NewLine;[LF]; + Whitespace;[ ]; + MarkupElement - [28..42)::14 + MarkupStartTag - [28..31)::3 - [

] - Gen + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [31..38)::7 - [Content] - Gen + Text;[Content]; + MarkupEndTag - [38..42)::4 - [

] - Gen + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [42..44)::2 - [LF] - Gen + NewLine;[LF]; + MarkupEndTag - [44..50)::6 - [
] - Gen + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [50..52)::2 - [LF] - Gen + NewLine;[LF]; + CSharpCodeBlock - [52..113)::61 + CSharpStatement - [52..113)::61 + CSharpTransition - [52..53)::1 - Gen + Transition;[@]; + CSharpStatementBody - [53..113)::60 + RazorMetaCode - [53..54)::1 - Gen + LeftBrace;[{]; + CSharpCodeBlock - [54..112)::58 + CSharpStatementLiteral - [54..112)::58 - [ #else }LF
LF

Content2

LF
LF@{LF#endifLF] - Gen + Whitespace;[ ]; + CSharpDirective;[#else }LF];RZ1043(55:6,3 [9] ) + CSharpDisabledText;[
LF

Content2

LF
LF@{LF]; + CSharpDirective;[#endifLF]; + RazorMetaCode - [112..113)::1 - Gen + RightBrace;[}]; + MarkupTextLiteral - [113..113)::0 - [] - Gen + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/EndIfNotOnNewline.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/EndIfNotOnNewline.cspans.txt new file mode 100644 index 00000000000..472cb9dc970 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/EndIfNotOnNewline.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [64] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [64] ) +MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [64] ) +Code span at (2:0,2 [62] ) - Parent: Statement block at (0:0,0 [64] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/EndIfNotOnNewline.diag.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/EndIfNotOnNewline.diag.txt new file mode 100644 index 00000000000..a270903b79c --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/EndIfNotOnNewline.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(7,4): Warning RZ1044: Possible C# preprocessor directive is misplaced. C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/EndIfNotOnNewline.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/EndIfNotOnNewline.stree.txt new file mode 100644 index 00000000000..b399fbaa804 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/EndIfNotOnNewline.stree.txt @@ -0,0 +1,19 @@ +RazorDocument - [0..64)::64 - [@{LF#if falseLF}LF
LF

Content

LF
LF@{ #endif }] + MarkupBlock - [0..64)::64 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..64)::64 + CSharpStatement - [0..64)::64 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementBody - [1..64)::63 + RazorMetaCode - [1..2)::1 - Gen + LeftBrace;[{]; + CSharpCodeBlock - [2..64)::62 + CSharpStatementLiteral - [2..64)::62 - [LF#if falseLF}LF
LF

Content

LF
LF@{ #endif }] - Gen + NewLine;[LF]; + CSharpDirective;[#if falseLF]; + CSharpDisabledText;[}LF
LF

Content

LF
LF@{ #endif }];RZ1044(56:6,3 [6] ) + RazorMetaCode - [64..64)::0 - Gen + RightBrace;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/ErrorWarningLine.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/ErrorWarningLine.cspans.txt new file mode 100644 index 00000000000..cae87c4ab35 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/ErrorWarningLine.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [152] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [152] ) +MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [152] ) +Code span at (2:0,2 [149] ) - Parent: Statement block at (0:0,0 [152] ) +MetaCode span at (151:7,0 [1] ) - Parent: Statement block at (0:0,0 [152] ) +Markup span at (152:7,1 [0] ) - Parent: Markup block at (0:0,0 [152] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/ErrorWarningLine.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/ErrorWarningLine.stree.txt new file mode 100644 index 00000000000..1954db41780 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/ErrorWarningLine.stree.txt @@ -0,0 +1,25 @@ +RazorDocument - [0..152)::152 - [@{LF#line 1 "file.cs"LF#error This is an errorLF#line defaultLF#warning This is a warningLF#line hiddenLF#line (1, 1) - (5, 60) 10 "partial-class.cs"LF}] + MarkupBlock - [0..152)::152 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..152)::152 + CSharpStatement - [0..152)::152 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementBody - [1..152)::151 + RazorMetaCode - [1..2)::1 - Gen + LeftBrace;[{]; + CSharpCodeBlock - [2..151)::149 + CSharpStatementLiteral - [2..151)::149 - [LF#line 1 "file.cs"LF#error This is an errorLF#line defaultLF#warning This is a warningLF#line hiddenLF#line (1, 1) - (5, 60) 10 "partial-class.cs"LF] - Gen + NewLine;[LF]; + CSharpDirective;[#line 1 "file.cs"LF]; + CSharpDirective;[#error This is an errorLF]; + CSharpDirective;[#line defaultLF]; + CSharpDirective;[#warning This is a warningLF]; + CSharpDirective;[#line hiddenLF]; + CSharpDirective;[#line (1, 1) - (5, 60) 10 "partial-class.cs"LF]; + RazorMetaCode - [151..152)::1 - Gen + RightBrace;[}]; + MarkupTextLiteral - [152..152)::0 - [] - Gen + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefAcrossMultipleBlocks.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefAcrossMultipleBlocks.cspans.txt new file mode 100644 index 00000000000..a176a17d95d --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefAcrossMultipleBlocks.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [102] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [102] ) +MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [102] ) +Code span at (2:0,2 [99] ) - Parent: Statement block at (0:0,0 [102] ) +MetaCode span at (101:12,0 [1] ) - Parent: Statement block at (0:0,0 [102] ) +Markup span at (102:12,1 [0] ) - Parent: Markup block at (0:0,0 [102] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefAcrossMultipleBlocks.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefAcrossMultipleBlocks.stree.txt new file mode 100644 index 00000000000..3c0db7bb1a1 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefAcrossMultipleBlocks.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..102)::102 - [@{LF#if falseLF var x = 1;LF}LFLF
LF

Content

LF
LFLF@{LF var y = 2;LF#endifLF}] + MarkupBlock - [0..102)::102 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..102)::102 + CSharpStatement - [0..102)::102 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementBody - [1..102)::101 + RazorMetaCode - [1..2)::1 - Gen + LeftBrace;[{]; + CSharpCodeBlock - [2..101)::99 + CSharpStatementLiteral - [2..101)::99 - [LF#if falseLF var x = 1;LF}LFLF
LF

Content

LF
LFLF@{LF var y = 2;LF#endifLF] - Gen + NewLine;[LF]; + CSharpDirective;[#if falseLF]; + CSharpDisabledText;[ var x = 1;LF}LFLF
LF

Content

LF
LFLF@{LF var y = 2;LF]; + CSharpDirective;[#endifLF]; + RazorMetaCode - [101..102)::1 - Gen + RightBrace;[}]; + MarkupTextLiteral - [102..102)::0 - [] - Gen + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefDisabledSectionUnbalanced.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefDisabledSectionUnbalanced.cspans.txt new file mode 100644 index 00000000000..2ab137d35b8 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefDisabledSectionUnbalanced.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [40] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [40] ) +MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [40] ) +Code span at (2:0,2 [37] ) - Parent: Statement block at (0:0,0 [40] ) +MetaCode span at (39:4,0 [1] ) - Parent: Statement block at (0:0,0 [40] ) +Markup span at (40:4,1 [0] ) - Parent: Markup block at (0:0,0 [40] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefDisabledSectionUnbalanced.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefDisabledSectionUnbalanced.stree.txt new file mode 100644 index 00000000000..b065360b7af --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefDisabledSectionUnbalanced.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..40)::40 - [@{LF#if falseLF void M() {LF#endifLF}] + MarkupBlock - [0..40)::40 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..40)::40 + CSharpStatement - [0..40)::40 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementBody - [1..40)::39 + RazorMetaCode - [1..2)::1 - Gen + LeftBrace;[{]; + CSharpCodeBlock - [2..39)::37 + CSharpStatementLiteral - [2..39)::37 - [LF#if falseLF void M() {LF#endifLF] - Gen + NewLine;[LF]; + CSharpDirective;[#if falseLF]; + CSharpDisabledText;[ void M() {LF]; + CSharpDirective;[#endifLF]; + RazorMetaCode - [39..40)::1 - Gen + RightBrace;[}]; + MarkupTextLiteral - [40..40)::0 - [] - Gen + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_None.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_None.cspans.txt new file mode 100644 index 00000000000..0dd084a5f95 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_None.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [95] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [95] ) +MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [95] ) +Code span at (2:0,2 [92] ) - Parent: Statement block at (0:0,0 [95] ) +MetaCode span at (94:8,0 [1] ) - Parent: Statement block at (0:0,0 [95] ) +Markup span at (95:8,1 [0] ) - Parent: Markup block at (0:0,0 [95] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_None.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_None.stree.txt new file mode 100644 index 00000000000..8bda107e863 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_None.stree.txt @@ -0,0 +1,35 @@ +RazorDocument - [0..95)::95 - [@{LF#if SYMBOLLF var x = 1;LF#elif SYMBOL2LF var x = 2;LF#elseLF var x = 3;LF#endifLF}] + MarkupBlock - [0..95)::95 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..95)::95 + CSharpStatement - [0..95)::95 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementBody - [1..95)::94 + RazorMetaCode - [1..2)::1 - Gen + LeftBrace;[{]; + CSharpCodeBlock - [2..94)::92 + CSharpStatementLiteral - [2..94)::92 - [LF#if SYMBOLLF var x = 1;LF#elif SYMBOL2LF var x = 2;LF#elseLF var x = 3;LF#endifLF] - Gen + NewLine;[LF]; + CSharpDirective;[#if SYMBOLLF]; + CSharpDisabledText;[ var x = 1;LF]; + CSharpDirective;[#elif SYMBOL2LF]; + CSharpDisabledText;[ var x = 2;LF]; + CSharpDirective;[#elseLF]; + Whitespace;[ ]; + Keyword;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + NumericLiteral;[3]; + Semicolon;[;]; + NewLine;[LF]; + CSharpDirective;[#endifLF]; + RazorMetaCode - [94..95)::1 - Gen + RightBrace;[}]; + MarkupTextLiteral - [95..95)::0 - [] - Gen + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_Symbol.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_Symbol.cspans.txt new file mode 100644 index 00000000000..0dd084a5f95 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_Symbol.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [95] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [95] ) +MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [95] ) +Code span at (2:0,2 [92] ) - Parent: Statement block at (0:0,0 [95] ) +MetaCode span at (94:8,0 [1] ) - Parent: Statement block at (0:0,0 [95] ) +Markup span at (95:8,1 [0] ) - Parent: Markup block at (0:0,0 [95] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_Symbol.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_Symbol.stree.txt new file mode 100644 index 00000000000..3e801619dee --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_Symbol.stree.txt @@ -0,0 +1,35 @@ +RazorDocument - [0..95)::95 - [@{LF#if SYMBOLLF var x = 1;LF#elif SYMBOL2LF var x = 2;LF#elseLF var x = 3;LF#endifLF}] + MarkupBlock - [0..95)::95 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..95)::95 + CSharpStatement - [0..95)::95 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementBody - [1..95)::94 + RazorMetaCode - [1..2)::1 - Gen + LeftBrace;[{]; + CSharpCodeBlock - [2..94)::92 + CSharpStatementLiteral - [2..94)::92 - [LF#if SYMBOLLF var x = 1;LF#elif SYMBOL2LF var x = 2;LF#elseLF var x = 3;LF#endifLF] - Gen + NewLine;[LF]; + CSharpDirective;[#if SYMBOLLF]; + Whitespace;[ ]; + Keyword;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + NumericLiteral;[1]; + Semicolon;[;]; + NewLine;[LF]; + CSharpDirective;[#elif SYMBOL2LF]; + CSharpDisabledText;[ var x = 2;LF]; + CSharpDirective;[#elseLF]; + CSharpDisabledText;[ var x = 3;LF]; + CSharpDirective;[#endifLF]; + RazorMetaCode - [94..95)::1 - Gen + RightBrace;[}]; + MarkupTextLiteral - [95..95)::0 - [] - Gen + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_Symbol2.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_Symbol2.cspans.txt new file mode 100644 index 00000000000..0dd084a5f95 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_Symbol2.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [95] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [95] ) +MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [95] ) +Code span at (2:0,2 [92] ) - Parent: Statement block at (0:0,0 [95] ) +MetaCode span at (94:8,0 [1] ) - Parent: Statement block at (0:0,0 [95] ) +Markup span at (95:8,1 [0] ) - Parent: Markup block at (0:0,0 [95] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_Symbol2.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_Symbol2.stree.txt new file mode 100644 index 00000000000..85583ccb7df --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefFromParseOptions_Symbol2.stree.txt @@ -0,0 +1,35 @@ +RazorDocument - [0..95)::95 - [@{LF#if SYMBOLLF var x = 1;LF#elif SYMBOL2LF var x = 2;LF#elseLF var x = 3;LF#endifLF}] + MarkupBlock - [0..95)::95 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..95)::95 + CSharpStatement - [0..95)::95 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementBody - [1..95)::94 + RazorMetaCode - [1..2)::1 - Gen + LeftBrace;[{]; + CSharpCodeBlock - [2..94)::92 + CSharpStatementLiteral - [2..94)::92 - [LF#if SYMBOLLF var x = 1;LF#elif SYMBOL2LF var x = 2;LF#elseLF var x = 3;LF#endifLF] - Gen + NewLine;[LF]; + CSharpDirective;[#if SYMBOLLF]; + CSharpDisabledText;[ var x = 1;LF]; + CSharpDirective;[#elif SYMBOL2LF]; + Whitespace;[ ]; + Keyword;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + NumericLiteral;[2]; + Semicolon;[;]; + NewLine;[LF]; + CSharpDirective;[#elseLF]; + CSharpDisabledText;[ var x = 3;LF]; + CSharpDirective;[#endifLF]; + RazorMetaCode - [94..95)::1 - Gen + RightBrace;[}]; + MarkupTextLiteral - [95..95)::0 - [] - Gen + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefNotOnNewline_01.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefNotOnNewline_01.cspans.txt new file mode 100644 index 00000000000..2c066c1a087 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefNotOnNewline_01.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [64] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [64] ) +MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [64] ) +Code span at (2:0,2 [61] ) - Parent: Statement block at (0:0,0 [64] ) +MetaCode span at (63:6,0 [1] ) - Parent: Statement block at (0:0,0 [64] ) +Markup span at (64:6,1 [0] ) - Parent: Markup block at (0:0,0 [64] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefNotOnNewline_01.diag.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefNotOnNewline_01.diag.txt new file mode 100644 index 00000000000..70f2ff6b424 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefNotOnNewline_01.diag.txt @@ -0,0 +1 @@ +(1,4): Error RZ1043: C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefNotOnNewline_01.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefNotOnNewline_01.stree.txt new file mode 100644 index 00000000000..4b4696c9ce7 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefNotOnNewline_01.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..64)::64 - [@{ #if false }LF
LF

Content

LF
LF@{LF#endifLF}] + MarkupBlock - [0..64)::64 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..64)::64 + CSharpStatement - [0..64)::64 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementBody - [1..64)::63 + RazorMetaCode - [1..2)::1 - Gen + LeftBrace;[{]; + CSharpCodeBlock - [2..63)::61 + CSharpStatementLiteral - [2..63)::61 - [ #if false }LF
LF

Content

LF
LF@{LF#endifLF] - Gen + Whitespace;[ ]; + CSharpDirective;[#if false }LF];RZ1043(3:0,3 [13] ) + CSharpDisabledText;[
LF

Content

LF
LF@{LF]; + CSharpDirective;[#endifLF]; + RazorMetaCode - [63..64)::1 - Gen + RightBrace;[}]; + MarkupTextLiteral - [64..64)::0 - [] - Gen + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefNotOnNewline_02.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefNotOnNewline_02.cspans.txt new file mode 100644 index 00000000000..2f471965c21 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefNotOnNewline_02.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [63] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [63] ) +MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [63] ) +Code span at (2:0,2 [60] ) - Parent: Statement block at (0:0,0 [63] ) +MetaCode span at (62:6,0 [1] ) - Parent: Statement block at (0:0,0 [63] ) +Markup span at (63:6,1 [0] ) - Parent: Markup block at (0:0,0 [63] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefNotOnNewline_02.diag.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefNotOnNewline_02.diag.txt new file mode 100644 index 00000000000..8ff9d56a3f5 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefNotOnNewline_02.diag.txt @@ -0,0 +1 @@ +(1,3): Error RZ1043: C# preprocessor directives must be at the start of the line, except for whitespace. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefNotOnNewline_02.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefNotOnNewline_02.stree.txt new file mode 100644 index 00000000000..91a9946588a --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfDefNotOnNewline_02.stree.txt @@ -0,0 +1,21 @@ +RazorDocument - [0..63)::63 - [@{#if false }LF
LF

Content

LF
LF@{LF#endifLF}] + MarkupBlock - [0..63)::63 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..63)::63 + CSharpStatement - [0..63)::63 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementBody - [1..63)::62 + RazorMetaCode - [1..2)::1 - Gen + LeftBrace;[{]; + CSharpCodeBlock - [2..62)::60 + CSharpStatementLiteral - [2..62)::60 - [#if false }LF
LF

Content

LF
LF@{LF#endifLF] - Gen + CSharpDirective;[#if false }LF];RZ1043(2:0,2 [13] ) + CSharpDisabledText;[
LF

Content

LF
LF@{LF]; + CSharpDirective;[#endifLF]; + RazorMetaCode - [62..63)::1 - Gen + RightBrace;[}]; + MarkupTextLiteral - [63..63)::0 - [] - Gen + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElse.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElse.cspans.txt new file mode 100644 index 00000000000..955cd492b01 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElse.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [69] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [69] ) +Code span at (1:0,1 [68] ) - Parent: Statement block at (0:0,0 [69] ) +Markup span at (69:10,1 [0] ) - Parent: Markup block at (0:0,0 [69] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElse.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElse.stree.txt new file mode 100644 index 00000000000..2aff90ed8c2 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElse.stree.txt @@ -0,0 +1,40 @@ +RazorDocument - [0..69)::69 - [@if (true)LF{LF}LFelse if (false)LF{LF}LFelseLF#if trueLF{LF#endifLF}] + MarkupBlock - [0..69)::69 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..69)::69 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementLiteral - [1..69)::68 - [if (true)LF{LF}LFelse if (false)LF{LF}LFelseLF#if trueLF{LF#endifLF}] - Gen + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + NewLine;[LF]; + LeftBrace;[{]; + NewLine;[LF]; + RightBrace;[}]; + NewLine;[LF]; + Keyword;[else]; + Whitespace;[ ]; + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[false]; + RightParenthesis;[)]; + NewLine;[LF]; + LeftBrace;[{]; + NewLine;[LF]; + RightBrace;[}]; + NewLine;[LF]; + Keyword;[else]; + NewLine;[LF]; + CSharpDirective;[#if trueLF]; + LeftBrace;[{]; + NewLine;[LF]; + CSharpDirective;[#endifLF]; + RightBrace;[}]; + MarkupTextLiteral - [69..69)::0 - [] - Gen + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElseIf.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElseIf.cspans.txt new file mode 100644 index 00000000000..a440f1761c4 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElseIf.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [57] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [57] ) +Code span at (1:0,1 [56] ) - Parent: Statement block at (0:0,0 [57] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElseIf.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElseIf.stree.txt new file mode 100644 index 00000000000..b3abeef1d35 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElseIf.stree.txt @@ -0,0 +1,32 @@ +RazorDocument - [0..57)::57 - [@if (true)LF{LF}LFelse if (false)LF#if trueLF{LF#endifLF}] + MarkupBlock - [0..57)::57 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..57)::57 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementLiteral - [1..57)::56 - [if (true)LF{LF}LFelse if (false)LF#if trueLF{LF#endifLF}] - Gen + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + NewLine;[LF]; + LeftBrace;[{]; + NewLine;[LF]; + RightBrace;[}]; + NewLine;[LF]; + Keyword;[else]; + Whitespace;[ ]; + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[false]; + RightParenthesis;[)]; + NewLine;[LF]; + CSharpDirective;[#if trueLF]; + LeftBrace;[{]; + NewLine;[LF]; + CSharpDirective;[#endifLF]; + RightBrace;[}]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElseIfBeforeElse.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElseIfBeforeElse.cspans.txt new file mode 100644 index 00000000000..955cd492b01 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElseIfBeforeElse.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [69] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [69] ) +Code span at (1:0,1 [68] ) - Parent: Statement block at (0:0,0 [69] ) +Markup span at (69:10,1 [0] ) - Parent: Markup block at (0:0,0 [69] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElseIfBeforeElse.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElseIfBeforeElse.stree.txt new file mode 100644 index 00000000000..9d9beeadbf8 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterElseIfBeforeElse.stree.txt @@ -0,0 +1,40 @@ +RazorDocument - [0..69)::69 - [@if (true)LF{LF}LFelse if (false)LF{LF}LF#if trueLFelseLF#endifLF{LF}] + MarkupBlock - [0..69)::69 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..69)::69 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementLiteral - [1..69)::68 - [if (true)LF{LF}LFelse if (false)LF{LF}LF#if trueLFelseLF#endifLF{LF}] - Gen + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + NewLine;[LF]; + LeftBrace;[{]; + NewLine;[LF]; + RightBrace;[}]; + NewLine;[LF]; + Keyword;[else]; + Whitespace;[ ]; + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[false]; + RightParenthesis;[)]; + NewLine;[LF]; + LeftBrace;[{]; + NewLine;[LF]; + RightBrace;[}]; + NewLine;[LF]; + CSharpDirective;[#if trueLF]; + Keyword;[else]; + NewLine;[LF]; + CSharpDirective;[#endifLF]; + LeftBrace;[{]; + NewLine;[LF]; + RightBrace;[}]; + MarkupTextLiteral - [69..69)::0 - [] - Gen + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIf.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIf.cspans.txt new file mode 100644 index 00000000000..5fe7bb01e19 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIf.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [34] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [34] ) +Code span at (1:0,1 [33] ) - Parent: Statement block at (0:0,0 [34] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIf.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIf.stree.txt new file mode 100644 index 00000000000..eed8ff4b94a --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIf.stree.txt @@ -0,0 +1,20 @@ +RazorDocument - [0..34)::34 - [@if (true)LF#if trueLF{LF#endifLF}] + MarkupBlock - [0..34)::34 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..34)::34 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementLiteral - [1..34)::33 - [if (true)LF#if trueLF{LF#endifLF}] - Gen + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + NewLine;[LF]; + CSharpDirective;[#if trueLF]; + LeftBrace;[{]; + NewLine;[LF]; + CSharpDirective;[#endifLF]; + RightBrace;[}]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIfBeforeElseIf.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIfBeforeElseIf.cspans.txt new file mode 100644 index 00000000000..a440f1761c4 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIfBeforeElseIf.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [57] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [57] ) +Code span at (1:0,1 [56] ) - Parent: Statement block at (0:0,0 [57] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIfBeforeElseIf.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIfBeforeElseIf.stree.txt new file mode 100644 index 00000000000..0324f258865 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIfBeforeElseIf.stree.txt @@ -0,0 +1,32 @@ +RazorDocument - [0..57)::57 - [@if (true)LF{LF}LF#if trueLFelse if (false)LF#endifLF{LF}] + MarkupBlock - [0..57)::57 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..57)::57 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementLiteral - [1..57)::56 - [if (true)LF{LF}LF#if trueLFelse if (false)LF#endifLF{LF}] - Gen + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + NewLine;[LF]; + LeftBrace;[{]; + NewLine;[LF]; + RightBrace;[}]; + NewLine;[LF]; + CSharpDirective;[#if trueLF]; + Keyword;[else]; + Whitespace;[ ]; + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[false]; + RightParenthesis;[)]; + NewLine;[LF]; + CSharpDirective;[#endifLF]; + LeftBrace;[{]; + NewLine;[LF]; + RightBrace;[}]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIfBlock.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIfBlock.cspans.txt new file mode 100644 index 00000000000..27236ea435a --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIfBlock.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [34] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [28] ) +Code span at (1:0,1 [27] ) - Parent: Statement block at (0:0,0 [28] ) +Markup span at (28:4,0 [6] ) - Parent: Markup block at (0:0,0 [34] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIfBlock.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIfBlock.stree.txt new file mode 100644 index 00000000000..77f3b09401d --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/IfStatementAfterIfBlock.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..34)::34 - [@if (true)LF{LF#if trueLF}LF#endif] + MarkupBlock - [0..34)::34 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..28)::28 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementLiteral - [1..28)::27 - [if (true)LF{LF#if trueLF}LF] - Gen + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + NewLine;[LF]; + LeftBrace;[{]; + NewLine;[LF]; + CSharpDirective;[#if trueLF]; + RightBrace;[}]; + NewLine;[LF]; + MarkupTextLiteral - [28..34)::6 - [#endif] - Gen + Text;[#endif]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/NullableDirectives.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/NullableDirectives.cspans.txt new file mode 100644 index 00000000000..e646ba517c2 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/NullableDirectives.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [236] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [236] ) +MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [236] ) +Code span at (2:0,2 [233] ) - Parent: Statement block at (0:0,0 [236] ) +MetaCode span at (235:10,0 [1] ) - Parent: Statement block at (0:0,0 [236] ) +Markup span at (236:10,1 [0] ) - Parent: Markup block at (0:0,0 [236] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/NullableDirectives.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/NullableDirectives.stree.txt new file mode 100644 index 00000000000..44c450b5bb0 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/NullableDirectives.stree.txt @@ -0,0 +1,28 @@ +RazorDocument - [0..236)::236 - [@{LF#nullable enableLF#nullable disableLF#nullable restoreLF#nullable enable annotationsLF#nullable disable annotationsLF#nullable restore annotationsLF#nullable enable warningsLF#nullable disable warningsLF#nullable restore warningsLF}] + MarkupBlock - [0..236)::236 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..236)::236 + CSharpStatement - [0..236)::236 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementBody - [1..236)::235 + RazorMetaCode - [1..2)::1 - Gen + LeftBrace;[{]; + CSharpCodeBlock - [2..235)::233 + CSharpStatementLiteral - [2..235)::233 - [LF#nullable enableLF#nullable disableLF#nullable restoreLF#nullable enable annotationsLF#nullable disable annotationsLF#nullable restore annotationsLF#nullable enable warningsLF#nullable disable warningsLF#nullable restore warningsLF] - Gen + NewLine;[LF]; + CSharpDirective;[#nullable enableLF]; + CSharpDirective;[#nullable disableLF]; + CSharpDirective;[#nullable restoreLF]; + CSharpDirective;[#nullable enable annotationsLF]; + CSharpDirective;[#nullable disable annotationsLF]; + CSharpDirective;[#nullable restore annotationsLF]; + CSharpDirective;[#nullable enable warningsLF]; + CSharpDirective;[#nullable disable warningsLF]; + CSharpDirective;[#nullable restore warningsLF]; + RazorMetaCode - [235..236)::1 - Gen + RightBrace;[}]; + MarkupTextLiteral - [236..236)::0 - [] - Gen + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/Pragmas.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/Pragmas.cspans.txt new file mode 100644 index 00000000000..3b0d7f54e34 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/Pragmas.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [139] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [139] ) +MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [139] ) +Code span at (2:0,2 [136] ) - Parent: Statement block at (0:0,0 [139] ) +MetaCode span at (138:4,0 [1] ) - Parent: Statement block at (0:0,0 [139] ) +Markup span at (139:4,1 [0] ) - Parent: Markup block at (0:0,0 [139] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/Pragmas.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/Pragmas.stree.txt new file mode 100644 index 00000000000..3a31ff62f6e --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/Pragmas.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..139)::139 - [@{LF#pragma warning disable 123LF#pragma warning restore 123LF#pragma checksum "file.cs" "{00000000-0000-0000-0000-000000000000}" "1234"LF}] + MarkupBlock - [0..139)::139 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..139)::139 + CSharpStatement - [0..139)::139 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementBody - [1..139)::138 + RazorMetaCode - [1..2)::1 - Gen + LeftBrace;[{]; + CSharpCodeBlock - [2..138)::136 + CSharpStatementLiteral - [2..138)::136 - [LF#pragma warning disable 123LF#pragma warning restore 123LF#pragma checksum "file.cs" "{00000000-0000-0000-0000-000000000000}" "1234"LF] - Gen + NewLine;[LF]; + CSharpDirective;[#pragma warning disable 123LF]; + CSharpDirective;[#pragma warning restore 123LF]; + CSharpDirective;[#pragma checksum "file.cs" "{00000000-0000-0000-0000-000000000000}" "1234"LF]; + RazorMetaCode - [138..139)::1 - Gen + RightBrace;[}]; + MarkupTextLiteral - [139..139)::0 - [] - Gen + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/Regions.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/Regions.cspans.txt new file mode 100644 index 00000000000..30c4fba1504 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/Regions.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [37] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [37] ) +MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [37] ) +Code span at (2:0,2 [34] ) - Parent: Statement block at (0:0,0 [37] ) +MetaCode span at (36:3,0 [1] ) - Parent: Statement block at (0:0,0 [37] ) +Markup span at (37:3,1 [0] ) - Parent: Markup block at (0:0,0 [37] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/Regions.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/Regions.stree.txt new file mode 100644 index 00000000000..66705ca1c64 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/Regions.stree.txt @@ -0,0 +1,21 @@ +RazorDocument - [0..37)::37 - [@{LF#region MyRegion }LF#endregionLF}] + MarkupBlock - [0..37)::37 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..37)::37 + CSharpStatement - [0..37)::37 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementBody - [1..37)::36 + RazorMetaCode - [1..2)::1 - Gen + LeftBrace;[{]; + CSharpCodeBlock - [2..36)::34 + CSharpStatementLiteral - [2..36)::34 - [LF#region MyRegion }LF#endregionLF] - Gen + NewLine;[LF]; + CSharpDirective;[#region MyRegion }LF]; + CSharpDirective;[#endregionLF]; + RazorMetaCode - [36..37)::1 - Gen + RightBrace;[}]; + MarkupTextLiteral - [37..37)::0 - [] - Gen + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/SimpleIfDef_01.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/SimpleIfDef_01.cspans.txt new file mode 100644 index 00000000000..2d4ce6f2d28 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/SimpleIfDef_01.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [39] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [39] ) +MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [39] ) +Code span at (2:0,2 [36] ) - Parent: Statement block at (0:0,0 [39] ) +MetaCode span at (38:4,0 [1] ) - Parent: Statement block at (0:0,0 [39] ) +Markup span at (39:4,1 [0] ) - Parent: Markup block at (0:0,0 [39] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/SimpleIfDef_01.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/SimpleIfDef_01.stree.txt new file mode 100644 index 00000000000..b0854aba69a --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/SimpleIfDef_01.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..39)::39 - [@{LF#if trueLF var x = 1;LF#endifLF}] + MarkupBlock - [0..39)::39 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..39)::39 + CSharpStatement - [0..39)::39 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementBody - [1..39)::38 + RazorMetaCode - [1..2)::1 - Gen + LeftBrace;[{]; + CSharpCodeBlock - [2..38)::36 + CSharpStatementLiteral - [2..38)::36 - [LF#if trueLF var x = 1;LF#endifLF] - Gen + NewLine;[LF]; + CSharpDirective;[#if trueLF]; + Whitespace;[ ]; + Keyword;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + NumericLiteral;[1]; + Semicolon;[;]; + NewLine;[LF]; + CSharpDirective;[#endifLF]; + RazorMetaCode - [38..39)::1 - Gen + RightBrace;[}]; + MarkupTextLiteral - [39..39)::0 - [] - Gen + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/SimpleIfDef_02.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/SimpleIfDef_02.cspans.txt new file mode 100644 index 00000000000..749976e8df4 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/SimpleIfDef_02.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [45] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [45] ) +MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [45] ) +Code span at (2:0,2 [12] ) - Parent: Statement block at (0:0,0 [45] ) +Markup span at (14:2,0 [4] ) - Parent: Markup block at (14:2,0 [22] ) +Markup span at (18:2,4 [3] ) - Parent: Tag block at (18:2,4 [3] ) +Markup span at (21:2,7 [9] ) - Parent: Markup block at (14:2,0 [22] ) +Markup span at (30:2,16 [4] ) - Parent: Tag block at (30:2,16 [4] ) +Markup span at (34:2,20 [2] ) - Parent: Markup block at (14:2,0 [22] ) +Code span at (36:3,0 [8] ) - Parent: Statement block at (0:0,0 [45] ) +MetaCode span at (44:4,0 [1] ) - Parent: Statement block at (0:0,0 [45] ) +Markup span at (45:4,1 [0] ) - Parent: Markup block at (0:0,0 [45] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/SimpleIfDef_02.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/SimpleIfDef_02.stree.txt new file mode 100644 index 00000000000..2ad8c27dc55 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/SimpleIfDef_02.stree.txt @@ -0,0 +1,41 @@ +RazorDocument - [0..45)::45 - [@{LF#if trueLF

Some text

LF#endifLF}] + MarkupBlock - [0..45)::45 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..45)::45 + CSharpStatement - [0..45)::45 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementBody - [1..45)::44 + RazorMetaCode - [1..2)::1 - Gen + LeftBrace;[{]; + CSharpCodeBlock - [2..44)::42 + CSharpStatementLiteral - [2..14)::12 - [LF#if trueLF] - Gen + NewLine;[LF]; + CSharpDirective;[#if trueLF]; + MarkupBlock - [14..36)::22 + MarkupTextLiteral - [14..18)::4 - [ ] - Gen + Whitespace;[ ]; + MarkupElement - [18..34)::16 + MarkupStartTag - [18..21)::3 - [

] - Gen + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [21..30)::9 - [Some text] - Gen + Text;[Some]; + Whitespace;[ ]; + Text;[text]; + MarkupEndTag - [30..34)::4 - [

] - Gen + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [34..36)::2 - [LF] - Gen + NewLine;[LF]; + CSharpStatementLiteral - [36..44)::8 - [#endifLF] - Gen + CSharpDirective;[#endifLF]; + RazorMetaCode - [44..45)::1 - Gen + RightBrace;[}]; + MarkupTextLiteral - [45..45)::0 - [] - Gen + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/SimplePragma.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/SimplePragma.cspans.txt new file mode 100644 index 00000000000..460e15b3757 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/SimplePragma.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [38] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [38] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [38] ) +Code span at (2:0,2 [35] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [38] ) +MetaCode span at (37:2,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [38] ) +Markup span at (38:2,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [38] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/SimplePragma.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/SimplePragma.stree.txt new file mode 100644 index 00000000000..8008e1d6fd9 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/SimplePragma.stree.txt @@ -0,0 +1,29 @@ +RazorDocument - [0..38)::38 - [@{LF #pragma warning disable 123LF}] + MarkupBlock - [0..38)::38 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..38)::38 + CSharpStatement - [0..38)::38 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..38)::37 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..37)::35 + CSharpStatementLiteral - [2..37)::35 - [LF #pragma warning disable 123LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + Whitespace;[ ]; + Hash;[#]; + Identifier;[pragma]; + Whitespace;[ ]; + Identifier;[warning]; + Whitespace;[ ]; + Identifier;[disable]; + Whitespace;[ ]; + IntegerLiteral;[123]; + NewLine;[LF]; + RazorMetaCode - [37..38)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [38..38)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/UsingStatementResults.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/UsingStatementResults.cspans.txt new file mode 100644 index 00000000000..917666bd6a2 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/UsingStatementResults.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [48] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [48] ) +Code span at (1:0,1 [47] ) - Parent: Statement block at (0:0,0 [48] ) +Markup span at (48:4,1 [0] ) - Parent: Markup block at (0:0,0 [48] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/UsingStatementResults.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/UsingStatementResults.stree.txt new file mode 100644 index 00000000000..df45d9410db --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpPreprocessorTest/UsingStatementResults.stree.txt @@ -0,0 +1,28 @@ +RazorDocument - [0..48)::48 - [@using (var test = blah)LF#if trueLF{LF#endifLF}] + MarkupBlock - [0..48)::48 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..48)::48 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementLiteral - [1..48)::47 - [using (var test = blah)LF#if trueLF{LF#endifLF}] - Gen + Keyword;[using]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[var]; + Whitespace;[ ]; + Identifier;[test]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[blah]; + RightParenthesis;[)]; + NewLine;[LF]; + CSharpDirective;[#if trueLF]; + LeftBrace;[{]; + NewLine;[LF]; + CSharpDirective;[#endifLF]; + RightBrace;[}]; + MarkupTextLiteral - [48..48)::0 - [] - Gen + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Legacy/CSharpCodeParser.cs b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Legacy/CSharpCodeParser.cs index 171484eac8f..e467860fc76 100644 --- a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Legacy/CSharpCodeParser.cs +++ b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Legacy/CSharpCodeParser.cs @@ -24,7 +24,7 @@ internal class CSharpCodeParser : TokenizerBackedParser ]).ToFrozenSet(); private static readonly Func IsValidStatementSpacingToken = - IsSpacingTokenIncludingNewLinesAndComments; + IsSpacingTokenIncludingNewLinesAndCommentsAndCSharpDirectives; internal static readonly DirectiveDescriptor AddTagHelperDirectiveDescriptor = DirectiveDescriptor.CreateDirective( SyntaxConstants.CSharp.AddTagHelperKeyword, @@ -233,7 +233,7 @@ public HtmlMarkupParser HtmlParser NextToken(); using var precedingWhitespace = new PooledArrayBuilder(); - ReadWhile(IsSpacingTokenIncludingNewLinesAndComments, ref precedingWhitespace.AsRef()); + ReadWhile(IsSpacingTokenIncludingNewLinesAndCommentsAndCSharpDirectives, ref precedingWhitespace.AsRef()); // We are usually called when the other parser sees a transition '@'. Look for it. SyntaxToken? transitionToken = null; @@ -720,7 +720,20 @@ private void ParseStatement(in SyntaxListBuilder builder, Block { SetAcceptedCharacters(AcceptedCharactersInternal.Any); // Accept whitespace but always keep the last whitespace node so we can put it back if necessary - var lastWhitespace = AcceptWhitespaceInLines(); + using var tokens = new PooledArrayBuilder(); + ReadWhile(IsSpacingTokenIncludingNewLinesAndCommentsAndCSharpDirectives, ref tokens.AsRef()); + +#pragma warning disable RS0042 // Do not copy value https://github.com/dotnet/roslyn-analyzers/issues/7389 + var lastWhitespace = tokens is [.., { Kind: SyntaxKind.Whitespace } whitespace] ? whitespace : null; +#pragma warning restore RS0042 // Do not copy value + + if (lastWhitespace != null) + { + tokens.RemoveAt(^1); + } + + Accept(in tokens); + if (EndOfFile) { if (lastWhitespace != null) @@ -1745,7 +1758,7 @@ private void ParseExtensibleDirective(in SyntaxListBuilder buil break; case DirectiveKind.RazorBlock: shouldCaptureWhitespaceToEndOfLine = true; - AcceptWhile(IsSpacingTokenIncludingNewLinesAndComments); + AcceptWhile(IsSpacingTokenIncludingNewLinesAndCommentsAndCSharpDirectives); SetAcceptedCharacters(AcceptedCharactersInternal.AllWhitespace); directiveBuilder.Add(OutputTokensAsUnclassifiedLiteral()); @@ -1772,7 +1785,7 @@ private void ParseExtensibleDirective(in SyntaxListBuilder buil break; case DirectiveKind.CodeBlock: shouldCaptureWhitespaceToEndOfLine = true; - AcceptWhile(IsSpacingTokenIncludingNewLinesAndComments); + AcceptWhile(IsSpacingTokenIncludingNewLinesAndCommentsAndCSharpDirectives); SetAcceptedCharacters(AcceptedCharactersInternal.AllWhitespace); directiveBuilder.Add(OutputTokensAsUnclassifiedLiteral()); @@ -2075,12 +2088,12 @@ private void ParseConditionalBlock(in SyntaxListBuilder builder private void ParseConditionalBlock(in SyntaxListBuilder builder, Block block) { AcceptAndMoveNext(); - AcceptWhile(IsSpacingTokenIncludingNewLinesAndComments); + AcceptWhile(IsSpacingTokenIncludingNewLinesAndCommentsAndCSharpDirectives); // Parse the condition, if present (if not present, we'll let the C# compiler complain) if (TryParseCondition(builder)) { - AcceptWhile(IsSpacingTokenIncludingNewLinesAndComments); + AcceptWhile(IsSpacingTokenIncludingNewLinesAndCommentsAndCSharpDirectives); ParseExpectedCodeBlock(builder, block); } @@ -2148,7 +2161,7 @@ private void ParseUnconditionalBlock(in SyntaxListBuilder build Assert(SyntaxKind.Keyword); var block = new Block(GetBlockName(CurrentToken), CurrentStart); AcceptAndMoveNext(); - AcceptWhile(IsSpacingTokenIncludingNewLinesAndComments); + AcceptWhile(IsSpacingTokenIncludingNewLinesAndCommentsAndCSharpDirectives); ParseExpectedCodeBlock(builder, block); } @@ -2225,7 +2238,7 @@ private void ParseElseClause(in SyntaxListBuilder builder) var block = new Block(GetBlockName(CurrentToken), CurrentStart); AcceptAndMoveNext(); - AcceptWhile(IsSpacingTokenIncludingNewLinesAndComments); + AcceptWhile(IsSpacingTokenIncludingNewLinesAndCommentsAndCSharpDirectives); if (At(CSharpSyntaxKind.IfKeyword)) { // ElseIf @@ -2349,7 +2362,7 @@ private void ParseWhileClause(in SyntaxListBuilder builder) Accept(in whitespace); Assert(CSharpSyntaxKind.WhileKeyword); AcceptAndMoveNext(); - AcceptWhile(IsSpacingTokenIncludingNewLinesAndComments); + AcceptWhile(IsSpacingTokenIncludingNewLinesAndCommentsAndCSharpDirectives); if (TryParseCondition(builder) && TryAccept(SyntaxKind.Semicolon)) { SetAcceptedCharacters(AcceptedCharactersInternal.None); @@ -2447,7 +2460,7 @@ private void ParseUsingStatement(in SyntaxListBuilder builder, // Parse condition if (TryParseCondition(builder)) { - AcceptWhile(IsSpacingTokenIncludingNewLinesAndComments); + AcceptWhile(IsSpacingTokenIncludingNewLinesAndCommentsAndCSharpDirectives); // Parse code block ParseExpectedCodeBlock(builder, block); @@ -2473,7 +2486,7 @@ private void ParseUsingDeclaration(in SyntaxListBuilder builder nonNamespaceTokenCount = TokenBuilder.Count; TryParseNamespaceOrTypeName(directiveBuilder); using var whitespace = new PooledArrayBuilder(); - ReadWhile(IsSpacingTokenIncludingNewLinesAndComments, ref whitespace.AsRef()); + ReadWhile(IsSpacingTokenIncludingNewLinesAndCommentsAndCSharpDirectives, ref whitespace.AsRef()); if (At(SyntaxKind.Assign)) { // Alias @@ -2481,7 +2494,7 @@ private void ParseUsingDeclaration(in SyntaxListBuilder builder Assert(SyntaxKind.Assign); AcceptAndMoveNext(); - AcceptWhile(IsSpacingTokenIncludingNewLinesAndComments); + AcceptWhile(IsSpacingTokenIncludingNewLinesAndCommentsAndCSharpDirectives); // One more namespace or type name TryParseNamespaceOrTypeName(directiveBuilder); @@ -2681,7 +2694,7 @@ private void SkipToNextImportantToken( while (!EndOfFile) { - ReadWhile(IsSpacingTokenIncludingNewLinesAndComments, ref whitespace); + ReadWhile(IsSpacingTokenIncludingNewLinesAndCommentsAndCSharpDirectives, ref whitespace); if (At(SyntaxKind.RazorCommentTransition)) { Accept(in whitespace); diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Legacy/RoslynCSharpTokenizer.cs b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Legacy/RoslynCSharpTokenizer.cs index c5d5e6a8f3e..38a73b4f82c 100644 --- a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Legacy/RoslynCSharpTokenizer.cs +++ b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Legacy/RoslynCSharpTokenizer.cs @@ -4,8 +4,10 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using Microsoft.AspNetCore.Razor.PooledObjects; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Text; using SyntaxToken = Microsoft.AspNetCore.Razor.Language.Syntax.InternalSyntax.SyntaxToken; @@ -13,7 +15,6 @@ using CSharpSyntaxKind = Microsoft.CodeAnalysis.CSharp.SyntaxKind; using CSharpSyntaxToken = Microsoft.CodeAnalysis.SyntaxToken; using CSharpSyntaxTriviaList = Microsoft.CodeAnalysis.SyntaxTriviaList; -using Microsoft.AspNetCore.Razor.PooledObjects; namespace Microsoft.AspNetCore.Razor.Language.Legacy; @@ -31,7 +32,9 @@ internal sealed class RoslynCSharpTokenizer : CSharpTokenizer /// by position, where the position is the start of the token that was parsed including leading trivia, so that searching /// is correct when performing a reset. /// - private readonly List<(int position, SyntaxTokenParser.Result result)> _resultCache = ListPool<(int, SyntaxTokenParser.Result)>.Default.Get(); + private readonly List<(int position, SyntaxTokenParser.Result result, bool isOnlyWhitespaceOnLine)> _resultCache = ListPool<(int, SyntaxTokenParser.Result, bool)>.Default.Get(); + + private bool _isOnlyWhitespaceOnLine = true; public RoslynCSharpTokenizer(SeekableTextReader source, CSharpParseOptions parseOptions) : base(source) @@ -58,6 +61,26 @@ public RoslynCSharpTokenizer(SeekableTextReader source, CSharpParseOptions parse internal override void StartingBlock() { _roslynTokenParser.SkipForwardTo(Source.Position); + ResetIsOnlyWhitespaceOnLine(); + } + + private void ResetIsOnlyWhitespaceOnLine() + { + // Reset isOnlyWhitespaceOnLine for the new block + _isOnlyWhitespaceOnLine = true; + for (int i = Source.Position - 1; i >= 0; i--) + { + var currentChar = Source.SourceText[i]; + if (currentChar is '\n' or '\r') + { + break; + } + else if (!SyntaxFacts.IsWhitespace(currentChar)) + { + _isOnlyWhitespaceOnLine = false; + break; + } + } } internal override void EndingBlock() @@ -75,8 +98,9 @@ internal override void EndingBlock() Debug.Assert(_currentCSharpTokenTriviaEnumerator is (_, isLeading: false)); Debug.Assert(_resultCache.Count > 0); - var (_, result) = _resultCache[^1]; + var (_, result, isOnlyWhitespaceOnLine) = _resultCache[^1]; _roslynTokenParser.ResetTo(result); + _isOnlyWhitespaceOnLine = isOnlyWhitespaceOnLine; _resultCache.RemoveAt(_resultCache.Count - 1); var lastToken = result.Token; if (lastToken.HasLeadingTrivia) @@ -212,7 +236,8 @@ private StateResult Token() { Assumed.Unreachable(); } - else if (SyntaxFacts.IsIdentifierStartCharacter(CurrentCharacter)) + + if (SyntaxFacts.IsIdentifierStartCharacter(CurrentCharacter)) { return Identifier(); } @@ -265,6 +290,7 @@ private StateResult AtToken() // Escaped razor transition. Likely will error in the parser. AddResetPoint(); TakeCurrent(); + _isOnlyWhitespaceOnLine = false; _roslynTokenParser.SkipForwardTo(Source.Position); AssertCurrent('@'); return Transition(RoslynCSharpTokenizerState.Token, EndToken(SyntaxKind.Transition)); @@ -273,11 +299,21 @@ private StateResult AtToken() // identifier if it's the latter case. AddResetPoint(); TakeCurrent(); + _isOnlyWhitespaceOnLine = false; _roslynTokenParser.SkipForwardTo(Source.Position); var trailingTrivia = GetNextResult(NextResultType.TrailingTrivia); _currentCSharpTokenTriviaEnumerator = (trailingTrivia.Token.TrailingTrivia.GetEnumerator(), isLeading: false); return Transition(RoslynCSharpTokenizerState.TriviaForCSharpToken, EndToken(SyntaxKind.Transition)); } + + void AddResetPoint() + { + // We want to make it easy to reset the tokenizer back to just before this token; we can do that very simply by trying to parse + // leading trivia, which gives us a reset point. We know that we can't have any leading trivia, since we're on an `@` character. + var nextResult = GetNextResult(NextResultType.LeadingTrivia); + Debug.Assert(nextResult.Token.IsKind(CSharpSyntaxKind.None)); + Debug.Assert(nextResult.Token.FullSpan.Length == 0); + } } private StateResult Operator() @@ -462,13 +498,120 @@ private StateResult Trivia() new SourceSpan(CurrentStart, contentLength: 1 /* end of file */))); } - // PROTOTYPE: Handle preprocessor directives - var tokenType = trivia.Kind() switch + SyntaxKind tokenType; + switch (trivia.Kind()) { - CSharpSyntaxKind.WhitespaceTrivia => SyntaxKind.Whitespace, - CSharpSyntaxKind.EndOfLineTrivia => SyntaxKind.NewLine, - CSharpSyntaxKind.SingleLineCommentTrivia or CSharpSyntaxKind.MultiLineCommentTrivia or CSharpSyntaxKind.MultiLineDocumentationCommentTrivia or CSharpSyntaxKind.SingleLineDocumentationCommentTrivia => SyntaxKind.CSharpComment, - var kind => throw new InvalidOperationException($"Unexpected trivia kind: {kind}."), + case CSharpSyntaxKind.WhitespaceTrivia: + tokenType = SyntaxKind.Whitespace; + break; + case CSharpSyntaxKind.EndOfLineTrivia: + tokenType = SyntaxKind.NewLine; + _isOnlyWhitespaceOnLine = true; + break; + case CSharpSyntaxKind.SingleLineCommentTrivia or + CSharpSyntaxKind.MultiLineCommentTrivia or + CSharpSyntaxKind.MultiLineDocumentationCommentTrivia or + CSharpSyntaxKind.SingleLineDocumentationCommentTrivia: + tokenType = SyntaxKind.CSharpComment; + _isOnlyWhitespaceOnLine = false; + break; + case var kind when SyntaxFacts.IsPreprocessorDirective(kind): + tokenType = SyntaxKind.CSharpDirective; + + if (!_isOnlyWhitespaceOnLine) + { + CurrentErrors.Add( + RazorDiagnosticFactory.CreateParsing_PreprocessorDirectivesMustBeAtTheStartOfLine( + new SourceSpan(CurrentStart, contentLength: trivia.FullSpan.Length))); + } + + var directiveTrivia = (DirectiveTriviaSyntax)trivia.GetStructure()!; + Debug.Assert(directiveTrivia != null); + + if (directiveTrivia is DefineDirectiveTriviaSyntax or UndefDirectiveTriviaSyntax) + { + CurrentErrors.Add( + RazorDiagnosticFactory.CreateParsing_DefineAndUndefNotAllowed( + new SourceSpan(CurrentStart, contentLength: directiveTrivia.FullSpan.Length))); + } + + _isOnlyWhitespaceOnLine = directiveTrivia.EndOfDirectiveToken.TrailingTrivia is [.., { RawKind: (int)CSharpSyntaxKind.EndOfLineTrivia }]; + break; + case CSharpSyntaxKind.DisabledTextTrivia: + tokenType = SyntaxKind.CSharpDisabledText; + _isOnlyWhitespaceOnLine = true; + + // We want to scan through the disabled text and see if someone misplaced an #else or #endif by not putting it at the start of a line. We can't truly + // be certain; for example, it could be in html, intentionally. But this is just a warning, and the user can disable it; since we made a breaking change + // and there could be directives not at the start of a line, we want to be helpful. + + { + for (var i = 0; i < triviaString.Length; i++) + { + var currentChar = triviaString[i]; + switch (currentChar) + { + case '\r': + case '\n': + _isOnlyWhitespaceOnLine = true; + break; + + case '#' when !_isOnlyWhitespaceOnLine: + // If there is only whitespace on the current line, and we're about to see a directive, then it clearly wasn't + // #endif or #else + var start = CurrentStart.AbsoluteIndex + i; + if (startsWith("else")) + { + var length = "#else".Length; + var linePosition = Source.SourceText.Lines.GetLinePosition(start); + CurrentErrors.Add( + RazorDiagnosticFactory.CreateParsing_PossibleMisplacedPreprocessorDirective( + new SourceSpan( + absoluteIndex: start, + lineIndex: linePosition.Line, + characterIndex: linePosition.Character, + length))); + i += 4; + } + else if (startsWith("endif")) + { + var length = "#endif".Length; + var linePosition = Source.SourceText.Lines.GetLinePosition(start); + CurrentErrors.Add( + RazorDiagnosticFactory.CreateParsing_PossibleMisplacedPreprocessorDirective( + new SourceSpan( + absoluteIndex: start, + lineIndex: linePosition.Line, + characterIndex: linePosition.Character, + length))); + i += 5; + } + + break; + + bool startsWith(string substring) + { + Debug.Assert(currentChar == '#'); + if (i + 1 + substring.Length > triviaString.Length) + { + return false; + } + + return triviaString.AsSpan()[(i + 1)..].StartsWith(substring.AsSpan()); + } + + default: + if (!SyntaxFacts.IsWhitespace(currentChar)) + { + _isOnlyWhitespaceOnLine = false; + } + break; + } + } + } + break; + case var kind: + throw new InvalidOperationException($"Unexpected trivia kind: {kind}."); }; return Stay(EndToken(tokenType)); @@ -567,23 +710,19 @@ private SyntaxTokenParser.Result GetNextResult(NextResultType expectedType) // result and the current result, as the current result fully subsumes it. Debug.Assert(_resultCache[^1].result is { Token.FullSpan.Length: 0 }); Debug.Assert(!nextResult.Token.HasLeadingTrivia); - _resultCache[^1] = (nextResult.Token.FullSpan.Start, nextResult); + _resultCache[^1] = (nextResult.Token.FullSpan.Start, nextResult, _isOnlyWhitespaceOnLine); } else { - _resultCache.Add((nextResult.Token.FullSpan.Start, nextResult)); + _resultCache.Add((nextResult.Token.FullSpan.Start, nextResult, _isOnlyWhitespaceOnLine)); } - return nextResult; - } + if (!nextResult.Token.IsKind(CSharpSyntaxKind.None)) + { + _isOnlyWhitespaceOnLine = false; + } - private void AddResetPoint() - { - // We want to make it easy to reset the tokenizer back to just before this token; we can do that very simply by trying to parse - // leading trivia, which gives us a reset point. We know that we can't have any leading trivia, since we're on an `@` character. - var nextResult = GetNextResult(NextResultType.LeadingTrivia); - Debug.Assert(nextResult.Token.IsKind(CSharpSyntaxKind.None)); - Debug.Assert(nextResult.Token.FullSpan.Length == 0); + return nextResult; } public override void Reset(int position) @@ -596,13 +735,19 @@ public override void Reset(int position) // If this ever changes, we can consider doing a binary search at that point. for (var i = _resultCache.Count - 1; i >= 0; i--) { - var (currentPosition, currentResult) = _resultCache[i]; + var (currentPosition, currentResult, isOnlyWhitespaceOnLine) = _resultCache[i]; if (currentPosition == position) { // We found an exact match, so we can reset to it directly. _roslynTokenParser.ResetTo(currentResult); + _isOnlyWhitespaceOnLine = isOnlyWhitespaceOnLine; _resultCache.RemoveAt(i); base.CurrentState = (int)RoslynCSharpTokenizerState.Start; +#if DEBUG + var oldIsOnlyWhitespaceOnLine = _isOnlyWhitespaceOnLine; + ResetIsOnlyWhitespaceOnLine(); + Debug.Assert(isOnlyWhitespaceOnLine == _isOnlyWhitespaceOnLine); +#endif return; } else if (currentPosition < position) @@ -614,6 +759,8 @@ public override void Reset(int position) _roslynTokenParser.ResetTo(currentResult); _roslynTokenParser.SkipForwardTo(position); base.CurrentState = (int)RoslynCSharpTokenizerState.Start; + // Can't reuse the isOnlyWhitespaceOnLine value, since we're not before the start of the result anymore. + ResetIsOnlyWhitespaceOnLine(); return; } else @@ -629,7 +776,7 @@ public override void Dispose() { base.Dispose(); _roslynTokenParser.Dispose(); - ListPool<(int, SyntaxTokenParser.Result)>.Default.Return(_resultCache); + ListPool<(int, SyntaxTokenParser.Result, bool)>.Default.Return(_resultCache); } private enum NextResultType diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Legacy/TokenizerBackedParser.cs b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Legacy/TokenizerBackedParser.cs index 812fab220d4..f265a1a60ae 100644 --- a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Legacy/TokenizerBackedParser.cs +++ b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Legacy/TokenizerBackedParser.cs @@ -39,9 +39,9 @@ internal abstract class TokenizerBackedParser : ParserBase, IDisposa return IsSpacingToken(token) || token.Kind == SyntaxKind.CSharpComment; }; - protected static readonly Func IsSpacingTokenIncludingNewLinesAndComments = (token) => + protected static readonly Func IsSpacingTokenIncludingNewLinesAndCommentsAndCSharpDirectives = (token) => { - return IsSpacingTokenIncludingNewLines(token) || token.Kind == SyntaxKind.CSharpComment; + return IsSpacingTokenIncludingNewLines(token) || token.Kind is SyntaxKind.CSharpComment or SyntaxKind.CSharpDirective or SyntaxKind.CSharpDisabledText; }; protected TokenizerBackedParser(LanguageCharacteristics language, ParserContext context) diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/RazorDiagnosticFactory.cs b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/RazorDiagnosticFactory.cs index 8c36e2fe36d..f44420ea1f7 100644 --- a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/RazorDiagnosticFactory.cs +++ b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/RazorDiagnosticFactory.cs @@ -364,6 +364,30 @@ public static RazorDiagnostic CreateParsing_UnexpectedIdentifier(SourceSpan loca public static RazorDiagnostic CreateParsing_DirectiveExpectsIdentifierOrExpression(SourceSpan location, string directiveName) => RazorDiagnostic.Create(Parsing_DirectiveExpectsIdentifierOrExpression, location, directiveName); + internal static readonly RazorDiagnosticDescriptor Parsing_DefineAndUndefNotAllowed = + new($"{DiagnosticPrefix}1042", + Resources.Define_and_undef_cannot_be_used_in_razor_markup, + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic CreateParsing_DefineAndUndefNotAllowed(SourceSpan location) + => RazorDiagnostic.Create(Parsing_DefineAndUndefNotAllowed, location); + + internal static readonly RazorDiagnosticDescriptor Parsing_PreprocessorDirectivesMustBeAtTheStartOfLine = + new($"{DiagnosticPrefix}1043", + Resources.Directives_must_be_at_the_start_of_the_line, + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic CreateParsing_PreprocessorDirectivesMustBeAtTheStartOfLine(SourceSpan location) + => RazorDiagnostic.Create(Parsing_PreprocessorDirectivesMustBeAtTheStartOfLine, location); + + internal static readonly RazorDiagnosticDescriptor Parsing_PossibleMisplacedPreprocessorDirective = + new($"{DiagnosticPrefix}1044", + Resources.Possible_preprocessor_directive_is_misplaced, + RazorDiagnosticSeverity.Warning); + + public static RazorDiagnostic CreateParsing_PossibleMisplacedPreprocessorDirective(SourceSpan location) + => RazorDiagnostic.Create(Parsing_PossibleMisplacedPreprocessorDirective, location); + #endregion #region Semantic Errors @@ -613,14 +637,6 @@ public static RazorDiagnostic CreateTagHelper_InvalidBoundAttributeParameterName public static RazorDiagnostic CreateTagHelper_InvalidBoundDirectiveAttributeName(string tagHelperDisplayName, string propertyDisplayName, string invalidName) => RazorDiagnostic.Create(TagHelper_InvalidBoundDirectiveAttributeName, tagHelperDisplayName, propertyDisplayName, invalidName); - internal static readonly RazorDiagnosticDescriptor TagHelper_InvalidBoundDirectiveAttributePrefix = - new($"{DiagnosticPrefix}3015", - Resources.TagHelper_InvalidBoundDirectiveAttributePrefix, - RazorDiagnosticSeverity.Error); - - public static RazorDiagnostic CreateTagHelper_InvalidBoundDirectiveAttributePrefix(string tagHelperDisplayName, string propertyDisplayName, string invalidName) - => RazorDiagnostic.Create(TagHelper_InvalidBoundDirectiveAttributePrefix, tagHelperDisplayName, propertyDisplayName, invalidName); - internal static readonly RazorDiagnosticDescriptor TagHelper_InvalidRequiredDirectiveAttributeName = new($"{DiagnosticPrefix}3016", Resources.TagHelper_InvalidRequiredDirectiveAttributeName, @@ -629,6 +645,14 @@ public static RazorDiagnostic CreateTagHelper_InvalidBoundDirectiveAttributePref public static RazorDiagnostic CreateTagHelper_InvalidRequiredDirectiveAttributeName(string propertyDisplayName, string invalidName) => RazorDiagnostic.Create(TagHelper_InvalidRequiredDirectiveAttributeName, propertyDisplayName, invalidName); + internal static readonly RazorDiagnosticDescriptor TagHelper_InvalidBoundDirectiveAttributePrefix = + new($"{DiagnosticPrefix}3017", + Resources.TagHelper_InvalidBoundDirectiveAttributePrefix, + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic CreateTagHelper_InvalidBoundDirectiveAttributePrefix(string tagHelperDisplayName, string propertyDisplayName, string invalidName) + => RazorDiagnostic.Create(TagHelper_InvalidBoundDirectiveAttributePrefix, tagHelperDisplayName, propertyDisplayName, invalidName); + #endregion #region Rewriter Errors diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Resources.resx b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Resources.resx index f469eb79b96..de48352a348 100644 --- a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Resources.resx +++ b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Resources.resx @@ -1,17 +1,17 @@ - @@ -598,4 +598,13 @@ Adds the C# using directive to the generated view. + + '#define' and '#undef' cannot be used in razor markup. + + + C# preprocessor directives must be at the start of the line, except for whitespace. + + + Possible C# preprocessor directive is misplaced. C# preprocessor directives must be at the start of the line, except for whitespace. + diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Syntax/SyntaxKind.cs b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Syntax/SyntaxKind.cs index f549b3f2f97..751b55670c9 100644 --- a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Syntax/SyntaxKind.cs +++ b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Syntax/SyntaxKind.cs @@ -89,6 +89,8 @@ internal enum SyntaxKind : byte RealLiteral, CharacterLiteral, StringLiteral, + CSharpDirective, + CSharpDisabledText, // CSharp operators CSharpOperator, diff --git a/src/Compiler/test/Microsoft.NET.Sdk.Razor.SourceGenerators.Tests/RazorSourceGeneratorTests.cs b/src/Compiler/test/Microsoft.NET.Sdk.Razor.SourceGenerators.Tests/RazorSourceGeneratorTests.cs index 3ff04a92289..9d5de9e89e6 100644 --- a/src/Compiler/test/Microsoft.NET.Sdk.Razor.SourceGenerators.Tests/RazorSourceGeneratorTests.cs +++ b/src/Compiler/test/Microsoft.NET.Sdk.Razor.SourceGenerators.Tests/RazorSourceGeneratorTests.cs @@ -1405,7 +1405,7 @@ public override void Process(TagHelperContext context, TagHelperOutput output) Assert.Single(result.GeneratedSources); } - [Fact(Skip = "PROTOTYPE"), WorkItem("https://github.com/dotnet/razor/issues/7049")] + [Fact, WorkItem("https://github.com/dotnet/razor/issues/7049")] public async Task SourceGenerator_CshtmlFiles_TagHelperInFunction_ManualSuppression() { // Arrange diff --git a/src/Shared/Microsoft.AspNetCore.Razor.Test.Common/ErrorCode.cs b/src/Shared/Microsoft.AspNetCore.Razor.Test.Common/ErrorCode.cs index feb1b0102b5..14f6c4b3859 100644 --- a/src/Shared/Microsoft.AspNetCore.Razor.Test.Common/ErrorCode.cs +++ b/src/Shared/Microsoft.AspNetCore.Razor.Test.Common/ErrorCode.cs @@ -19,13 +19,20 @@ public enum ErrorCode ERR_SingleTypeNameNotFound = 246, ERR_CantInferMethTypeArgs = 411, WRN_UnreferencedFieldAssg = 414, + ERR_VariableUsedBeforeDeclaration = 841, ERR_SemicolonExpected = 1002, ERR_SyntaxError = 1003, + ERR_EndOfPPLineExpected = 1025, ERR_CloseParenExpected = 1026, + ERR_EndifDirectiveExpected = 1027, + ERR_UnexpectedDirective = 1028, ERR_TypeExpected = 1031, + ERR_PPDefFollowsToken = 1032, + ERR_BadDirectivePlacement = 1040, ERR_DottedTypeNameNotFoundInNSFwd = 1069, ERR_BadArgCount = 1501, ERR_BadArgType = 1503, + ERR_RbraceExpected = 1513, ERR_InvalidMemberDecl = 1519, ERR_InvalidExprTerm = 1525, ERR_CantConvAnonMethReturns = 1662, diff --git a/src/Shared/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorIntegrationTestBase.cs b/src/Shared/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorIntegrationTestBase.cs index 2e0fa3b8772..b64b99f7a4f 100644 --- a/src/Shared/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorIntegrationTestBase.cs +++ b/src/Shared/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorIntegrationTestBase.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#nullable disable - using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -15,6 +13,7 @@ using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Razor; using Microsoft.CodeAnalysis.Test.Utilities; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Xunit; using Xunit.Sdk; @@ -29,7 +28,7 @@ public class RazorIntegrationTestBase // so making sure it doesn't happen for each test. protected static readonly CSharpCompilation DefaultBaseCompilation; - private static CSharpParseOptions CSharpParseOptions { get; } + protected static CSharpParseOptions CSharpParseOptions { get; } static RazorIntegrationTestBase() { @@ -82,7 +81,7 @@ public RazorIntegrationTestBase() /// Gets a hardcoded document kind to be added to each code document that's created. This can /// be used to generate components. /// - internal virtual string FileKind { get; } + internal virtual string? FileKind { get; } internal virtual VirtualRazorProjectFileSystem FileSystem { get; } @@ -90,7 +89,7 @@ public RazorIntegrationTestBase() // for the baseline tests that exercise line mappings. Even though we normalize // newlines for testing, the difference between platforms affects the data through // the *count* of characters written. - internal virtual string LineEnding { get; } + internal virtual string? LineEnding { get; } internal virtual string PathSeparator { get; } @@ -101,7 +100,7 @@ public RazorIntegrationTestBase() internal virtual string WorkingDirectory { get; } // intentionally private - we don't want individual tests messing with the project engine - private RazorProjectEngine CreateProjectEngine(RazorConfiguration configuration, MetadataReference[] references, bool supportLocalizedComponentNames) + private RazorProjectEngine CreateProjectEngine(RazorConfiguration configuration, MetadataReference[] references, bool supportLocalizedComponentNames, CSharpParseOptions? csharpParseOptions) { return RazorProjectEngine.Create(configuration, FileSystem, b => { @@ -130,13 +129,16 @@ private RazorProjectEngine CreateProjectEngine(RazorConfiguration configuration, References = references, }); - b.SetCSharpLanguageVersion(CSharpParseOptions.LanguageVersion); + csharpParseOptions ??= CSharpParseOptions; + + b.SetCSharpLanguageVersion(csharpParseOptions.LanguageVersion); + b.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, csharpParseOptions)); CompilerFeatures.Register(b); }); } - internal RazorProjectItem CreateProjectItem(string cshtmlRelativePath, string cshtmlContent, string fileKind = null, string cssScope = null) + internal RazorProjectItem CreateProjectItem(string cshtmlRelativePath, string cshtmlContent, string? fileKind = null, string? cssScope = null) { var fullPath = WorkingDirectory + PathSeparator + cshtmlRelativePath; @@ -174,11 +176,12 @@ protected CompileToCSharpResult CompileToCSharp(string cshtmlContent, params Dia protected CompileToCSharpResult CompileToCSharp( string cshtmlContent, - string cssScope = null, + string? cssScope = null, bool supportLocalizedComponentNames = false, bool nullableEnable = false, - RazorConfiguration configuration = null, - CSharpCompilation baseCompilation = null, + RazorConfiguration? configuration = null, + CSharpCompilation? baseCompilation = null, + CSharpParseOptions? csharpParseOptions = null, params DiagnosticDescription[] expectedCSharpDiagnostics) { return CompileToCSharp( @@ -189,18 +192,20 @@ protected CompileToCSharpResult CompileToCSharp( nullableEnable: nullableEnable, configuration: configuration, baseCompilation: baseCompilation, + csharpParseOptions: csharpParseOptions, expectedCSharpDiagnostics: expectedCSharpDiagnostics); } protected CompileToCSharpResult CompileToCSharp( string cshtmlRelativePath, string cshtmlContent, - string fileKind = null, - string cssScope = null, + string? fileKind = null, + string? cssScope = null, bool supportLocalizedComponentNames = false, bool nullableEnable = false, - RazorConfiguration configuration = null, - CSharpCompilation baseCompilation = null, + RazorConfiguration? configuration = null, + CSharpCompilation? baseCompilation = null, + CSharpParseOptions? csharpParseOptions = null, params DiagnosticDescription[] expectedCSharpDiagnostics) { if (DeclarationOnly && DesignTime) @@ -227,7 +232,7 @@ protected CompileToCSharpResult CompileToCSharp( { // The first phase won't include any metadata references for component discovery. This mirrors // what the build does. - var projectEngine = CreateProjectEngine(configuration, Array.Empty(), supportLocalizedComponentNames); + var projectEngine = CreateProjectEngine(configuration, Array.Empty(), supportLocalizedComponentNames, csharpParseOptions); RazorCodeDocument codeDocument; foreach (var item in AdditionalRazorItems) @@ -236,7 +241,7 @@ protected CompileToCSharpResult CompileToCSharp( codeDocument = projectEngine.ProcessDeclarationOnly(item); Assert.Empty(codeDocument.GetCSharpDocument().Diagnostics); - var syntaxTree = Parse(codeDocument.GetCSharpDocument().GeneratedCode, path: item.FilePath); + var syntaxTree = Parse(codeDocument.GetCSharpDocument().GeneratedCode, csharpParseOptions, path: item.FilePath); AdditionalSyntaxTrees.Add(syntaxTree); } @@ -249,6 +254,7 @@ protected CompileToCSharpResult CompileToCSharp( CodeDocument = codeDocument, Code = codeDocument.GetCSharpDocument().GeneratedCode, RazorDiagnostics = codeDocument.GetCSharpDocument().Diagnostics, + ParseOptions = csharpParseOptions, }; // Result of doing 'temp' compilation @@ -256,7 +262,7 @@ protected CompileToCSharpResult CompileToCSharp( // Add the 'temp' compilation as a metadata reference var references = baseCompilation.References.Concat(new[] { tempAssembly.Compilation.ToMetadataReference() }).ToArray(); - projectEngine = CreateProjectEngine(configuration, references, supportLocalizedComponentNames); + projectEngine = CreateProjectEngine(configuration, references, supportLocalizedComponentNames, csharpParseOptions); // Now update the any additional files foreach (var item in AdditionalRazorItems) @@ -266,7 +272,7 @@ protected CompileToCSharpResult CompileToCSharp( Assert.Empty(codeDocument.GetCSharpDocument().Diagnostics); // Replace the 'declaration' syntax tree - var syntaxTree = Parse(codeDocument.GetCSharpDocument().GeneratedCode, path: item.FilePath); + var syntaxTree = Parse(codeDocument.GetCSharpDocument().GeneratedCode, csharpParseOptions, path: item.FilePath); AdditionalSyntaxTrees.RemoveAll(st => st.FilePath == item.FilePath); AdditionalSyntaxTrees.Add(syntaxTree); } @@ -279,13 +285,14 @@ protected CompileToCSharpResult CompileToCSharp( CodeDocument = codeDocument, Code = codeDocument.GetCSharpDocument().GeneratedCode, RazorDiagnostics = codeDocument.GetCSharpDocument().Diagnostics, + ParseOptions = csharpParseOptions, }; } else { // For single phase compilation tests just use the base compilation's references. // This will include the built-in components. - var projectEngine = CreateProjectEngine(configuration, baseCompilation.References.ToArray(), supportLocalizedComponentNames); + var projectEngine = CreateProjectEngine(configuration, baseCompilation.References.ToArray(), supportLocalizedComponentNames, csharpParseOptions); var projectItem = CreateProjectItem(cshtmlRelativePath, cshtmlContent, fileKind, cssScope); @@ -309,6 +316,7 @@ protected CompileToCSharpResult CompileToCSharp( CodeDocument = codeDocument, Code = codeDocument.GetCSharpDocument().GeneratedCode, RazorDiagnostics = codeDocument.GetCSharpDocument().Diagnostics, + ParseOptions = csharpParseOptions, }; } } @@ -323,7 +331,7 @@ protected CompileToAssemblyResult CompileToAssembly(CompileToCSharpResult cSharp { var syntaxTrees = new[] { - Parse(cSharpResult.Code), + Parse(cSharpResult.Code, cSharpResult.ParseOptions), }; var compilation = cSharpResult.BaseCompilation.AddSyntaxTrees(syntaxTrees); @@ -383,9 +391,9 @@ protected INamedTypeSymbol CompileToComponent(CompileToAssemblyResult assemblyRe return componentType; } - protected static CSharpSyntaxTree Parse(string text, string path = null) + protected static CSharpSyntaxTree Parse(string text, CSharpParseOptions? parseOptions = null, string path = "") { - return (CSharpSyntaxTree)CSharpSyntaxTree.ParseText(text, CSharpParseOptions, path: path); + return (CSharpSyntaxTree)CSharpSyntaxTree.ParseText(text, parseOptions ?? CSharpParseOptions, path: path); } protected static void AssertSourceEquals(string expected, CompileToCSharpResult generated) @@ -393,7 +401,7 @@ protected static void AssertSourceEquals(string expected, CompileToCSharpResult // Normalize the paths inside the expected result to match the OS paths if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - var windowsPath = Path.Combine(ArbitraryWindowsPath, generated.CodeDocument.Source.RelativePath).Replace('/', '\\'); + var windowsPath = Path.Combine(ArbitraryWindowsPath, generated.CodeDocument.Source.RelativePath ?? "").Replace('/', '\\'); expected = expected.Replace(windowsPath, generated.CodeDocument.Source.FilePath); } @@ -404,17 +412,18 @@ protected static void AssertSourceEquals(string expected, CompileToCSharpResult protected class CompileToCSharpResult { // A compilation that can be used *with* this code to compile an assembly - public Compilation BaseCompilation { get; set; } - public RazorCodeDocument CodeDocument { get; set; } - public string Code { get; set; } - public IEnumerable RazorDiagnostics { get; set; } + public required Compilation BaseCompilation { get; set; } + public required RazorCodeDocument CodeDocument { get; set; } + public required string Code { get; set; } + public required IEnumerable RazorDiagnostics { get; set; } + public CSharpParseOptions? ParseOptions { get; set; } } protected class CompileToAssemblyResult { - public Compilation Compilation { get; set; } - public string VerboseLog { get; set; } - public IEnumerable CSharpDiagnostics { get; set; } + public required Compilation Compilation { get; set; } + public string? VerboseLog { get; set; } + public required IEnumerable CSharpDiagnostics { get; set; } } private class CompilationFailedException : XunitException @@ -469,7 +478,7 @@ private class SuppressChecksum : IConfigureRazorCodeGenerationOptionsFeature { public int Order => 0; - public RazorEngine Engine { get; set; } + public RazorEngine? Engine { get; set; } public void Configure(RazorCodeGenerationOptionsBuilder options) { @@ -481,7 +490,7 @@ private class SupportLocalizedComponentNames : IConfigureRazorCodeGenerationOpti { public int Order => 0; - public RazorEngine Engine { get; set; } + public RazorEngine? Engine { get; set; } public void Configure(RazorCodeGenerationOptionsBuilder options) { @@ -518,7 +527,7 @@ public TestImportProjectFeature(List imports) _imports = imports; } - public RazorProjectEngine ProjectEngine { get; set; } + public RazorProjectEngine? ProjectEngine { get; set; } public IReadOnlyList GetImports(RazorProjectItem projectItem) { diff --git a/src/Shared/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/ParserTestBase.cs b/src/Shared/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/ParserTestBase.cs index f5799fa242c..0e82c10641a 100644 --- a/src/Shared/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/ParserTestBase.cs +++ b/src/Shared/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/ParserTestBase.cs @@ -87,6 +87,7 @@ internal virtual void AssertSyntaxTreeNodeMatchesBaseline(RazorSyntaxTree syntax { // Write syntax tree baseline var baselineFullPath = Path.Combine(TestProjectRoot, baselineFileName); + Directory.CreateDirectory(Path.GetDirectoryName(baselineFullPath)); File.WriteAllText(baselineFullPath, SyntaxNodeSerializer.Serialize(root, _validateSpanEditHandlers), _baselineEncoding); // Write diagnostics baseline @@ -243,14 +244,19 @@ internal virtual void ParseDocumentTest(string document, bool designTime) ParseDocumentTest(document, null, designTime); } - internal virtual void ParseDocumentTest(string document, IEnumerable directives, bool designTime, string fileKind = null) + internal void ParseDocumentTest(string document, CSharpParseOptions options) { - ParseDocumentTest(RazorLanguageVersion.Latest, document, directives, designTime, fileKind); + ParseDocumentTest(document, directives: null, designTime: false, csharpParseOptions: options); } - internal virtual void ParseDocumentTest(RazorLanguageVersion version, string document, IEnumerable directives, bool designTime, string fileKind = null) + internal virtual void ParseDocumentTest(string document, IEnumerable directives, bool designTime, string fileKind = null, CSharpParseOptions csharpParseOptions = null) { - var result = ParseDocument(version, document, directives, designTime, fileKind: fileKind); + ParseDocumentTest(RazorLanguageVersion.Latest, document, directives, designTime, fileKind, csharpParseOptions); + } + + internal virtual void ParseDocumentTest(RazorLanguageVersion version, string document, IEnumerable directives, bool designTime, string fileKind = null, CSharpParseOptions csharpParseOptions = null) + { + var result = ParseDocument(version, document, directives, designTime, fileKind: fileKind, csharpParseOptions: csharpParseOptions); BaselineTest(result); }