From acbbdf0b2c3ae58f3df4c0cebaabb2b018ac8ede Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Sun, 19 Mar 2017 11:18:40 -0700 Subject: [PATCH] Rename BlockType -> BlockKind Also moved BlockKind and SpanKind out of .Legacy --- .../{Legacy/BlockType.cs => BlockKind.cs} | 4 +- .../Legacy/Block.cs | 4 +- .../Legacy/BlockBuilder.cs | 2 +- .../Legacy/CSharpCodeParser.cs | 28 +++--- .../Legacy/HtmlMarkupParser.cs | 22 ++--- .../Legacy/SyntaxTreeBuilder.cs | 2 +- .../Legacy/TagHelperBlockBuilder.cs | 4 +- .../Legacy/TagHelperBlockRewriter.cs | 2 +- .../Legacy/TagHelperParseTreeRewriter.cs | 8 +- .../Legacy/TokenizerBackedParser.cs | 2 +- .../Legacy/WhiteSpaceRewriter.cs | 2 +- .../{Legacy => }/SpanKind.cs | 4 +- .../HtmlNodeOptimizationPassTest.cs | 2 +- .../Legacy/BlockTest.cs | 6 +- .../Legacy/BlockTypes.cs | 32 +++---- .../Legacy/CSharpBlockTest.cs | 92 +++++++++---------- .../Legacy/CSharpErrorTest.cs | 8 +- .../Legacy/CodeParserTestBase.cs | 24 ++--- .../Legacy/HtmlBlockTest.cs | 8 +- .../Legacy/HtmlDocumentTest.cs | 8 +- .../Legacy/MarkupParserTestBase.cs | 4 +- .../Legacy/ParserTestBase.cs | 36 ++++---- .../Legacy/TagHelperParseTreeRewriterTest.cs | 2 +- 23 files changed, 153 insertions(+), 153 deletions(-) rename src/Microsoft.AspNetCore.Razor.Evolution/{Legacy/BlockType.cs => BlockKind.cs} (83%) rename src/Microsoft.AspNetCore.Razor.Evolution/{Legacy => }/SpanKind.cs (76%) diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/BlockType.cs b/src/Microsoft.AspNetCore.Razor.Evolution/BlockKind.cs similarity index 83% rename from src/Microsoft.AspNetCore.Razor.Evolution/Legacy/BlockType.cs rename to src/Microsoft.AspNetCore.Razor.Evolution/BlockKind.cs index fac152aea9..2f020c191f 100644 --- a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/BlockType.cs +++ b/src/Microsoft.AspNetCore.Razor.Evolution/BlockKind.cs @@ -1,9 +1,9 @@ // 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. -namespace Microsoft.AspNetCore.Razor.Evolution.Legacy +namespace Microsoft.AspNetCore.Razor.Evolution { - internal enum BlockType + public enum BlockKind { // Code Statement, diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/Block.cs b/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/Block.cs index 57505f39bf..b83bcfd36c 100644 --- a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/Block.cs +++ b/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/Block.cs @@ -17,7 +17,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy source.Reset(); } - protected Block(BlockType? type, IReadOnlyList children, IParentChunkGenerator generator) + protected Block(BlockKind? type, IReadOnlyList children, IParentChunkGenerator generator) { if (type == null) { @@ -36,7 +36,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy } public IParentChunkGenerator ChunkGenerator { get; } - public BlockType Type { get; } + public BlockKind Type { get; } public IReadOnlyList Children { get; } diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/BlockBuilder.cs b/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/BlockBuilder.cs index be23d9e2ff..f273cadced 100644 --- a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/BlockBuilder.cs +++ b/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/BlockBuilder.cs @@ -21,7 +21,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy public IParentChunkGenerator ChunkGenerator { get; set; } - public BlockType? Type { get; set; } + public BlockKind? Type { get; set; } public List Children { get; private set; } diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/CSharpCodeParser.cs b/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/CSharpCodeParser.cs index 373f2af6ea..f4ef8f5b8b 100644 --- a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/CSharpCodeParser.cs +++ b/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/CSharpCodeParser.cs @@ -186,7 +186,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy Span.Start = CurrentLocation; // Unless changed, the block is a statement block - using (Context.Builder.StartBlock(BlockType.Statement)) + using (Context.Builder.StartBlock(BlockKind.Statement)) { NextToken(); @@ -259,7 +259,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy { if (CurrentSymbol.Type == CSharpSymbolType.LeftParenthesis) { - Context.Builder.CurrentBlock.Type = BlockType.Expression; + Context.Builder.CurrentBlock.Type = BlockKind.Expression; Context.Builder.CurrentBlock.ChunkGenerator = new ExpressionChunkGenerator(); ExplicitExpression(); return; @@ -287,7 +287,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy CurrentSymbol.Content.Length); } - Context.Builder.CurrentBlock.Type = BlockType.Expression; + Context.Builder.CurrentBlock.Type = BlockKind.Expression; Context.Builder.CurrentBlock.ChunkGenerator = new ExpressionChunkGenerator(); ImplicitExpression(); return; @@ -306,7 +306,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy } // Invalid character - Context.Builder.CurrentBlock.Type = BlockType.Expression; + Context.Builder.CurrentBlock.Type = BlockKind.Expression; Context.Builder.CurrentBlock.ChunkGenerator = new ExpressionChunkGenerator(); AddMarkerSymbolIfNecessary(); Span.ChunkGenerator = new ExpressionChunkGenerator(); @@ -406,7 +406,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy private void ImplicitExpression(AcceptedCharacters acceptedCharacters) { - Context.Builder.CurrentBlock.Type = BlockType.Expression; + Context.Builder.CurrentBlock.Type = BlockKind.Expression; Context.Builder.CurrentBlock.ChunkGenerator = new ExpressionChunkGenerator(); using (PushSpanConfig(span => @@ -553,7 +553,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy // Read whitespace, but not newlines // If we're not inserting a marker span, we don't need to capture whitespace if (!Context.WhiteSpaceIsSignificantToAncestorBlock && - Context.Builder.CurrentBlock.Type != BlockType.Expression && + Context.Builder.CurrentBlock.Type != BlockKind.Expression && captureWhitespaceToEndOfLine && !Context.DesignTimeMode && !IsNested) @@ -637,7 +637,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy private void Template() { - if (Context.Builder.ActiveBlocks.Any(block => block.Type == BlockType.Template)) + if (Context.Builder.ActiveBlocks.Any(block => block.Type == BlockKind.Template)) { Context.ErrorSink.OnError( CurrentStart, @@ -645,7 +645,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy length: 1 /* @ */); } Output(SpanKind.Code); - using (Context.Builder.StartBlock(BlockType.Template)) + using (Context.Builder.StartBlock(BlockKind.Template)) { Context.Builder.CurrentBlock.ChunkGenerator = new TemplateBlockChunkGenerator(); PutCurrentBack(); @@ -749,7 +749,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy AcceptAndMoveNext(); Span.EditHandler.AcceptedCharacters = AcceptedCharacters.None; Span.ChunkGenerator = SpanChunkGenerator.Null; - Context.Builder.CurrentBlock.Type = BlockType.Directive; + Context.Builder.CurrentBlock.Type = BlockKind.Directive; CompleteBlock(); Output(SpanKind.MetaCode); } @@ -758,7 +758,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy { HandleKeyword(topLevel, () => { - Context.Builder.CurrentBlock.Type = BlockType.Expression; + Context.Builder.CurrentBlock.Type = BlockKind.Expression; Context.Builder.CurrentBlock.ChunkGenerator = new ExpressionChunkGenerator(); ImplicitExpression(); }); @@ -846,7 +846,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy private void UsingDeclaration() { // Set block type to directive - Context.Builder.CurrentBlock.Type = BlockType.Directive; + Context.Builder.CurrentBlock.Type = BlockKind.Directive; var start = CurrentStart; if (At(CSharpSymbolType.Identifier)) @@ -1484,7 +1484,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy private void HandleDirective(DirectiveDescriptor descriptor) { - Context.Builder.CurrentBlock.Type = BlockType.Directive; + Context.Builder.CurrentBlock.Type = BlockKind.Directive; Context.Builder.CurrentBlock.ChunkGenerator = new DirectiveChunkGenerator(descriptor); AssertDirective(descriptor.Name); @@ -1703,7 +1703,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy var keywordStartLocation = Span.Start; // Set the block type - Context.Builder.CurrentBlock.Type = BlockType.Directive; + Context.Builder.CurrentBlock.Type = BlockKind.Directive; var keywordLength = Span.End.AbsoluteIndex - Span.Start.AbsoluteIndex; @@ -1760,7 +1760,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy AcceptAndMoveNext(); // Set the block type - Context.Builder.CurrentBlock.Type = BlockType.Directive; + Context.Builder.CurrentBlock.Type = BlockKind.Directive; var keywordLength = Span.End.AbsoluteIndex - Span.Start.AbsoluteIndex; diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/HtmlMarkupParser.cs b/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/HtmlMarkupParser.cs index d9a72da32e..8d7ad1b4dd 100644 --- a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/HtmlMarkupParser.cs +++ b/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/HtmlMarkupParser.cs @@ -272,7 +272,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy using (PushSpanConfig(DefaultMarkupSpan)) { - using (Context.Builder.StartBlock(BlockType.Markup)) + using (Context.Builder.StartBlock(BlockKind.Markup)) { Span.Start = CurrentLocation; @@ -388,7 +388,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy if (!EndOfFile && !atSpecialTag) { // Start a Block tag. This is used to wrap things like

or etc. - tagBlockWrapper = Context.Builder.StartBlock(BlockType.Tag); + tagBlockWrapper = Context.Builder.StartBlock(BlockKind.Tag); } if (EndOfFile) @@ -767,7 +767,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy // content (if the previous attribute was malformed). Output(SpanKind.Markup); - using (Context.Builder.StartBlock(BlockType.Markup)) + using (Context.Builder.StartBlock(BlockKind.Markup)) { Accept(whitespace); Accept(name); @@ -782,7 +782,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy Output(SpanKind.Markup); // Start a new markup block for the attribute - using (Context.Builder.StartBlock(BlockType.Markup)) + using (Context.Builder.StartBlock(BlockKind.Markup)) { AttributePrefix(whitespace, name, whitespaceAfterAttributeName); } @@ -894,7 +894,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy if (NextIs(HtmlSymbolType.Transition)) { // Wrapping this in a block so that the ConditionalAttributeCollapser doesn't rewrite it. - using (Context.Builder.StartBlock(BlockType.Markup)) + using (Context.Builder.StartBlock(BlockKind.Markup)) { Accept(prefix); @@ -920,7 +920,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy Span.ChunkGenerator = SpanChunkGenerator.Null; // Dynamic value, start a new block and set the chunk generator - using (Context.Builder.StartBlock(BlockType.Markup)) + using (Context.Builder.StartBlock(BlockKind.Markup)) { Context.Builder.CurrentBlock.ChunkGenerator = new DynamicAttributeBlockChunkGenerator( @@ -1178,7 +1178,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy Accept(whiteSpace); Output(SpanKind.Markup); // Output the whitespace - using (Context.Builder.StartBlock(BlockType.Tag)) + using (Context.Builder.StartBlock(BlockKind.Tag)) { Accept(openAngle); Accept(solidus); @@ -1267,7 +1267,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy { Output(SpanKind.Markup); - using (Context.Builder.StartBlock(BlockType.Tag)) + using (Context.Builder.StartBlock(BlockKind.Tag)) { Span.EditHandler.AcceptedCharacters = endTagAcceptedCharacters; @@ -1444,7 +1444,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy using (PushSpanConfig(DefaultMarkupSpan)) { - using (Context.Builder.StartBlock(BlockType.Markup)) + using (Context.Builder.StartBlock(BlockKind.Markup)) { Span.Start = CurrentLocation; @@ -1491,7 +1491,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy Output(SpanKind.Markup); // Start tag block - var tagBlock = Context.Builder.StartBlock(BlockType.Tag); + var tagBlock = Context.Builder.StartBlock(BlockKind.Tag); AcceptAndMoveNext(); // Accept '<' @@ -1598,7 +1598,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy { Span.Start = CurrentLocation; - using (Context.Builder.StartBlock(BlockType.Markup)) + using (Context.Builder.StartBlock(BlockKind.Markup)) { NextToken(); CaseSensitive = caseSensitive; diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/SyntaxTreeBuilder.cs b/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/SyntaxTreeBuilder.cs index 870c182e11..395e875459 100644 --- a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/SyntaxTreeBuilder.cs +++ b/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/SyntaxTreeBuilder.cs @@ -49,7 +49,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy /// Starts a block of the specified type /// /// The type of the block to start - public IDisposable StartBlock(BlockType blockType) + public IDisposable StartBlock(BlockKind blockType) { var builder = new BlockBuilder() { Type = blockType }; _blockStack.Push(builder); diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperBlockBuilder.cs b/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperBlockBuilder.cs index 8b37f2a381..ed7f4763ea 100644 --- a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperBlockBuilder.cs +++ b/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperBlockBuilder.cs @@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy Start = start; BindingResult = bindingResult; Attributes = new List(attributes); - Type = BlockType.Tag; + Type = BlockKind.Tag; ChunkGenerator = new TagHelperChunkGenerator(); } @@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy TagName = tagName; TagMode = tagMode; Attributes = attributes; - Type = BlockType.Tag; + Type = BlockKind.Tag; ChunkGenerator = new TagHelperChunkGenerator(); // Children is IList, no AddRange diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperBlockRewriter.cs b/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperBlockRewriter.cs index c8955919c5..6f94ae75a5 100644 --- a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperBlockRewriter.cs +++ b/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperBlockRewriter.cs @@ -463,7 +463,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy { var spanBuilder = new SpanBuilder(span); - if (parentBlock.Type == BlockType.Expression && + if (parentBlock.Type == BlockKind.Expression && (spanBuilder.Kind == SpanKind.Transition || spanBuilder.Kind == SpanKind.MetaCode)) { diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperParseTreeRewriter.cs b/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperParseTreeRewriter.cs index bee30a3eeb..ca7b73ddd3 100644 --- a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperParseTreeRewriter.cs +++ b/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperParseTreeRewriter.cs @@ -82,7 +82,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy { var childBlock = (Block)child; - if (childBlock.Type == BlockType.Tag) + if (childBlock.Type == BlockKind.Tag) { if (TryRewriteTagHelper(childBlock, errorSink)) { @@ -340,7 +340,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy { var childBlock = (Block)child; - if (childBlock.Type != BlockType.Markup) + if (childBlock.Type != BlockKind.Markup) { // Anything other than markup blocks in the attribute area of tags mangles following attributes. // It's also not supported by TagHelpers, bail early to avoid creating bad attribute value pairs. @@ -762,7 +762,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy { var child = tagBlock.Children[0]; - if (tagBlock.Type != BlockType.Tag || tagBlock.Children.Count == 0 || !(child is Span)) + if (tagBlock.Type != BlockKind.Tag || tagBlock.Children.Count == 0 || !(child is Span)) { return null; } @@ -803,7 +803,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy private static void EnsureTagBlock(Block tagBlock) { - Debug.Assert(tagBlock.Type == BlockType.Tag); + Debug.Assert(tagBlock.Type == BlockKind.Tag); Debug.Assert(tagBlock.Children.First() is Span); } diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TokenizerBackedParser.cs b/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TokenizerBackedParser.cs index afb9f07d82..c99b4c0cb2 100644 --- a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TokenizerBackedParser.cs +++ b/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TokenizerBackedParser.cs @@ -614,7 +614,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy OutputSpanBeforeRazorComment(); using (PushSpanConfig(CommentSpanConfig)) { - using (Context.Builder.StartBlock(BlockType.Comment)) + using (Context.Builder.StartBlock(BlockKind.Comment)) { Context.Builder.CurrentBlock.ChunkGenerator = new RazorCommentChunkGenerator(); var start = CurrentStart; diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/WhiteSpaceRewriter.cs b/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/WhiteSpaceRewriter.cs index 9e9c7c47f1..c4e72954f3 100644 --- a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/WhiteSpaceRewriter.cs +++ b/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/WhiteSpaceRewriter.cs @@ -10,7 +10,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy { protected override bool CanRewrite(Block block) { - return block.Type == BlockType.Expression && Parent != null; + return block.Type == BlockKind.Expression && Parent != null; } protected override SyntaxTreeNode RewriteBlock(BlockBuilder parent, Block block) diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/SpanKind.cs b/src/Microsoft.AspNetCore.Razor.Evolution/SpanKind.cs similarity index 76% rename from src/Microsoft.AspNetCore.Razor.Evolution/Legacy/SpanKind.cs rename to src/Microsoft.AspNetCore.Razor.Evolution/SpanKind.cs index 0df30f2f2b..918f779dfa 100644 --- a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/SpanKind.cs +++ b/src/Microsoft.AspNetCore.Razor.Evolution/SpanKind.cs @@ -1,9 +1,9 @@ // 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. -namespace Microsoft.AspNetCore.Razor.Evolution.Legacy +namespace Microsoft.AspNetCore.Razor.Evolution { - internal enum SpanKind + public enum SpanKind { Transition, MetaCode, diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/HtmlNodeOptimizationPassTest.cs b/test/Microsoft.AspNetCore.Razor.Evolution.Test/HtmlNodeOptimizationPassTest.cs index 724c2e9312..4ebeb6da9c 100644 --- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/HtmlNodeOptimizationPassTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/HtmlNodeOptimizationPassTest.cs @@ -26,7 +26,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution // Assert var tag = Assert.Single(outputTree.Root.Children); var tagBlock = Assert.IsType(tag); - Assert.Equal(BlockType.Tag, tagBlock.Type); + Assert.Equal(BlockKind.Tag, tagBlock.Type); Assert.Equal(3, tagBlock.Children.Count); Assert.IsType(tagBlock.Children[1]); } diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/BlockTest.cs b/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/BlockTest.cs index ec35e5d440..1e71732627 100644 --- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/BlockTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/BlockTest.cs @@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy public void ConstructorWithBlockBuilderSetsParent() { // Arrange - var builder = new BlockBuilder() { Type = BlockType.Comment }; + var builder = new BlockBuilder() { Type = BlockKind.Comment }; var span = new SpanBuilder(SourceLocation.Undefined) { Kind = SpanKind.Code }.Build(); builder.Children.Add(span); @@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy var expected = new ExpressionChunkGenerator(); var builder = new BlockBuilder() { - Type = BlockType.Helper, + Type = BlockKind.Helper, ChunkGenerator = expected }; @@ -48,7 +48,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy var expected = new SpanBuilder(SourceLocation.Undefined) { Kind = SpanKind.Code }.Build(); var builder = new BlockBuilder() { - Type = BlockType.Functions + Type = BlockKind.Functions }; builder.Children.Add(expected); diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/BlockTypes.cs b/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/BlockTypes.cs index eb3138590f..364082fe94 100644 --- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/BlockTypes.cs +++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/BlockTypes.cs @@ -9,10 +9,10 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy internal class StatementBlock : Block { - private const BlockType ThisBlockType = BlockType.Statement; + private const BlockKind ThisBlockKind = BlockKind.Statement; public StatementBlock(IParentChunkGenerator chunkGenerator, IReadOnlyList children) - : base(ThisBlockType, children, chunkGenerator) + : base(ThisBlockKind, children, chunkGenerator) { } @@ -29,10 +29,10 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy internal class DirectiveBlock : Block { - private const BlockType ThisBlockType = BlockType.Directive; + private const BlockKind ThisBlockKind = BlockKind.Directive; public DirectiveBlock(IParentChunkGenerator chunkGenerator, IReadOnlyList children) - : base(ThisBlockType, children, chunkGenerator) + : base(ThisBlockKind, children, chunkGenerator) { } @@ -49,10 +49,10 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy internal class ExpressionBlock : Block { - private const BlockType ThisBlockType = BlockType.Expression; + private const BlockKind ThisBlockKind = BlockKind.Expression; public ExpressionBlock(IParentChunkGenerator chunkGenerator, IReadOnlyList children) - : base(ThisBlockType, children, chunkGenerator) + : base(ThisBlockKind, children, chunkGenerator) { } @@ -69,28 +69,28 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy internal class MarkupTagBlock : Block { - private const BlockType ThisBlockType = BlockType.Tag; + private const BlockKind ThisBlockKind = BlockKind.Tag; public MarkupTagBlock(params SyntaxTreeNode[] children) - : base(ThisBlockType, children, ParentChunkGenerator.Null) + : base(ThisBlockKind, children, ParentChunkGenerator.Null) { } } internal class MarkupBlock : Block { - private const BlockType ThisBlockType = BlockType.Markup; + private const BlockKind ThisBlockKind = BlockKind.Markup; public MarkupBlock( - BlockType blockType, + BlockKind BlockKind, IParentChunkGenerator chunkGenerator, IReadOnlyList children) - : base(blockType, children, chunkGenerator) + : base(BlockKind, children, chunkGenerator) { } public MarkupBlock(IParentChunkGenerator chunkGenerator, IReadOnlyList children) - : this(ThisBlockType, chunkGenerator, children) + : this(ThisBlockKind, chunkGenerator, children) { } @@ -170,10 +170,10 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy internal class TemplateBlock : Block { - private const BlockType ThisBlockType = BlockType.Template; + private const BlockKind ThisBlockKind = BlockKind.Template; public TemplateBlock(IParentChunkGenerator chunkGenerator, IReadOnlyList children) - : base(ThisBlockType, children, chunkGenerator) + : base(ThisBlockKind, children, chunkGenerator) { } @@ -195,10 +195,10 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy internal class CommentBlock : Block { - private const BlockType ThisBlockType = BlockType.Comment; + private const BlockKind ThisBlockKind = BlockKind.Comment; public CommentBlock(IParentChunkGenerator chunkGenerator, IReadOnlyList children) - : base(ThisBlockType, children, chunkGenerator) + : base(ThisBlockKind, children, chunkGenerator) { } diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/CSharpBlockTest.cs b/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/CSharpBlockTest.cs index d0042db4ec..d147991e1f 100644 --- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/CSharpBlockTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/CSharpBlockTest.cs @@ -53,7 +53,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy SingleSpanBlockTest(@"if(foo) { // bar } "" baz ' zoop(); -}", BlockType.Statement, SpanKind.Code); +}", BlockKind.Statement, SpanKind.Code); } [Fact] @@ -76,7 +76,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy @"if(foo) { /* bar } "" */ ' baz } ' zoop(); -}", BlockType.Statement, SpanKind.Code); +}", BlockKind.Statement, SpanKind.Code); } [Fact] @@ -84,7 +84,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy { SingleSpanBlockTest( "for(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }", - BlockType.Statement, + BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); } @@ -94,7 +94,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy { SingleSpanBlockTest( "foreach(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }", - BlockType.Statement, + BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); } @@ -104,7 +104,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy { SingleSpanBlockTest( "while(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }", - BlockType.Statement, + BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); } @@ -114,7 +114,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy { SingleSpanBlockTest( "using(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }", - BlockType.Statement, + BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); } @@ -123,7 +123,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy { SingleSpanBlockTest( "if(foo) { using(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); } }", - BlockType.Statement, + BlockKind.Statement, SpanKind.Code); } @@ -132,14 +132,14 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy { SingleSpanBlockTest( "if(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }", - BlockType.Statement, + BlockKind.Statement, SpanKind.Code); } [Fact] public void ParseBlockAllowsEmptyBlockStatement() { - SingleSpanBlockTest("if(false) { }", BlockType.Statement, SpanKind.Code); + SingleSpanBlockTest("if(false) { }", BlockKind.Statement, SpanKind.Code); } [Fact] @@ -159,7 +159,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy { SingleSpanBlockTest( "if(foo) { bar(); } /* Foo */ /* Bar */ else { baz(); }", - BlockType.Statement, + BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); } @@ -177,7 +177,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy { SingleSpanBlockTest( "if(foo) { bar(); } else if(bar) { baz(); } /* Foo */ /* Bar */ else { biz(); }", - BlockType.Statement, + BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); } @@ -195,7 +195,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy { SingleSpanBlockTest( "if(foo) { bar(); } /* Foo */ /* Bar */ else if(bar) { baz(); }", - BlockType.Statement, + BlockKind.Statement, SpanKind.Code); } @@ -211,7 +211,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy SingleSpanBlockTest(@"if(foo) { bar(); } // Foo // Bar -else { baz(); }", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); +else { baz(); }", BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); } [Fact] @@ -220,7 +220,7 @@ else { baz(); }", BlockType.Statement, SpanKind.Code, acceptedCharacters: Accept SingleSpanBlockTest(@"if(foo) { bar(); } else if(bar) { baz(); } // Foo // Bar -else { biz(); }", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); +else { biz(); }", BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); } [Fact] @@ -229,7 +229,7 @@ else { biz(); }", BlockType.Statement, SpanKind.Code, acceptedCharacters: Accept SingleSpanBlockTest(@"if(foo) { bar(); } // Foo // Bar -else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code); +else if(bar) { baz(); }", BlockKind.Statement, SpanKind.Code); } [Fact] @@ -243,7 +243,7 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code); }"; const string document = ifStatement + elseIfBranch; - SingleSpanBlockTest(document, BlockType.Statement, SpanKind.Code); + SingleSpanBlockTest(document, BlockKind.Statement, SpanKind.Code); } [Fact] @@ -256,7 +256,7 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code); Debug.WriteLine(@""bar } baz""); }"; const string document = ifStatement + elseIfBranch + elseIfBranch + elseIfBranch + elseIfBranch; - SingleSpanBlockTest(document, BlockType.Statement, SpanKind.Code); + SingleSpanBlockTest(document, BlockKind.Statement, SpanKind.Code); } [Fact] @@ -271,7 +271,7 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code); const string elseBranch = @" else { Debug.WriteLine(@""bar } baz""); }"; const string document = ifStatement + elseIfBranch + elseIfBranch + elseBranch; - SingleSpanBlockTest(document, BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); + SingleSpanBlockTest(document, BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); } [Fact] @@ -299,7 +299,7 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code); Debug.WriteLine(@""foo } bar""); }"; - SingleSpanBlockTest(document, BlockType.Statement, SpanKind.Code); + SingleSpanBlockTest(document, BlockKind.Statement, SpanKind.Code); } [Fact] @@ -313,7 +313,7 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code); const string elseIfBranch = @" else if { foo(); }"; const string document = ifBranch + elseIfBranch; - SingleSpanBlockTest(document, BlockType.Statement, SpanKind.Code); + SingleSpanBlockTest(document, BlockKind.Statement, SpanKind.Code); } [Fact] @@ -321,7 +321,7 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code); { SingleSpanBlockTest( "do { var foo = bar; } while(foo != bar);", - BlockType.Statement, + BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); } @@ -329,13 +329,13 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code); [Fact] public void ParseBlockCorrectlyParsesDoWhileBlockMissingSemicolon() { - SingleSpanBlockTest("do { var foo = bar; } while(foo != bar)", BlockType.Statement, SpanKind.Code); + SingleSpanBlockTest("do { var foo = bar; } while(foo != bar)", BlockKind.Statement, SpanKind.Code); } [Fact] public void ParseBlockCorrectlyParsesDoWhileBlockMissingWhileCondition() { - SingleSpanBlockTest("do { var foo = bar; } while", BlockType.Statement, SpanKind.Code); + SingleSpanBlockTest("do { var foo = bar; } while", BlockKind.Statement, SpanKind.Code); } [Fact] @@ -343,7 +343,7 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code); { SingleSpanBlockTest( "do { var foo = bar; } while;", - BlockType.Statement, + BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); } @@ -351,7 +351,7 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code); [Fact] public void ParseBlockCorrectlyParsesDoWhileBlockMissingWhileClauseEntirely() { - SingleSpanBlockTest("do { var foo = bar; } narf;", "do { var foo = bar; }", BlockType.Statement, SpanKind.Code); + SingleSpanBlockTest("do { var foo = bar; } narf;", "do { var foo = bar; }", BlockKind.Statement, SpanKind.Code); } [Fact] @@ -359,7 +359,7 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code); { SingleSpanBlockTest( "do { var foo = bar; } /* Foo */ /* Bar */ while(true);", - BlockType.Statement, + BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); } @@ -370,7 +370,7 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code); SingleSpanBlockTest(@"do { var foo = bar; } // Foo // Bar -while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); +while(true);", BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); } [Fact] @@ -413,7 +413,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC return; default: return; -}", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); +}", BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); } [Fact] @@ -421,7 +421,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC { SingleSpanBlockTest( "lock(foo) { Debug.WriteLine(@\"foo } bar\"); }", - BlockType.Statement, + BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); } @@ -487,7 +487,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC [Fact] public void ParseBlockTerminatesUsingKeywordAtEOFAndOutputsFileCodeBlock() { - SingleSpanBlockTest("using ", BlockType.Statement, SpanKind.Code); + SingleSpanBlockTest("using ", BlockKind.Statement, SpanKind.Code); } [Fact] @@ -497,7 +497,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC SingleSpanBlockTest( document, document, - BlockType.Statement, + BlockKind.Statement, SpanKind.Code, new RazorError( LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("foreach", '}', '{'), @@ -512,7 +512,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC SingleSpanBlockTest( document, document, - BlockType.Statement, + BlockKind.Statement, SpanKind.Code, new RazorError( LegacyResources.ParseError_BlockComment_Not_Terminated, @@ -531,7 +531,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC SingleSpanBlockTest( document, document, - BlockType.Statement, + BlockKind.Statement, SpanKind.Code, new RazorError( LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("foreach", '}', '{'), @@ -542,7 +542,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC [Fact] public void ParseBlockSupportsBlockCommentBetweenTryAndFinallyClause() { - SingleSpanBlockTest("try { bar(); } /* Foo */ /* Bar */ finally { baz(); }", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); + SingleSpanBlockTest("try { bar(); } /* Foo */ /* Bar */ finally { baz(); }", BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); } [Fact] @@ -556,7 +556,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC { SingleSpanBlockTest( "try { bar(); } catch(bar) { baz(); } /* Foo */ /* Bar */ finally { biz(); }", - BlockType.Statement, + BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); } @@ -572,7 +572,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC [Fact] public void ParseBlockSupportsBlockCommentBetweenTryAndCatchClause() { - SingleSpanBlockTest("try { bar(); } /* Foo */ /* Bar */ catch(bar) { baz(); }", BlockType.Statement, SpanKind.Code); + SingleSpanBlockTest("try { bar(); } /* Foo */ /* Bar */ catch(bar) { baz(); }", BlockKind.Statement, SpanKind.Code); } [Fact] @@ -587,7 +587,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC SingleSpanBlockTest(@"try { bar(); } // Foo // Bar -finally { baz(); }", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); +finally { baz(); }", BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); } [Fact] @@ -596,7 +596,7 @@ finally { baz(); }", BlockType.Statement, SpanKind.Code, acceptedCharacters: Acc SingleSpanBlockTest(@"try { bar(); } catch(bar) { baz(); } // Foo // Bar -finally { biz(); }", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); +finally { biz(); }", BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); } [Fact] @@ -605,13 +605,13 @@ finally { biz(); }", BlockType.Statement, SpanKind.Code, acceptedCharacters: Acc SingleSpanBlockTest(@"try { bar(); } // Foo // Bar -catch(bar) { baz(); }", BlockType.Statement, SpanKind.Code); +catch(bar) { baz(); }", BlockKind.Statement, SpanKind.Code); } [Fact] public void ParseBlockSupportsTryStatementWithNoAdditionalClauses() { - SingleSpanBlockTest("try { var foo = new { } }", BlockType.Statement, SpanKind.Code); + SingleSpanBlockTest("try { var foo = new { } }", BlockKind.Statement, SpanKind.Code); } [Fact] @@ -633,7 +633,7 @@ catch(bar) { baz(); }", BlockType.Statement, SpanKind.Code); [Fact] public void ParseBlockSupportsTryStatementWithOneCatchClause() { - SingleSpanBlockTest("try { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } }", BlockType.Statement, SpanKind.Code); + SingleSpanBlockTest("try { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } }", BlockKind.Statement, SpanKind.Code); } [Fact] @@ -658,14 +658,14 @@ catch(bar) { baz(); }", BlockType.Statement, SpanKind.Code); SingleSpanBlockTest( "try { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } } catch(Foo Bar Baz) " + "{ var foo = new { } } catch(Foo Bar Baz) { var foo = new { } }", - BlockType.Statement, + BlockKind.Statement, SpanKind.Code); } [Fact] public void ParseBlockSupportsExceptionLessCatchClauses() { - SingleSpanBlockTest("try { var foo = new { } } catch { var foo = new { } }", BlockType.Statement, SpanKind.Code); + SingleSpanBlockTest("try { var foo = new { } } catch { var foo = new { } }", BlockKind.Statement, SpanKind.Code); } [Fact] @@ -688,7 +688,7 @@ catch(bar) { baz(); }", BlockType.Statement, SpanKind.Code); [Fact] public void ParseBlockSupportsTryStatementWithFinallyClause() { - SingleSpanBlockTest("try { var foo = new { } } finally { var foo = new { } }", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); + SingleSpanBlockTest("try { var foo = new { } } finally { var foo = new { } }", BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); } [Fact] @@ -712,14 +712,14 @@ catch(bar) { baz(); }", BlockType.Statement, SpanKind.Code); public void ParseBlockStopsParsingCatchClausesAfterFinallyBlock() { var expectedContent = "try { var foo = new { } } finally { var foo = new { } }"; - SingleSpanBlockTest(expectedContent + " catch(Foo Bar Baz) { }", expectedContent, BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); + SingleSpanBlockTest(expectedContent + " catch(Foo Bar Baz) { }", expectedContent, BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); } [Fact] public void ParseBlockDoesNotAllowMultipleFinallyBlocks() { var expectedContent = "try { var foo = new { } } finally { var foo = new { } }"; - SingleSpanBlockTest(expectedContent + " finally { }", expectedContent, BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); + SingleSpanBlockTest(expectedContent + " finally { }", expectedContent, BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); } [Fact] diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/CSharpErrorTest.cs b/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/CSharpErrorTest.cs index 0deae1bf89..a77052af3a 100644 --- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/CSharpErrorTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/CSharpErrorTest.cs @@ -578,7 +578,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy + " var p = \"foo bar baz" + Environment.NewLine + ";" + Environment.NewLine + "}", - BlockType.Statement, SpanKind.Code, + BlockKind.Statement, SpanKind.Code, new RazorError( LegacyResources.ParseError_Unterminated_String_Literal, new SourceLocation(21 + Environment.NewLine.Length, 1, 12), @@ -588,7 +588,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy [Fact] public void ParseBlockTerminatesNormalStringAtEndOfFile() { - SingleSpanBlockTest("if(foo) { var foo = \"blah blah blah blah blah", BlockType.Statement, SpanKind.Code, + SingleSpanBlockTest("if(foo) { var foo = \"blah blah blah blah blah", BlockKind.Statement, SpanKind.Code, new RazorError( LegacyResources.ParseError_Unterminated_String_Literal, new SourceLocation(20, 0, 20), @@ -607,7 +607,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy + "

Foo

" + Environment.NewLine + "blah " + Environment.NewLine + "blah", - BlockType.Statement, SpanKind.Code, + BlockKind.Statement, SpanKind.Code, new RazorError( LegacyResources.ParseError_Unterminated_String_Literal, new SourceLocation(20, 0, 20), @@ -684,7 +684,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy { SingleSpanBlockTest( keyword + " (foo) { var foo = bar; if(foo != null) { bar(); } ", - BlockType.Statement, + BlockKind.Statement, SpanKind.Code, new RazorError( LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(keyword, '}', '{'), diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/CodeParserTestBase.cs b/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/CodeParserTestBase.cs index f86c603ae6..57649ae45d 100644 --- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/CodeParserTestBase.cs +++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/CodeParserTestBase.cs @@ -29,34 +29,34 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy ImplicitExpressionTest(input, expected, AcceptedCharacters.NonWhiteSpace, errors); } - internal override void SingleSpanBlockTest(string document, BlockType blockType, SpanKind spanType, AcceptedCharacters acceptedCharacters = AcceptedCharacters.Any) + internal override void SingleSpanBlockTest(string document, BlockKind blockKind, SpanKind spanType, AcceptedCharacters acceptedCharacters = AcceptedCharacters.Any) { - SingleSpanBlockTest(document, blockType, spanType, acceptedCharacters, expectedError: null); + SingleSpanBlockTest(document, blockKind, spanType, acceptedCharacters, expectedError: null); } - internal override void SingleSpanBlockTest(string document, string spanContent, BlockType blockType, SpanKind spanType, AcceptedCharacters acceptedCharacters = AcceptedCharacters.Any) + internal override void SingleSpanBlockTest(string document, string spanContent, BlockKind blockKind, SpanKind spanType, AcceptedCharacters acceptedCharacters = AcceptedCharacters.Any) { - SingleSpanBlockTest(document, spanContent, blockType, spanType, acceptedCharacters, expectedErrors: null); + SingleSpanBlockTest(document, spanContent, blockKind, spanType, acceptedCharacters, expectedErrors: null); } - internal override void SingleSpanBlockTest(string document, BlockType blockType, SpanKind spanType, params RazorError[] expectedError) + internal override void SingleSpanBlockTest(string document, BlockKind blockKind, SpanKind spanType, params RazorError[] expectedError) { - SingleSpanBlockTest(document, document, blockType, spanType, expectedError); + SingleSpanBlockTest(document, document, blockKind, spanType, expectedError); } - internal override void SingleSpanBlockTest(string document, string spanContent, BlockType blockType, SpanKind spanType, params RazorError[] expectedErrors) + internal override void SingleSpanBlockTest(string document, string spanContent, BlockKind blockKind, SpanKind spanType, params RazorError[] expectedErrors) { - SingleSpanBlockTest(document, spanContent, blockType, spanType, AcceptedCharacters.Any, expectedErrors ?? new RazorError[0]); + SingleSpanBlockTest(document, spanContent, blockKind, spanType, AcceptedCharacters.Any, expectedErrors ?? new RazorError[0]); } - internal override void SingleSpanBlockTest(string document, BlockType blockType, SpanKind spanType, AcceptedCharacters acceptedCharacters, params RazorError[] expectedError) + internal override void SingleSpanBlockTest(string document, BlockKind blockKind, SpanKind spanType, AcceptedCharacters acceptedCharacters, params RazorError[] expectedError) { - SingleSpanBlockTest(document, document, blockType, spanType, acceptedCharacters, expectedError); + SingleSpanBlockTest(document, document, blockKind, spanType, acceptedCharacters, expectedError); } - internal override void SingleSpanBlockTest(string document, string spanContent, BlockType blockType, SpanKind spanType, AcceptedCharacters acceptedCharacters, params RazorError[] expectedErrors) + internal override void SingleSpanBlockTest(string document, string spanContent, BlockKind blockKind, SpanKind spanType, AcceptedCharacters acceptedCharacters, params RazorError[] expectedErrors) { - var b = CreateSimpleBlockAndSpan(spanContent, blockType, spanType, acceptedCharacters); + var b = CreateSimpleBlockAndSpan(spanContent, blockKind, spanType, acceptedCharacters); ParseBlockTest(document, b, expectedErrors ?? new RazorError[0]); } diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/HtmlBlockTest.cs b/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/HtmlBlockTest.cs index 00fc85e305..22afdfea53 100644 --- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/HtmlBlockTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/HtmlBlockTest.cs @@ -321,7 +321,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy [Fact] public void ParseBlockSupportsCommentAsBlock() { - SingleSpanBlockTest("", BlockType.Markup, SpanKind.Markup, acceptedCharacters: AcceptedCharacters.None); + SingleSpanBlockTest("", BlockKind.Markup, SpanKind.Markup, acceptedCharacters: AcceptedCharacters.None); } [Fact] @@ -398,19 +398,19 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy [Fact] public void ParseBlockProperlyBalancesCommentStartAndEndTags() { - SingleSpanBlockTest("", BlockType.Markup, SpanKind.Markup, acceptedCharacters: AcceptedCharacters.None); + SingleSpanBlockTest("", BlockKind.Markup, SpanKind.Markup, acceptedCharacters: AcceptedCharacters.None); } [Fact] public void ParseBlockTerminatesAtEOFWhenParsingComment() { - SingleSpanBlockTest("", BlockType.Markup, SpanKind.Markup, acceptedCharacters: AcceptedCharacters.None); + SingleSpanBlockTest("", BlockKind.Markup, SpanKind.Markup, acceptedCharacters: AcceptedCharacters.None); } [Fact] diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/HtmlDocumentTest.cs b/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/HtmlDocumentTest.cs index b2348605e3..247ca3e4df 100644 --- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/HtmlDocumentTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/HtmlDocumentTest.cs @@ -48,7 +48,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy [Fact] public void ParseDocumentOutputsWhitespaceOnlyContentAsSingleWhitespaceMarkupSpan() { - SingleSpanDocumentTest(" ", BlockType.Markup, SpanKind.Markup); + SingleSpanDocumentTest(" ", BlockKind.Markup, SpanKind.Markup); } [Fact] @@ -130,7 +130,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy [Fact] public void ParseDocumentParsesWholeContentAsOneSpanIfNoSwapCharacterEncountered() { - SingleSpanDocumentTest("foo baz", BlockType.Markup, SpanKind.Markup); + SingleSpanDocumentTest("foo baz", BlockKind.Markup, SpanKind.Markup); } [Fact] @@ -182,7 +182,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy [Fact] public void ParseDocumentDoesNotSwitchToCodeOnEmailAddressInText() { - SingleSpanDocumentTest("anurse@microsoft.com", BlockType.Markup, SpanKind.Markup); + SingleSpanDocumentTest("anurse@microsoft.com", BlockKind.Markup, SpanKind.Markup); } [Fact] @@ -218,7 +218,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy [Fact] public void ParseDocumentReturnsOneMarkupSegmentIfNoCodeBlocksEncountered() { - SingleSpanDocumentTest("Foo BazBarBar