diff --git a/src/Microsoft.AspNet.Razor/Chunks/ChunkTreeBuilder.cs b/src/Microsoft.AspNet.Razor/Chunks/ChunkTreeBuilder.cs index 812eeb2dcb..fe828e4752 100644 --- a/src/Microsoft.AspNet.Razor/Chunks/ChunkTreeBuilder.cs +++ b/src/Microsoft.AspNet.Razor/Chunks/ChunkTreeBuilder.cs @@ -132,14 +132,6 @@ namespace Microsoft.AspNet.Razor.Chunks }, association); } - public void AddResolveUrlChunk(string url, SyntaxTreeNode association) - { - AddChunk(new ResolveUrlChunk - { - Url = url - }, association); - } - public void AddSetBaseTypeChunk(string typeName, SyntaxTreeNode association) { AddChunk(new SetBaseTypeChunk diff --git a/src/Microsoft.AspNet.Razor/Chunks/Generators/ResolveUrlChunkGenerator.cs b/src/Microsoft.AspNet.Razor/Chunks/Generators/ResolveUrlChunkGenerator.cs deleted file mode 100644 index b0ef82b10d..0000000000 --- a/src/Microsoft.AspNet.Razor/Chunks/Generators/ResolveUrlChunkGenerator.cs +++ /dev/null @@ -1,28 +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 Microsoft.AspNet.Razor.Parser.SyntaxTree; - -namespace Microsoft.AspNet.Razor.Chunks.Generators -{ - public class ResolveUrlChunkGenerator : SpanChunkGenerator - { - public override void GenerateChunk(Span target, ChunkGeneratorContext context) - { - // Check if the host supports it - if (string.IsNullOrEmpty(context.Host.GeneratedClassContext.ResolveUrlMethodName)) - { - // Nope, just use the default MarkupChunkGenerator behavior - new MarkupChunkGenerator().GenerateChunk(target, context); - return; - } - - context.ChunkTreeBuilder.AddResolveUrlChunk(target.Content, target); - } - - public override string ToString() - { - return "VirtualPath"; - } - } -} diff --git a/src/Microsoft.AspNet.Razor/Chunks/ResolveUrlChunk.cs b/src/Microsoft.AspNet.Razor/Chunks/ResolveUrlChunk.cs deleted file mode 100644 index 3e9f5ede1a..0000000000 --- a/src/Microsoft.AspNet.Razor/Chunks/ResolveUrlChunk.cs +++ /dev/null @@ -1,10 +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. - -namespace Microsoft.AspNet.Razor.Chunks -{ - public class ResolveUrlChunk : Chunk - { - public string Url { get; set; } - } -} diff --git a/src/Microsoft.AspNet.Razor/CodeGenerators/GeneratedClassContext.cs b/src/Microsoft.AspNet.Razor/CodeGenerators/GeneratedClassContext.cs index ab3d4be31b..a6726e39fc 100644 --- a/src/Microsoft.AspNet.Razor/CodeGenerators/GeneratedClassContext.cs +++ b/src/Microsoft.AspNet.Razor/CodeGenerators/GeneratedClassContext.cs @@ -136,9 +136,6 @@ namespace Microsoft.AspNet.Razor.CodeGenerators public string WriteAttributeMethodName { get; set; } public string WriteAttributeToMethodName { get; set; } - [SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings", Justification = "Property is not a URL property")] - public string ResolveUrlMethodName { get; set; } - public bool AllowSections { get { return !string.IsNullOrEmpty(DefineSectionMethodName); } diff --git a/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpCodeVisitor.cs b/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpCodeVisitor.cs index 731d72593e..e5e6fefa15 100644 --- a/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpCodeVisitor.cs +++ b/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpCodeVisitor.cs @@ -94,45 +94,6 @@ namespace Microsoft.AspNet.Razor.CodeGenerators.Visitors Writer.WriteEndMethodInvocation(false).WriteLine(); } - protected override void Visit(ResolveUrlChunk chunk) - { - if (!Context.Host.DesignTimeMode && string.IsNullOrEmpty(chunk.Url)) - { - return; - } - - var generateInstrumentation = ShouldGenerateInstrumentationForExpressions(); - - if (generateInstrumentation) - { - // Add a non-literal context call (non-literal because the expanded URL will not match the source - // character-by-character) - Writer.WriteStartInstrumentationContext(Context, chunk.Association, isLiteral: false); - } - - if (!string.IsNullOrEmpty(chunk.Url) && !Context.Host.DesignTimeMode) - { - if (Context.ExpressionRenderingMode == ExpressionRenderingMode.WriteToOutput) - { - RenderPreWriteStart(); - } - - Writer.WriteStartMethodInvocation(Context.Host.GeneratedClassContext.ResolveUrlMethodName) - .WriteStringLiteral(chunk.Url) - .WriteEndMethodInvocation(endLine: false); - - if (Context.ExpressionRenderingMode == ExpressionRenderingMode.WriteToOutput) - { - Writer.WriteEndMethodInvocation(); - } - } - - if (generateInstrumentation) - { - Writer.WriteEndInstrumentationContext(Context); - } - } - protected override void Visit(LiteralChunk chunk) { if (Context.Host.DesignTimeMode || string.IsNullOrEmpty(chunk.Text)) diff --git a/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpTagHelperAttributeValueVisitor.cs b/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpTagHelperAttributeValueVisitor.cs index 3d8091b2e7..6b7fa9f5ec 100644 --- a/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpTagHelperAttributeValueVisitor.cs +++ b/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpTagHelperAttributeValueVisitor.cs @@ -92,19 +92,6 @@ namespace Microsoft.AspNet.Razor.CodeGenerators.Visitors RenderCode(chunk.Text, (Span)chunk.Association); } - /// - /// Writes code for the given . - /// - /// The to render. - /// - /// Allowed to support future C# extensions. Likely "~/..." will lead to a C# compilation error but that is up - /// to the compiler. - /// - protected override void Visit(ResolveUrlChunk chunk) - { - RenderCode(chunk.Url, (Span)chunk.Association); - } - /// /// Writes code for the given . /// diff --git a/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/ChunkVisitor.cs b/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/ChunkVisitor.cs index 3143eb6df8..cbb5fef7a6 100644 --- a/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/ChunkVisitor.cs +++ b/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/ChunkVisitor.cs @@ -61,10 +61,6 @@ namespace Microsoft.AspNet.Razor.CodeGenerators.Visitors { Visit((RemoveTagHelperChunk)chunk); } - else if (chunk is ResolveUrlChunk) - { - Visit((ResolveUrlChunk)chunk); - } else if (chunk is TypeMemberChunk) { Visit((TypeMemberChunk)chunk); @@ -117,7 +113,6 @@ namespace Microsoft.AspNet.Razor.CodeGenerators.Visitors protected abstract void Visit(CodeAttributeChunk chunk); protected abstract void Visit(SectionChunk chunk); protected abstract void Visit(TypeMemberChunk chunk); - protected abstract void Visit(ResolveUrlChunk chunk); protected abstract void Visit(SetBaseTypeChunk chunk); protected abstract void Visit(TemplateChunk chunk); protected abstract void Visit(ExpressionBlockChunk chunk); diff --git a/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CodeVisitor.cs b/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CodeVisitor.cs index b89c2f242b..dab34ba9fa 100644 --- a/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CodeVisitor.cs +++ b/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CodeVisitor.cs @@ -59,9 +59,6 @@ namespace Microsoft.AspNet.Razor.CodeGenerators.Visitors protected override void Visit(TypeMemberChunk chunk) { } - protected override void Visit(ResolveUrlChunk chunk) - { - } protected override void Visit(SetBaseTypeChunk chunk) { } diff --git a/src/Microsoft.AspNet.Razor/Parser/HtmlMarkupParser.Block.cs b/src/Microsoft.AspNet.Razor/Parser/HtmlMarkupParser.Block.cs index 916e8787b4..90a1ade056 100644 --- a/src/Microsoft.AspNet.Razor/Parser/HtmlMarkupParser.Block.cs +++ b/src/Microsoft.AspNet.Razor/Parser/HtmlMarkupParser.Block.cs @@ -616,20 +616,6 @@ namespace Microsoft.AspNet.Razor.Parser } } } - else if (At(HtmlSymbolType.Text) && - CurrentSymbol.Content.Length > 0 && - CurrentSymbol.Content[0] == '~' && - NextIs(HtmlSymbolType.ForwardSlash)) - { - Accept(prefix); - - // Virtual Path value - var valueStart = CurrentLocation; - VirtualPath(); - Span.ChunkGenerator = new LiteralAttributeChunkGenerator( - prefix.GetContent(prefixStart), - new LocationTagged(new ResolveUrlChunkGenerator(), valueStart)); - } else { Accept(prefix); @@ -676,18 +662,6 @@ namespace Microsoft.AspNet.Razor.Parser sym.Type == HtmlSymbolType.NewLine; } - private void VirtualPath() - { - Assert(HtmlSymbolType.Text); - Debug.Assert(CurrentSymbol.Content.Length > 0 && CurrentSymbol.Content[0] == '~'); - - // Parse until a transition symbol, whitespace, newline or quote. We support only a fairly minimal subset of Virtual Paths - AcceptUntil(HtmlSymbolType.Transition, HtmlSymbolType.WhiteSpace, HtmlSymbolType.NewLine, HtmlSymbolType.SingleQuote, HtmlSymbolType.DoubleQuote); - - // Output a Virtual Path span - Span.EditHandler.EditorHints = EditorHints.VirtualPath; - } - private void RecoverToEndOfTag() { // Accept until ">", "/" or "<", but parse code diff --git a/test/Microsoft.AspNet.Razor.Test/CodeGenerators/CSharpRazorChunkGeneratorTest.cs b/test/Microsoft.AspNet.Razor.Test/CodeGenerators/CSharpRazorChunkGeneratorTest.cs index a31a37bb9e..ed03b0f3b8 100644 --- a/test/Microsoft.AspNet.Razor.Test/CodeGenerators/CSharpRazorChunkGeneratorTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/CodeGenerators/CSharpRazorChunkGeneratorTest.cs @@ -28,7 +28,6 @@ namespace Microsoft.AspNet.Razor.Test.Generator } private const string TestPhysicalPath = @"C:\Bar.cshtml"; - private const string TestVirtualPath = "~/Foo/Bar.cshtml"; [Fact] public void ConstructorRequiresNonNullClassName() @@ -69,7 +68,6 @@ namespace Microsoft.AspNet.Razor.Test.Generator [InlineData("RazorComments")] [InlineData("InlineBlocks")] [InlineData("ConditionalAttributes")] - [InlineData("ResolveUrl")] [InlineData("Await")] [InlineData("CodeBlockWithTextElement")] public void CSharpChunkGeneratorCorrectlyGeneratesRunTimeCode(string testType) diff --git a/test/Microsoft.AspNet.Razor.Test/CodeGenerators/RazorChunkGeneratorTest.cs b/test/Microsoft.AspNet.Razor.Test/CodeGenerators/RazorChunkGeneratorTest.cs index 735f7f87f0..00e124eb89 100644 --- a/test/Microsoft.AspNet.Razor.Test/CodeGenerators/RazorChunkGeneratorTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/CodeGenerators/RazorChunkGeneratorTest.cs @@ -152,19 +152,17 @@ namespace Microsoft.AspNet.Razor.Test.Generator host.DefaultClassName = name; // Add support for templates, etc. - host.GeneratedClassContext = new GeneratedClassContext(GeneratedClassContext.DefaultExecuteMethodName, - GeneratedClassContext.DefaultWriteMethodName, - GeneratedClassContext.DefaultWriteLiteralMethodName, - "WriteTo", - "WriteLiteralTo", - "Template", - "DefineSection", - "Instrumentation.BeginContext", - "Instrumentation.EndContext", - new GeneratedTagHelperContext()) - { - ResolveUrlMethodName = "Href" - }; + host.GeneratedClassContext = new GeneratedClassContext( + GeneratedClassContext.DefaultExecuteMethodName, + GeneratedClassContext.DefaultWriteMethodName, + GeneratedClassContext.DefaultWriteLiteralMethodName, + "WriteTo", + "WriteLiteralTo", + "Template", + "DefineSection", + "Instrumentation.BeginContext", + "Instrumentation.EndContext", + new GeneratedTagHelperContext()); if (hostConfig != null) { host = hostConfig(host); diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/Html/HtmlAttributeTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/Html/HtmlAttributeTest.cs index ea5b3511f6..1348da2975 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/Html/HtmlAttributeTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/Html/HtmlAttributeTest.cs @@ -137,10 +137,9 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) .Accepts(AcceptedCharacters.NonWhiteSpace))), Factory.Markup(" ~/Foo/Bar") - .WithEditorHints(EditorHints.VirtualPath) .With(new LiteralAttributeChunkGenerator( new LocationTagged(" ", 13, 0, 13), - new LocationTagged(new ResolveUrlChunkGenerator(), 14, 0, 14))), + new LocationTagged("~/Foo/Bar", 14, 0, 14))), Factory.Markup("'").With(SpanChunkGenerator.Null)), Factory.Markup(" />").Accepts(AcceptedCharacters.None)))); } @@ -181,33 +180,6 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html Factory.Markup(" />")))); } - [Fact] - public void ConditionalAttributeCollapserDoesNotRemoveUrlAttributeValues() - { - // Act - var results = ParseDocument(""); - var rewritingContext = new RewritingContext(results.Document, new ErrorSink()); - new ConditionalAttributeCollapser(new HtmlMarkupParser().BuildSpan).Rewrite(rewritingContext); - new MarkupCollapser(new HtmlMarkupParser().BuildSpan).Rewrite(rewritingContext); - var rewritten = rewritingContext.SyntaxTree; - - // Assert - Assert.Equal(0, results.ParserErrors.Count()); - EvaluateParseTree(rewritten, - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("(" href='", 2, 0, 2), suffix: new LocationTagged("'", 18, 0, 18)), - Factory.Markup(" href='").With(SpanChunkGenerator.Null), - Factory.Markup("~/Foo/Bar") - .WithEditorHints(EditorHints.VirtualPath) - .With(new LiteralAttributeChunkGenerator( - new LocationTagged(string.Empty, 9, 0, 9), - new LocationTagged(new ResolveUrlChunkGenerator(), 9, 0, 9))), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - Factory.Markup(" />")))); - } - [Fact] public void ConditionalAttributeCollapserDoesNotRewriteEscapedTransitions() { diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/Html/HtmlUrlAttributeTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/Html/HtmlUrlAttributeTest.cs deleted file mode 100644 index 2dd7ac6b4a..0000000000 --- a/test/Microsoft.AspNet.Razor.Test/Parser/Html/HtmlUrlAttributeTest.cs +++ /dev/null @@ -1,293 +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 Microsoft.AspNet.Razor.Chunks.Generators; -using Microsoft.AspNet.Razor.Editor; -using Microsoft.AspNet.Razor.Parser; -using Microsoft.AspNet.Razor.Parser.SyntaxTree; -using Microsoft.AspNet.Razor.Test.Framework; -using Microsoft.AspNet.Razor.Text; -using Xunit; - -namespace Microsoft.AspNet.Razor.Test.Parser.Html -{ - public class HtmlUrlAttributeTest : CsHtmlMarkupParserTestBase - { - [Fact] - public void SimpleUrlInAttributeInMarkupBlock() - { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("(" href='", 2, 0, 2), new LocationTagged("'", 22, 0, 22)), - Factory.Markup(" href='").With(SpanChunkGenerator.Null), - Factory.Markup("~/Foo/Bar/Baz") - .WithEditorHints(EditorHints.VirtualPath) - .With(new LiteralAttributeChunkGenerator( - new LocationTagged(string.Empty, 9, 0, 9), - new LocationTagged(new ResolveUrlChunkGenerator(), 9, 0, 9))), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - Factory.Markup(" />").Accepts(AcceptedCharacters.None)))); - } - - [Fact] - public void SimpleUrlInAttributeInMarkupDocument() - { - ParseDocumentTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("(" href='", 2, 0, 2), new LocationTagged("'", 22, 0, 22)), - Factory.Markup(" href='").With(SpanChunkGenerator.Null), - Factory.Markup("~/Foo/Bar/Baz") - .WithEditorHints(EditorHints.VirtualPath) - .With(new LiteralAttributeChunkGenerator( - new LocationTagged(string.Empty, 9, 0, 9), - new LocationTagged(new ResolveUrlChunkGenerator(), 9, 0, 9))), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - Factory.Markup(" />")))); - } - - [Fact] - public void SimpleUrlInAttributeInMarkupSection() - { - ParseDocumentTest("@section Foo { }", - new MarkupBlock( - Factory.EmptyHtml(), - new SectionBlock(new SectionChunkGenerator("Foo"), - Factory.CodeTransition(), - Factory.MetaCode("section Foo {") - .AutoCompleteWith(null, atEndOfSpan: true) - .Accepts(AcceptedCharacters.Any), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("(" href='", 17, 0, 17), new LocationTagged("'", 37, 0, 37)), - Factory.Markup(" href='").With(SpanChunkGenerator.Null), - Factory.Markup("~/Foo/Bar/Baz") - .WithEditorHints(EditorHints.VirtualPath) - .With(new LiteralAttributeChunkGenerator( - new LocationTagged(string.Empty, 24, 0, 24), - new LocationTagged(new ResolveUrlChunkGenerator(), 24, 0, 24))), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - Factory.Markup(" />")), - Factory.Markup(" ") - ), - Factory.MetaCode("}").Accepts(AcceptedCharacters.None)), - Factory.EmptyHtml())); - } - - [Fact] - public void UrlWithExpressionsInAttributeInMarkupBlock() - { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("(" href='", 2, 0, 2), new LocationTagged("'", 22, 0, 22)), - Factory.Markup(" href='").With(SpanChunkGenerator.Null), - Factory.Markup("~/Foo/") - .WithEditorHints(EditorHints.VirtualPath) - .With(new LiteralAttributeChunkGenerator( - new LocationTagged(string.Empty, 9, 0, 9), - new LocationTagged(new ResolveUrlChunkGenerator(), 9, 0, 9))), - new MarkupBlock(new DynamicAttributeBlockChunkGenerator(new LocationTagged(string.Empty, 15, 0, 15), 15, 0, 15), - new ExpressionBlock( - Factory.CodeTransition().Accepts(AcceptedCharacters.None), - Factory.Code("id") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharacters.NonWhiteSpace))), - Factory.Markup("/Baz") - .With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 18, 0, 18), new LocationTagged("/Baz", 18, 0, 18))), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - Factory.Markup(" />").Accepts(AcceptedCharacters.None)))); - } - - [Fact] - public void UrlWithExpressionsInAttributeInMarkupDocument() - { - ParseDocumentTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("(" href='", 2, 0, 2), new LocationTagged("'", 22, 0, 22)), - Factory.Markup(" href='").With(SpanChunkGenerator.Null), - Factory.Markup("~/Foo/") - .WithEditorHints(EditorHints.VirtualPath) - .With(new LiteralAttributeChunkGenerator( - new LocationTagged(string.Empty, 9, 0, 9), - new LocationTagged(new ResolveUrlChunkGenerator(), 9, 0, 9))), - new MarkupBlock(new DynamicAttributeBlockChunkGenerator(new LocationTagged(string.Empty, 15, 0, 15), 15, 0, 15), - new ExpressionBlock( - Factory.CodeTransition().Accepts(AcceptedCharacters.None), - Factory.Code("id") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharacters.NonWhiteSpace))), - Factory.Markup("/Baz") - .With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 18, 0, 18), new LocationTagged("/Baz", 18, 0, 18))), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - Factory.Markup(" />")))); - } - - [Fact] - public void UrlWithExpressionsInAttributeInMarkupSection() - { - ParseDocumentTest("@section Foo { }", - new MarkupBlock( - Factory.EmptyHtml(), - new SectionBlock(new SectionChunkGenerator("Foo"), - Factory.CodeTransition(), - Factory.MetaCode("section Foo {") - .AutoCompleteWith(null, atEndOfSpan: true), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("(" href='", 17, 0, 17), new LocationTagged("'", 37, 0, 37)), - Factory.Markup(" href='").With(SpanChunkGenerator.Null), - Factory.Markup("~/Foo/") - .WithEditorHints(EditorHints.VirtualPath) - .With(new LiteralAttributeChunkGenerator( - new LocationTagged(string.Empty, 24, 0, 24), - new LocationTagged(new ResolveUrlChunkGenerator(), 24, 0, 24))), - new MarkupBlock(new DynamicAttributeBlockChunkGenerator(new LocationTagged(string.Empty, 30, 0, 30), 30, 0, 30), - new ExpressionBlock( - Factory.CodeTransition().Accepts(AcceptedCharacters.None), - Factory.Code("id") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharacters.NonWhiteSpace))), - Factory.Markup("/Baz") - .With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 33, 0, 33), new LocationTagged("/Baz", 33, 0, 33))), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - Factory.Markup(" />")), - Factory.Markup(" ") - ), - Factory.MetaCode("}").Accepts(AcceptedCharacters.None)), - Factory.EmptyHtml())); - } - - [Fact] - public void UrlWithComplexCharactersInAttributeInMarkupBlock() - { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("(" href='", 2, 0, 2), new LocationTagged("'", 31, 0, 31)), - Factory.Markup(" href='").With(SpanChunkGenerator.Null), - Factory.Markup("~/Foo+Bar:Baz(Biz),Boz") - .WithEditorHints(EditorHints.VirtualPath) - .With(new LiteralAttributeChunkGenerator( - new LocationTagged(string.Empty, 9, 0, 9), - new LocationTagged(new ResolveUrlChunkGenerator(), 9, 0, 9))), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - Factory.Markup(" />").Accepts(AcceptedCharacters.None)))); - } - - [Fact] - public void UrlWithComplexCharactersInAttributeInMarkupDocument() - { - ParseDocumentTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("(" href='", 2, 0, 2), new LocationTagged("'", 31, 0, 31)), - Factory.Markup(" href='").With(SpanChunkGenerator.Null), - Factory.Markup("~/Foo+Bar:Baz(Biz),Boz") - .WithEditorHints(EditorHints.VirtualPath) - .With(new LiteralAttributeChunkGenerator( - new LocationTagged(string.Empty, 9, 0, 9), - new LocationTagged(new ResolveUrlChunkGenerator(), 9, 0, 9))), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - Factory.Markup(" />")))); - } - - [Fact] - public void UrlInUnquotedAttributeValueInMarkupBlock() - { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("(" href=", 2, 0, 2), new LocationTagged(string.Empty, 38, 0, 38)), - Factory.Markup(" href=").With(SpanChunkGenerator.Null), - Factory.Markup("~/Foo+Bar:Baz(Biz),Boz/") - .WithEditorHints(EditorHints.VirtualPath) - .With(new LiteralAttributeChunkGenerator( - new LocationTagged(string.Empty, 8, 0, 8), - new LocationTagged(new ResolveUrlChunkGenerator(), 8, 0, 8))), - new MarkupBlock(new DynamicAttributeBlockChunkGenerator(new LocationTagged(string.Empty, 31, 0, 31), 31, 0, 31), - new ExpressionBlock( - Factory.CodeTransition() - .Accepts(AcceptedCharacters.None), - Factory.Code("id") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharacters.NonWhiteSpace))), - Factory.Markup("/Boz").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 34, 0, 34), new LocationTagged("/Boz", 34, 0, 34)))), - Factory.Markup(" />").Accepts(AcceptedCharacters.None)))); - } - - [Fact] - public void UrlInUnquotedAttributeValueInMarkupDocument() - { - ParseDocumentTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("(" href=", 2, 0, 2), new LocationTagged(string.Empty, 38, 0, 38)), - Factory.Markup(" href=").With(SpanChunkGenerator.Null), - Factory.Markup("~/Foo+Bar:Baz(Biz),Boz/") - .WithEditorHints(EditorHints.VirtualPath) - .With(new LiteralAttributeChunkGenerator( - new LocationTagged(string.Empty, 8, 0, 8), - new LocationTagged(new ResolveUrlChunkGenerator(), 8, 0, 8))), - new MarkupBlock(new DynamicAttributeBlockChunkGenerator(new LocationTagged(string.Empty, 31, 0, 31), 31, 0, 31), - new ExpressionBlock( - Factory.CodeTransition() - .Accepts(AcceptedCharacters.None), - Factory.Code("id") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharacters.NonWhiteSpace))), - Factory.Markup("/Boz").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 34, 0, 34), new LocationTagged("/Boz", 34, 0, 34)))), - Factory.Markup(" />")))); - } - - [Fact] - public void UrlInUnquotedAttributeValueInMarkupSection() - { - ParseDocumentTest("@section Foo { }", - new MarkupBlock( - Factory.EmptyHtml(), - new SectionBlock(new SectionChunkGenerator("Foo"), - Factory.CodeTransition(), - Factory.MetaCode("section Foo {") - .AutoCompleteWith(null, atEndOfSpan: true), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("(" href=", 17, 0, 17), new LocationTagged(string.Empty, 53, 0, 53)), - Factory.Markup(" href=").With(SpanChunkGenerator.Null), - Factory.Markup("~/Foo+Bar:Baz(Biz),Boz/") - .WithEditorHints(EditorHints.VirtualPath) - .With(new LiteralAttributeChunkGenerator( - new LocationTagged(string.Empty, 23, 0, 23), - new LocationTagged(new ResolveUrlChunkGenerator(), 23, 0, 23))), - new MarkupBlock(new DynamicAttributeBlockChunkGenerator(new LocationTagged(string.Empty, 46, 0, 46), 46, 0, 46), - new ExpressionBlock( - Factory.CodeTransition() - .Accepts(AcceptedCharacters.None), - Factory.Code("id") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharacters.NonWhiteSpace))), - Factory.Markup("/Boz").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 49, 0, 49), new LocationTagged("/Boz", 49, 0, 49)))), - Factory.Markup(" />")), - Factory.Markup(" ") - ), - Factory.MetaCode("}").Accepts(AcceptedCharacters.None)), - Factory.EmptyHtml())); - } - } -} diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/Output/ConditionalAttributes.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/Output/ConditionalAttributes.cs index 81bb4c5cba..b6de066b67 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/Output/ConditionalAttributes.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/Output/ConditionalAttributes.cs @@ -73,12 +73,8 @@ WriteTo(__razor_attribute_value_writer, cls); } ), 256), false)); - Instrumentation.BeginContext(282, 11, true); - WriteLiteral(" />\r\n (Href("~/Foo"), 300), false)); - Instrumentation.BeginContext(306, 16, true); - WriteLiteral(" />\r\n \r\n \r\n (Url.Content("~/Scripts/jquery-1.6.2.min.js"), 328), false)); diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/Output/HtmlCommentWithQuote_Double.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/Output/HtmlCommentWithQuote_Double.cs index e1760a3b79..762800e139 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/Output/HtmlCommentWithQuote_Double.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/Output/HtmlCommentWithQuote_Double.cs @@ -14,12 +14,8 @@ namespace TestOutput #pragma warning disable 1998 public override async Task ExecuteAsync() { - Instrumentation.BeginContext(0, 16, true); - WriteLiteral("\r\n(Href("~/images/submit.png"), 22), false)); - Instrumentation.BeginContext(42, 3, true); - WriteLiteral(" />"); + Instrumentation.BeginContext(0, 45, true); + WriteLiteral("\r\n"); Instrumentation.EndContext(); } #pragma warning restore 1998 diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/Output/HtmlCommentWithQuote_Single.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/Output/HtmlCommentWithQuote_Single.cs index dee532c5b6..a95ffb4691 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/Output/HtmlCommentWithQuote_Single.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/Output/HtmlCommentWithQuote_Single.cs @@ -14,12 +14,8 @@ namespace TestOutput #pragma warning disable 1998 public override async Task ExecuteAsync() { - Instrumentation.BeginContext(0, 16, true); - WriteLiteral("\r\n(Href("~/images/submit.png"), 22), false)); - Instrumentation.BeginContext(42, 3, true); - WriteLiteral(" />"); + Instrumentation.BeginContext(0, 45, true); + WriteLiteral("\r\n"); Instrumentation.EndContext(); } #pragma warning restore 1998 diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/Output/ResolveUrl.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/Output/ResolveUrl.cs deleted file mode 100644 index db852f50d0..0000000000 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/Output/ResolveUrl.cs +++ /dev/null @@ -1,133 +0,0 @@ -#pragma checksum "ResolveUrl.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "ee17a91893cee3c8590202192de89abe32776cc2" -namespace TestOutput -{ - using System; - using System.Threading.Tasks; - - public class ResolveUrl - { - #line hidden - public ResolveUrl() - { - } - - #pragma warning disable 1998 - public override async Task ExecuteAsync() - { - Instrumentation.BeginContext(0, 2, true); - WriteLiteral("(Href("~/Foo"), 9), false)); - Instrumentation.BeginContext(15, 12, true); - WriteLiteral(">Foo\r\n(Href("~/Products/"), 34), false), - Tuple.Create(Tuple.Create("", 45), Tuple.Create(product.id, 45), false)); - Instrumentation.BeginContext(57, 1, true); - WriteLiteral(">"); - Instrumentation.EndContext(); - Instrumentation.BeginContext(59, 12, false); -#line 2 "ResolveUrl.cshtml" - Write(product.Name); - -#line default -#line hidden - Instrumentation.EndContext(); - Instrumentation.BeginContext(71, 8, true); - WriteLiteral("\r\n(Href("~/Products/"), 86), false), - Tuple.Create(Tuple.Create("", 97), Tuple.Create(product.id, 97), false), Tuple.Create(Tuple.Create("", 108), Tuple.Create("/Detail", 108), true)); - Instrumentation.BeginContext(116, 16, true); - WriteLiteral(">Details\r\n(Href("~/A+Really(Crazy),Url.Is:This/"), 139), false), - Tuple.Create(Tuple.Create("", 169), Tuple.Create(product.id, 169), false), Tuple.Create(Tuple.Create("", 180), Tuple.Create("/Detail", 180), true)); - Instrumentation.BeginContext(188, 19, true); - WriteLiteral(">Crazy Url!\r\n\r\n"); - Instrumentation.EndContext(); -#line 6 "ResolveUrl.cshtml" - - -#line default -#line hidden - - Instrumentation.BeginContext(221, 12, true); - WriteLiteral("\r\n (Href("~/Foo"), 240), false)); - Instrumentation.BeginContext(246, 20, true); - WriteLiteral(">Foo\r\n (Href("~/Products/"), 273), false), - Tuple.Create(Tuple.Create("", 284), Tuple.Create(product.id, 284), false)); - Instrumentation.BeginContext(296, 1, true); - WriteLiteral(">"); - Instrumentation.EndContext(); - Instrumentation.BeginContext(298, 12, false); -#line 9 "ResolveUrl.cshtml" - Write(product.Name); - -#line default -#line hidden - Instrumentation.EndContext(); - Instrumentation.BeginContext(310, 16, true); - WriteLiteral("\r\n (Href("~/Products/"), 333), false), - Tuple.Create(Tuple.Create("", 344), Tuple.Create(product.id, 344), false), Tuple.Create(Tuple.Create("", 355), Tuple.Create("/Detail", 355), true)); - Instrumentation.BeginContext(363, 24, true); - WriteLiteral(">Details\r\n (Href("~/A+Really(Crazy),Url.Is:This/"), 394), false), - Tuple.Create(Tuple.Create("", 424), Tuple.Create(product.id, 424), false), Tuple.Create(Tuple.Create("", 435), Tuple.Create("/Detail", 435), true)); - Instrumentation.BeginContext(443, 23, true); - WriteLiteral(">Crazy Url!\r\n \r\n"); - Instrumentation.EndContext(); -#line 13 "ResolveUrl.cshtml" - -#line default -#line hidden - - Instrumentation.BeginContext(474, 4, true); - WriteLiteral("\r\n\r\n"); - Instrumentation.EndContext(); - DefineSection("Foo", async(__razor_template_writer) => { - Instrumentation.BeginContext(492, 8, true); - WriteLiteralTo(__razor_template_writer, "\r\n (Href("~/Foo"), 507), false)); - Instrumentation.BeginContext(513, 16, true); - WriteLiteralTo(__razor_template_writer, ">Foo\r\n (Href("~/Products/"), 536), false), - Tuple.Create(Tuple.Create("", 547), Tuple.Create(product.id, 547), false)); - Instrumentation.BeginContext(559, 1, true); - WriteLiteralTo(__razor_template_writer, ">"); - Instrumentation.EndContext(); - Instrumentation.BeginContext(561, 12, false); -#line 17 "ResolveUrl.cshtml" - WriteTo(__razor_template_writer, product.Name); - -#line default -#line hidden - Instrumentation.EndContext(); - Instrumentation.BeginContext(573, 12, true); - WriteLiteralTo(__razor_template_writer, "\r\n (Href("~/Products/"), 592), false), - Tuple.Create(Tuple.Create("", 603), Tuple.Create(product.id, 603), false), Tuple.Create(Tuple.Create("", 614), Tuple.Create("/Detail", 614), true)); - Instrumentation.BeginContext(622, 20, true); - WriteLiteralTo(__razor_template_writer, ">Details\r\n (Href("~/A+Really(Crazy),Url.Is:This/"), 649), false), - Tuple.Create(Tuple.Create("", 679), Tuple.Create(product.id, 679), false), Tuple.Create(Tuple.Create("", 690), Tuple.Create("/Detail", 690), true)); - Instrumentation.BeginContext(698, 17, true); - WriteLiteralTo(__razor_template_writer, ">Crazy Url!\r\n"); - Instrumentation.EndContext(); - } - ); - } - #pragma warning restore 1998 - } -} diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/Source/ResolveUrl.cshtml b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/Source/ResolveUrl.cshtml deleted file mode 100644 index fc8c77cf08..0000000000 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/Source/ResolveUrl.cshtml +++ /dev/null @@ -1,20 +0,0 @@ -Foo -@product.Name -Details -Crazy Url! - -@{ - - Foo - @product.Name - Details - Crazy Url! - -} - -@section Foo { - Foo - @product.Name - Details - Crazy Url! -} \ No newline at end of file