From 642a2f57893d7be987216e6cc76fde80fbd80884 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Thu, 24 Jan 2019 12:42:10 -0800 Subject: [PATCH] Final cleanup to remove all traces of ParseBlockTest (dotnet/aspnetcore-tooling#169) \n\nCommit migrated from https://github.com/dotnet/aspnetcore-tooling/commit/e1608721428fb79fbaa0f42cdd0896e80a884356 --- .../Language/Legacy/ParserTestBase.cs | 85 +------------------ .../Language/SyntaxTreeVerifier.cs | 5 +- 2 files changed, 4 insertions(+), 86 deletions(-) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/ParserTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/ParserTestBase.cs index 7338819a95..15b9138276 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/ParserTestBase.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/ParserTestBase.cs @@ -171,18 +171,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return Regex.Replace(content, "(? directives, bool designTime); - internal RazorSyntaxTree ParseDocument(string document, bool designTime = false, IEnumerable directives = null, RazorParserFeatureFlags featureFlags = null) { return ParseDocument(RazorLanguageVersion.Latest, document, directives, designTime, featureFlags); @@ -218,85 +216,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return syntaxTree; } - internal virtual RazorSyntaxTree ParseHtmlBlock(RazorLanguageVersion version, string document, IEnumerable directives, bool designTime = false) - { - directives = directives ?? Array.Empty(); - - var source = TestRazorSourceDocument.Create(document, filePath: null, relativePath: null, normalizeNewLines: true); - - var options = CreateParserOptions(version, directives, designTime); - var context = new ParserContext(source, options); - - var codeParser = new CSharpCodeParser(directives, context); - var markupParser = new HtmlMarkupParser(context); - - codeParser.HtmlParser = markupParser; - markupParser.CodeParser = codeParser; - - var root = markupParser.ParseBlock().CreateRed(); - - var diagnostics = context.ErrorSink.Errors; - - var syntaxTree = RazorSyntaxTree.Create(root, source, diagnostics, options); - - return syntaxTree; - } - - internal virtual RazorSyntaxTree ParseCodeBlock( - RazorLanguageVersion version, - string document, - IEnumerable directives, - bool designTime) - { - directives = directives ?? Array.Empty(); - - var source = TestRazorSourceDocument.Create(document, filePath: null, relativePath: null, normalizeNewLines: true); - - var options = CreateParserOptions(version, directives, designTime); - var context = new ParserContext(source, options); - - var codeParser = new CSharpCodeParser(directives, context); - var markupParser = new HtmlMarkupParser(context); - - codeParser.HtmlParser = markupParser; - markupParser.CodeParser = codeParser; - - var root = codeParser.ParseBlock().CreateRed(); - - var diagnostics = context.ErrorSink.Errors; - - var syntaxTree = RazorSyntaxTree.Create(root, source, diagnostics, options); - - return syntaxTree; - } - - internal virtual void ParseBlockTest(string document, int? expectedParseLength = null) - { - ParseBlockTest(document, null, false, expectedParseLength); - } - - internal virtual void ParseBlockTest(string document, bool designTime, int? expectedParseLength = null) - { - ParseBlockTest(document, null, designTime, expectedParseLength); - } - - internal virtual void ParseBlockTest(string document, IEnumerable directives, int? expectedParseLength = null) - { - ParseBlockTest(document, directives, false, expectedParseLength); - } - - internal virtual void ParseBlockTest(string document, IEnumerable directives, bool designTime, int? expectedParseLength = null) - { - ParseBlockTest(RazorLanguageVersion.Latest, document, directives, designTime, expectedParseLength); - } - - internal virtual void ParseBlockTest(RazorLanguageVersion version, string document, IEnumerable directives, bool designTime, int? expectedParseLength = null) - { - var result = ParseBlock(version, document, directives, designTime); - - BaselineTest(result, expectedParseLength: expectedParseLength); - } - internal virtual void ParseDocumentTest(string document) { ParseDocumentTest(document, null, false); diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common/Language/SyntaxTreeVerifier.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common/Language/SyntaxTreeVerifier.cs index f0627432cb..f4f416616c 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common/Language/SyntaxTreeVerifier.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common/Language/SyntaxTreeVerifier.cs @@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Verifies recursively that a syntax tree has no gaps in terms of position/location. internal class SyntaxTreeVerifier { - public static void Verify(RazorSyntaxTree syntaxTree, bool ensureFullFidelity = true, int? expectedParseLength = null) + public static void Verify(RazorSyntaxTree syntaxTree, bool ensureFullFidelity = true) { var verifier = new Verifier(syntaxTree.Source); verifier.Visit(syntaxTree.Root); @@ -21,8 +21,7 @@ namespace Microsoft.AspNetCore.Razor.Language { var syntaxTreeString = syntaxTree.Root.ToFullString(); var builder = new StringBuilder(syntaxTree.Source.Length); - var sourceLength = expectedParseLength ?? syntaxTree.Source.Length; - for (var i = 0; i < sourceLength; i++) + for (var i = 0; i < syntaxTree.Source.Length; i++) { builder.Append(syntaxTree.Source[i]); }