diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpAutoCompleteTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpAutoCompleteTest.cs index 4264b5a66a..5ef32b1e8a 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpAutoCompleteTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpAutoCompleteTest.cs @@ -10,11 +10,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class CSharpAutoCompleteTest : CsHtmlCodeParserTestBase { - public CSharpAutoCompleteTest() - { - UseBaselineTests = true; - } - [Fact] public void FunctionsDirectiveAutoCompleteAtEOF() { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpBlockTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpBlockTest.cs index 04d75c98c5..f530020333 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpBlockTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpBlockTest.cs @@ -8,11 +8,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class CSharpBlockTest : CsHtmlCodeParserTestBase { - public CSharpBlockTest() - { - UseBaselineTests = true; - } - [Fact] public void ParseBlock_NestedCodeBlockWithCSharpAt() { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpDirectivesTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpDirectivesTest.cs index abba962a46..2452e64f88 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpDirectivesTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpDirectivesTest.cs @@ -11,11 +11,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class CSharpDirectivesTest : CsHtmlCodeParserTestBase { - public CSharpDirectivesTest() - { - UseBaselineTests = true; - } - [Fact] public void DirectiveDescriptor_FileScopedMultipleOccurring_CanHaveDuplicates() { @@ -921,13 +916,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var result = ParseCodeBlock(RazorLanguageVersion.Latest, document, descriptors, designTime: false); - if (UseBaselineTests && !IsTheory) - { - BaselineTest(result); - return; - } - - EvaluateResults(result, expected, expectedErrors); + BaselineTest(result); } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpErrorTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpErrorTest.cs index 4fb9fe7b6a..d4a31728b4 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpErrorTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpErrorTest.cs @@ -9,11 +9,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class CSharpErrorTest : CsHtmlCodeParserTestBase { - public CSharpErrorTest() - { - UseBaselineTests = true; - } - [Fact] public void ParseBlockHandlesQuotesAfterTransition() { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpExplicitExpressionTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpExplicitExpressionTest.cs index 18c32b67c3..8abae17490 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpExplicitExpressionTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpExplicitExpressionTest.cs @@ -8,11 +8,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class CSharpExplicitExpressionTest : CsHtmlCodeParserTestBase { - public CSharpExplicitExpressionTest() - { - UseBaselineTests = true; - } - [Fact] public void ParseBlockShouldOutputZeroLengthCodeSpanIfExplicitExpressionIsEmpty() { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpImplicitExpressionTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpImplicitExpressionTest.cs index 7c00bbeaa1..5ab4300ef7 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpImplicitExpressionTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpImplicitExpressionTest.cs @@ -7,11 +7,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class CSharpImplicitExpressionTest : CsHtmlCodeParserTestBase { - public CSharpImplicitExpressionTest() - { - UseBaselineTests = true; - } - [Fact] public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Bracket1() { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpNestedStatementsTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpNestedStatementsTest.cs index 96cbba4c7b..ee07b634e7 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpNestedStatementsTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpNestedStatementsTest.cs @@ -7,11 +7,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class CSharpNestedStatementsTest : CsHtmlCodeParserTestBase { - public CSharpNestedStatementsTest() - { - UseBaselineTests = true; - } - [Fact] public void NestedSimpleStatement() { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpRazorCommentsTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpRazorCommentsTest.cs index d9aa3aa40c..bcc8974b86 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpRazorCommentsTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpRazorCommentsTest.cs @@ -8,11 +8,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class CSharpRazorCommentsTest : CsHtmlMarkupParserTestBase { - public CSharpRazorCommentsTest() - { - UseBaselineTests = true; - } - [Fact] public void UnterminatedRazorComment() { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpReservedWordsTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpReservedWordsTest.cs index 57ac9757fc..eae67d0168 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpReservedWordsTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpReservedWordsTest.cs @@ -7,11 +7,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class CSharpReservedWordsTest : CsHtmlCodeParserTestBase { - public CSharpReservedWordsTest() - { - UseBaselineTests = true; - } - [Fact] public void ReservedWord() { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSectionTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSectionTest.cs index a1d686375a..2d05f57a29 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSectionTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSectionTest.cs @@ -9,11 +9,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class CSharpSectionTest : CsHtmlMarkupParserTestBase { - public CSharpSectionTest() - { - UseBaselineTests = true; - } - [Fact] public void ParseSectionBlockCapturesNewlineImmediatelyFollowing() { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSpecialBlockTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSpecialBlockTest.cs index 6908250386..9506de7405 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSpecialBlockTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSpecialBlockTest.cs @@ -8,11 +8,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class CSharpSpecialBlockTest : CsHtmlCodeParserTestBase { - public CSharpSpecialBlockTest() - { - UseBaselineTests = true; - } - [Fact] public void NamespaceImportInsideCodeBlockCausesError() { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpStatementTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpStatementTest.cs index 174ce6dc1a..ea167f4934 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpStatementTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpStatementTest.cs @@ -16,11 +16,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public class CSharpStatementTest : CsHtmlCodeParserTestBase { - public CSharpStatementTest() - { - UseBaselineTests = true; - } - [Fact] public void ForStatement() { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTemplateTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTemplateTest.cs index 1b69d3750c..619292fd96 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTemplateTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTemplateTest.cs @@ -8,12 +8,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class CSharpTemplateTest : CsHtmlCodeParserTestBase { - public CSharpTemplateTest() - { - UseBaselineTests = true; - } - - [Fact] public void ParseBlockHandlesSingleLineTemplate() { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpToMarkupSwitchTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpToMarkupSwitchTest.cs index adf71262af..128179ac25 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpToMarkupSwitchTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpToMarkupSwitchTest.cs @@ -8,11 +8,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class CSharpToMarkupSwitchTest : CsHtmlCodeParserTestBase { - public CSharpToMarkupSwitchTest() - { - UseBaselineTests = true; - } - [Fact] public void SingleAngleBracketDoesNotCauseSwitchIfOuterBlockIsTerminated() { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpVerbatimBlockTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpVerbatimBlockTest.cs index 2a96d2dcd6..7b38b1cbe1 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpVerbatimBlockTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpVerbatimBlockTest.cs @@ -10,11 +10,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { private const string TestExtraKeyword = "model"; - public CSharpVerbatimBlockTest() - { - UseBaselineTests = true; - } - [Fact] public void VerbatimBlock() { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpWhitespaceHandlingTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpWhitespaceHandlingTest.cs index 0542b64bcb..e9c028da7e 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpWhitespaceHandlingTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpWhitespaceHandlingTest.cs @@ -8,11 +8,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class CSharpWhitespaceHandlingTest : CsHtmlMarkupParserTestBase { - public CSharpWhitespaceHandlingTest() - { - UseBaselineTests = true; - } - [Fact] public void StatementBlockDoesNotAcceptTrailingNewlineIfNewlinesAreSignificantToAncestor() { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CodeParserTestBase.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CodeParserTestBase.cs index 6437faa292..c3425055b4 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CodeParserTestBase.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CodeParserTestBase.cs @@ -58,12 +58,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy SingleSpanBlockTest(document, document, blockKind, spanType, acceptedCharacters, expectedError); } - internal override void SingleSpanBlockTest(string document, string spanContent, BlockKindInternal blockKind, SpanKindInternal spanType, AcceptedCharactersInternal acceptedCharacters, params RazorDiagnostic[] expectedErrors) - { - var b = CreateSimpleBlockAndSpan(spanContent, blockKind, spanType, acceptedCharacters); - ParseBlockTest(document, b, expectedErrors ?? new RazorDiagnostic[0]); - } - internal void ImplicitExpressionTest(string input, string expected, AcceptedCharactersInternal acceptedCharacters, params RazorDiagnostic[] errors) { ParseBlockTest(SyntaxConstants.TransitionString + input); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/ExceptionHelpers.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/ExceptionHelpers.cs deleted file mode 100644 index c5ae54dea8..0000000000 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/ExceptionHelpers.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using Xunit; - -namespace Microsoft.AspNetCore.Razor.Language.Legacy -{ - public static class ExceptionHelpers - { - public static void ValidateArgumentException(string parameterName, string expectedMessage, ArgumentException exception) - { - Assert.Equal(string.Format("{0}{1}Parameter name: {2}", expectedMessage, Environment.NewLine, parameterName), exception.Message); - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlAttributeTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlAttributeTest.cs index 6fdf7f685f..1fae85afba 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlAttributeTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlAttributeTest.cs @@ -9,11 +9,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class HtmlAttributeTest : CsHtmlMarkupParserTestBase { - public HtmlAttributeTest() - { - UseBaselineTests = true; - } - [Fact] public void SymbolBoundAttributes_BeforeEqualWhitespace1() { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlBlockTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlBlockTest.cs index 6e3ca96b9e..d069d68d59 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlBlockTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlBlockTest.cs @@ -8,11 +8,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class HtmlBlockTest : CsHtmlMarkupParserTestBase { - public HtmlBlockTest() - { - UseBaselineTests = true; - } - [Fact] public void ParseBlockHandlesUnbalancedTripleDashHTMLComments() { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlDocumentTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlDocumentTest.cs index 7929c9a14c..0863f30168 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlDocumentTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlDocumentTest.cs @@ -12,11 +12,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { private static readonly TestFile Nested1000 = TestFile.Create("TestFiles/nested-1000.html", typeof(HtmlDocumentTest)); - public HtmlDocumentTest() - { - UseBaselineTests = true; - } - [Fact] public void ParseDocument_NestedCodeBlockWithMarkupSetsDotAsMarkup() { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlErrorTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlErrorTest.cs index 59a2b99854..fdb7a91523 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlErrorTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlErrorTest.cs @@ -7,11 +7,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class HtmlErrorTest : CsHtmlMarkupParserTestBase { - public HtmlErrorTest() - { - UseBaselineTests = true; - } - [Fact] public void ParseBlockAllowsInvalidTagNamesAsLongAsParserCanIdentifyEndTag() { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlTagsTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlTagsTest.cs index 21daa145ae..4b200db19e 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlTagsTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlTagsTest.cs @@ -28,11 +28,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy "wbr", }; - public HtmlTagsTest() - { - UseBaselineTests = true; - } - [Fact] public void EmptyTagNestsLikeNormalTag() { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlToCodeSwitchTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlToCodeSwitchTest.cs index 2bdf5ea638..66371b5d87 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlToCodeSwitchTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlToCodeSwitchTest.cs @@ -10,11 +10,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class HtmlToCodeSwitchTest : CsHtmlMarkupParserTestBase { - public HtmlToCodeSwitchTest() - { - UseBaselineTests = true; - } - [Fact] public void ParseBlockSwitchesWhenCharacterBeforeSwapIsNonAlphanumeric() { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/MarkupParserTestBase.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/MarkupParserTestBase.cs index 16b1f43c1f..d81ebee9e3 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/MarkupParserTestBase.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/MarkupParserTestBase.cs @@ -15,11 +15,5 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { return ParseHtmlBlock(version, document, directives, designTime); } - - internal virtual void SingleSpanDocumentTest(string document, BlockKindInternal blockKind, SpanKindInternal spanType) - { - var b = CreateSimpleBlockAndSpan(document, blockKind, spanType); - ParseDocumentTest(document, b); - } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/MiscUtils.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/MiscUtils.cs deleted file mode 100644 index e014d24830..0000000000 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/MiscUtils.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -#if DEBUG -using System.Diagnostics; -using System.Threading; -#endif -using Xunit; - -namespace Microsoft.AspNetCore.Razor.Language.Legacy -{ - class MiscUtils - { - public const int TimeoutInSeconds = 1; - - public static void DoWithTimeoutIfNotDebugging(Func withTimeout) - { -#if DEBUG - if (Debugger.IsAttached) - { - withTimeout(Timeout.Infinite); - } - else - { -#endif - Assert.True(withTimeout((int)TimeSpan.FromSeconds(TimeoutInSeconds).TotalMilliseconds), "Timeout expired!"); -#if DEBUG - } -#endif - } - } -} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/RazorParserTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/RazorParserTest.cs index 589a147e4c..15dacfdaf8 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/RazorParserTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/RazorParserTest.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System.IO; using System.Linq; using Xunit; @@ -26,7 +25,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var factory = new SpanFactory(); var parser = new RazorParser(); - // Act/Assert + // Act + var syntaxTree = parser.Parse(TestRazorSourceDocument.Create("foo @bar baz")); + + // Assert ParserTestBase.EvaluateResults(parser.Parse(TestRazorSourceDocument.Create("foo @bar baz")), new MarkupBlock( factory.Markup("foo "), diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperBlockRewriterTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperBlockRewriterTest.cs index 440b9486cd..04e468c99e 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperBlockRewriterTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperBlockRewriterTest.cs @@ -9,11 +9,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class TagHelperBlockRewriterTest : TagHelperRewritingTestBase { - public TagHelperBlockRewriterTest() - { - UseBaselineTests = true; - } - public static TagHelperDescriptor[] SymbolBoundAttributes_Descriptors = new[] { TagHelperDescriptorBuilder.Create("CatchAllTagHelper", "SomeAssembly") diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperParseTreeRewriterTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperParseTreeRewriterTest.cs index 3cc644cacb..c4454c18ef 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperParseTreeRewriterTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperParseTreeRewriterTest.cs @@ -10,11 +10,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class TagHelperParseTreeRewriterTest : TagHelperRewritingTestBase { - public TagHelperParseTreeRewriterTest() - { - UseBaselineTests = true; - } - public static TheoryData GetAttributeNameValuePairsData { get diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperRewritingTestBase.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperRewritingTestBase.cs index 86a73d1683..0181462c30 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperRewritingTestBase.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperRewritingTestBase.cs @@ -83,14 +83,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .OrderBy(error => error.Span.AbsoluteIndex) .ToList(); - if (UseBaselineTests && !IsTheory) - { - BaselineTest(actualTree, verifySyntaxTree: false, actualErrors.ToArray()); - return; - } - - EvaluateRazorErrors(actualErrors, expectedErrors.ToList()); - EvaluateParseTree(actualTree, expectedOutput); + BaselineTest(actualTree, verifySyntaxTree: false, actualErrors.ToArray()); } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/WhiteSpaceRewriterTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/WhiteSpaceRewriterTest.cs index c1dab94172..975912de80 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/WhiteSpaceRewriterTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/WhiteSpaceRewriterTest.cs @@ -8,11 +8,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class WhiteSpaceRewriterTest : CsHtmlMarkupParserTestBase { - public WhiteSpaceRewriterTest() - { - UseBaselineTests = true; - } - [Fact] public void Rewrite_Moves_Whitespace_Preceeding_ExpressionBlock_To_Parent_Block() { diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/ParserTestBase.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/ParserTestBase.cs index 34b9269fe0..49b4241ae6 100644 --- a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/ParserTestBase.cs +++ b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/ParserTestBase.cs @@ -28,8 +28,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private static readonly AsyncLocal _isTheory = new AsyncLocal(); #endif - internal static Block IgnoreOutput = new IgnoreOutputBlock(); - internal ParserTestBase() { Factory = CreateSpanFactory(); @@ -55,8 +53,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy protected string TestProjectRoot { get; } - protected bool UseBaselineTests { get; set; } - // Used by the test framework to set the 'base' name for test files. public static string FileName { @@ -107,6 +103,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy throw new InvalidOperationException(message); } + if (IsTheory) + { + var message = $"{nameof(AssertSyntaxTreeNodeMatchesBaseline)} should not be called from a [Theory] test."; + throw new InvalidOperationException(message); + } + var baselineFileName = Path.ChangeExtension(FileName, ".syntaxtree.txt"); var baselineDiagnosticsFileName = Path.ChangeExtension(FileName, ".diagnostics.txt"); @@ -218,7 +220,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { directives = directives ?? Array.Empty(); - var source = TestRazorSourceDocument.Create(document, filePath: null, normalizeNewLines: UseBaselineTests); + var source = TestRazorSourceDocument.Create(document, filePath: null, normalizeNewLines: true); var options = CreateParserOptions(version, directives, designTime); var context = new ParserContext(source, options); @@ -249,7 +251,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { directives = directives ?? Array.Empty(); - var source = TestRazorSourceDocument.Create(document, filePath: null, normalizeNewLines: UseBaselineTests); + var source = TestRazorSourceDocument.Create(document, filePath: null, normalizeNewLines: true); var options = CreateParserOptions(version, directives, designTime); var context = new ParserContext(source, options); @@ -280,7 +282,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { directives = directives ?? Array.Empty(); - var source = TestRazorSourceDocument.Create(document, filePath: null, normalizeNewLines: UseBaselineTests); + var source = TestRazorSourceDocument.Create(document, filePath: null, normalizeNewLines: true); var options = CreateParserOptions(version, directives, designTime); var context = new ParserContext(source, options); @@ -384,27 +386,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var result = ParseBlock(version, document, directives, designTime); - if (UseBaselineTests && !IsTheory) - { - BaselineTest(result); - return; - } - - if (FixupSpans) - { - SpancestryCorrector.Correct(expected); - - var span = expected.FindFirstDescendentSpan(); - span.ChangeStart(SourceLocation.Zero); - } - - SyntaxTreeVerifier.Verify(result); - SyntaxTreeVerifier.Verify(expected); - - if (!ReferenceEquals(expected, IgnoreOutput)) - { - EvaluateResults(result, expected, expectedErrors); - } + BaselineTest(result); } internal virtual void SingleSpanBlockTest(string document) @@ -441,31 +423,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var result = ParseBlock(document, designTime: false); - if (UseBaselineTests && !IsTheory) - { - BaselineTest(result); - return; - } - - var builder = new BlockBuilder(); - builder.Type = blockKind; - var expected = ConfigureAndAddSpanToBlock(builder, Factory.Span(spanType, spanContent, spanType == SpanKindInternal.Markup).Accepts(acceptedCharacters)); - - if (FixupSpans) - { - SpancestryCorrector.Correct(expected); - - var span = expected.FindFirstDescendentSpan(); - span.ChangeStart(SourceLocation.Zero); - } - - SyntaxTreeVerifier.Verify(result); - SyntaxTreeVerifier.Verify(expected); - - if (!ReferenceEquals(expected, IgnoreOutput)) - { - EvaluateResults(result, expected, expectedErrors); - } + BaselineTest(result); } internal virtual void ParseDocumentTest(string document) @@ -512,49 +470,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var result = ParseDocument(document, directives, designTime); - if (UseBaselineTests && !IsTheory) - { - BaselineTest(result); - return; - } - - if (FixupSpans) - { - SpancestryCorrector.Correct(expected); - - var span = expected.FindFirstDescendentSpan(); - span.ChangeStart(SourceLocation.Zero); - } - - SyntaxTreeVerifier.Verify(result); - SyntaxTreeVerifier.Verify(expected); - - if (!ReferenceEquals(expected, IgnoreOutput)) - { - EvaluateResults(result, expected, expectedErrors); - } - } - - [Conditional("PARSER_TRACE")] - private void WriteNode(int indent, SyntaxTreeNode node) - { - var content = node.ToString().Replace("\r", "\\r") - .Replace("\n", "\\n") - .Replace("{", "{{") - .Replace("}", "}}"); - if (indent > 0) - { - content = new String('.', indent * 2) + content; - } - WriteTraceLine(content); - var block = node as Block; - if (block != null) - { - foreach (SyntaxTreeNode child in block.Children) - { - WriteNode(indent + 1, child); - } - } + BaselineTest(result); } internal static void EvaluateResults(RazorSyntaxTree result, Block expectedRoot) @@ -594,35 +510,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } } - private static void EvaluateTagHelperAttribute( - ErrorCollector collector, - TagHelperAttributeNode actual, - TagHelperAttributeNode expected) - { - if (actual.Name != expected.Name) - { - collector.AddError("{0} - FAILED :: Attribute names do not match", expected.Name); - } - else - { - collector.AddMessage("{0} - PASSED :: Attribute names match", expected.Name); - } - - if (actual.AttributeStructure != expected.AttributeStructure) - { - collector.AddError("{0} - FAILED :: Attribute value styles do not match", expected.AttributeStructure.ToString()); - } - else - { - collector.AddMessage("{0} - PASSED :: Attribute value style match", expected.AttributeStructure); - } - - if (actual.AttributeStructure != AttributeStructure.Minimized) - { - EvaluateSyntaxTreeNode(collector, actual.Value, expected.Value); - } - } - private static void EvaluateSyntaxTreeNode(ErrorCollector collector, SyntaxTreeNode actual, SyntaxTreeNode expected) { if (actual == null) @@ -741,6 +628,35 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } } + private static void EvaluateTagHelperAttribute( + ErrorCollector collector, + TagHelperAttributeNode actual, + TagHelperAttributeNode expected) + { + if (actual.Name != expected.Name) + { + collector.AddError("{0} - FAILED :: Attribute names do not match", expected.Name); + } + else + { + collector.AddMessage("{0} - PASSED :: Attribute names match", expected.Name); + } + + if (actual.AttributeStructure != expected.AttributeStructure) + { + collector.AddError("{0} - FAILED :: Attribute value styles do not match", expected.AttributeStructure.ToString()); + } + else + { + collector.AddMessage("{0} - PASSED :: Attribute value style match", expected.AttributeStructure); + } + + if (actual.AttributeStructure != AttributeStructure.Minimized) + { + EvaluateSyntaxTreeNode(collector, actual.Value, expected.Value); + } + } + private static void AddPassedMessage(ErrorCollector collector, SyntaxTreeNode expected) { collector.AddMessage("{0} - PASSED", expected); @@ -801,35 +717,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Trace.WriteLine(string.Format(format, args)); } - internal virtual Block CreateSimpleBlockAndSpan(string spanContent, BlockKindInternal blockKind, SpanKindInternal spanType, AcceptedCharactersInternal acceptedCharacters = AcceptedCharactersInternal.Any) - { - var span = Factory.Span(spanType, spanContent, spanType == SpanKindInternal.Markup).Accepts(acceptedCharacters); - var b = new BlockBuilder() - { - Type = blockKind - }; - return ConfigureAndAddSpanToBlock(b, span); - } - - internal virtual Block ConfigureAndAddSpanToBlock(BlockBuilder block, SpanConstructor span) - { - switch (block.Type) - { - case BlockKindInternal.Markup: - span.With(new MarkupChunkGenerator()); - break; - case BlockKindInternal.Statement: - span.With(new StatementChunkGenerator()); - break; - case BlockKindInternal.Expression: - block.ChunkGenerator = new ExpressionChunkGenerator(); - span.With(new ExpressionChunkGenerator()); - break; - } - block.Children.Add(span); - return block.Build(); - } - private static RazorParserOptions CreateParserOptions( RazorLanguageVersion version, IEnumerable directives, @@ -841,46 +728,5 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy parseLeadingDirectives: false, version: version); } - - private class IgnoreOutputBlock : Block - { - public IgnoreOutputBlock() : base(BlockKindInternal.Template, new SyntaxTreeNode[0], null) { } - } - - // Corrects the parents and previous/next information for spans - internal class SpancestryCorrector : ParserVisitor - { - private SpancestryCorrector() - { - } - - protected Block CurrentBlock { get; set; } - - protected Span LastSpan { get; set; } - - public static void Correct(Block block) - { - new SpancestryCorrector().VisitBlock(block); - } - - public override void VisitBlock(Block block) - { - CurrentBlock = block; - base.VisitBlock(block); - } - - public override void VisitSpan(Span span) - { - span.Parent = CurrentBlock; - - span.Previous = LastSpan; - if (LastSpan != null) - { - LastSpan.Next = span; - } - - LastSpan = span; - } - } } } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/SyntaxTreeNodeWriter.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/SyntaxTreeNodeWriter.cs index b0a268d0c6..5bf344a4d3 100644 --- a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/SyntaxTreeNodeWriter.cs +++ b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/SyntaxTreeNodeWriter.cs @@ -40,7 +40,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Write(tagHelperBlock.TagName); // Write descriptors - foreach (var descriptor in tagHelperBlock.Binding.Descriptors) + foreach (var descriptor in tagHelperBlock.Binding?.Descriptors ?? Array.Empty()) { WriteSeparator();