Change tests to utilize Environment.NewLine.
- Normalized newlines for code generation tests. We default all tests to use \r\n. This way we can have a consistent test experience cross plat. - For tests that expected indexes that were affected by new lines I modified them to account for cross plat scenarios. - Added a few test classes to ensure we could normalize newlines for codegen tests. #106
This commit is contained in:
parent
98df1e230b
commit
7d7b2795e1
|
|
@ -21,9 +21,15 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
|||
private CodeTree Tree { get { return Context.CodeTreeBuilder.CodeTree; } }
|
||||
public RazorEngineHost Host { get { return Context.Host; } }
|
||||
|
||||
// Internal for testing
|
||||
internal virtual CSharpCodeWriter CreateCodeWriter()
|
||||
{
|
||||
return new CSharpCodeWriter();
|
||||
}
|
||||
|
||||
public override CodeBuilderResult Build()
|
||||
{
|
||||
var writer = new CSharpCodeWriter();
|
||||
var writer = CreateCodeWriter();
|
||||
|
||||
if (!Host.DesignTimeMode && !string.IsNullOrEmpty(Context.Checksum))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
|||
public CSharpCodeWriter WriteLineNumberDirective(int lineNumber, string file)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(LastWrite) &&
|
||||
!LastWrite.EndsWith(Environment.NewLine, StringComparison.Ordinal))
|
||||
!LastWrite.EndsWith(NewLine, StringComparison.Ordinal))
|
||||
{
|
||||
WriteLine();
|
||||
}
|
||||
|
|
@ -455,7 +455,7 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
|||
}
|
||||
|
||||
Write("\" +");
|
||||
Write(Environment.NewLine);
|
||||
Write(NewLine);
|
||||
Write("\"");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler
|
|||
|
||||
private void WriteEndScope()
|
||||
{
|
||||
TryAutoSpace(Environment.NewLine);
|
||||
TryAutoSpace(_writer.NewLine);
|
||||
|
||||
// Ensure the scope hasn't been modified
|
||||
if (_writer.CurrentIndent == _startIndent)
|
||||
|
|
|
|||
|
|
@ -10,8 +10,7 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler
|
|||
public class CodeWriter : IDisposable
|
||||
{
|
||||
private static readonly char[] NewLineCharacters = new char[] { '\r', '\n' };
|
||||
|
||||
private StringWriter _writer = new StringWriter();
|
||||
private readonly StringWriter _writer = new StringWriter();
|
||||
private bool _newLine;
|
||||
private string _cache = string.Empty;
|
||||
private bool _dirty = false;
|
||||
|
|
@ -21,8 +20,21 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler
|
|||
private int _currentLineCharacterIndex;
|
||||
|
||||
public string LastWrite { get; private set; }
|
||||
|
||||
public int CurrentIndent { get; private set; }
|
||||
|
||||
public string NewLine
|
||||
{
|
||||
get
|
||||
{
|
||||
return _writer.NewLine;
|
||||
}
|
||||
set
|
||||
{
|
||||
_writer.NewLine = value;
|
||||
}
|
||||
}
|
||||
|
||||
public CodeWriter ResetIndent()
|
||||
{
|
||||
return SetIndent(0);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using System.Web.WebPages.TestUtils;
|
|||
using Microsoft.AspNet.Razor.Editor;
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
using Microsoft.AspNet.Razor.Test.Framework;
|
||||
using Microsoft.AspNet.Razor.Test.Generator;
|
||||
using Microsoft.AspNet.Razor.Test.Utils;
|
||||
using Microsoft.AspNet.Razor.Text;
|
||||
using Microsoft.AspNet.Testing;
|
||||
|
|
@ -98,15 +99,19 @@ namespace Microsoft.AspNet.Razor.Test.Editor
|
|||
var parameterName = "change";
|
||||
var exception = Assert.Throws<ArgumentException>(
|
||||
parameterName,
|
||||
() => new RazorEditorParser(
|
||||
CreateHost(),
|
||||
"C:\\Foo.cshtml").CheckForStructureChanges(change));
|
||||
() =>
|
||||
{
|
||||
using (var parser = new RazorEditorParser(CreateHost(), "C:\\Foo.cshtml"))
|
||||
{
|
||||
parser.CheckForStructureChanges(change);
|
||||
}
|
||||
});
|
||||
ExceptionHelpers.ValidateArgumentException(parameterName, RazorResources.FormatStructure_Member_CannotBeNull("Buffer", "TextChange"), exception);
|
||||
}
|
||||
|
||||
private static RazorEngineHost CreateHost()
|
||||
{
|
||||
return new RazorEngineHost(new CSharpRazorCodeLanguage()) { DesignTimeMode = true };
|
||||
return new CodeGenTestHost(new CSharpRazorCodeLanguage()) { DesignTimeMode = true };
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -114,7 +119,7 @@ namespace Microsoft.AspNet.Razor.Test.Editor
|
|||
public void CheckForStructureChangesStartsReparseAndFiresDocumentParseCompletedEventIfNoAdditionalChangesQueued()
|
||||
{
|
||||
// Arrange
|
||||
using (RazorEditorParser parser = CreateClientParser())
|
||||
using (var parser = CreateClientParser())
|
||||
{
|
||||
var input = new StringTextBuffer(SimpleCSHTMLDocument.ReadAllText());
|
||||
|
||||
|
|
@ -143,30 +148,32 @@ namespace Microsoft.AspNet.Razor.Test.Editor
|
|||
public void CheckForStructureChangesStartsFullReparseIfChangeOverlapsMultipleSpans()
|
||||
{
|
||||
// Arrange
|
||||
var parser = new RazorEditorParser(CreateHost(), TestLinePragmaFileName);
|
||||
var original = new StringTextBuffer("Foo @bar Baz");
|
||||
var changed = new StringTextBuffer("Foo @bap Daz");
|
||||
var change = new TextChange(7, 3, original, 3, changed);
|
||||
|
||||
var parseComplete = new ManualResetEventSlim();
|
||||
var parseCount = 0;
|
||||
parser.DocumentParseComplete += (sender, args) =>
|
||||
using (var parser = new RazorEditorParser(CreateHost(), TestLinePragmaFileName))
|
||||
{
|
||||
Interlocked.Increment(ref parseCount);
|
||||
parseComplete.Set();
|
||||
};
|
||||
var original = new StringTextBuffer("Foo @bar Baz");
|
||||
var changed = new StringTextBuffer("Foo @bap Daz");
|
||||
var change = new TextChange(7, 3, original, 3, changed);
|
||||
|
||||
Assert.Equal(PartialParseResult.Rejected, parser.CheckForStructureChanges(new TextChange(0, 0, new StringTextBuffer(String.Empty), 12, original)));
|
||||
MiscUtils.DoWithTimeoutIfNotDebugging(parseComplete.Wait); // Wait for the parse to finish
|
||||
parseComplete.Reset();
|
||||
var parseComplete = new ManualResetEventSlim();
|
||||
var parseCount = 0;
|
||||
parser.DocumentParseComplete += (sender, args) =>
|
||||
{
|
||||
Interlocked.Increment(ref parseCount);
|
||||
parseComplete.Set();
|
||||
};
|
||||
|
||||
// Act
|
||||
var result = parser.CheckForStructureChanges(change);
|
||||
Assert.Equal(PartialParseResult.Rejected, parser.CheckForStructureChanges(new TextChange(0, 0, new StringTextBuffer(String.Empty), 12, original)));
|
||||
MiscUtils.DoWithTimeoutIfNotDebugging(parseComplete.Wait); // Wait for the parse to finish
|
||||
parseComplete.Reset();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(PartialParseResult.Rejected, result);
|
||||
MiscUtils.DoWithTimeoutIfNotDebugging(parseComplete.Wait);
|
||||
Assert.Equal(2, parseCount);
|
||||
// Act
|
||||
var result = parser.CheckForStructureChanges(change);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(PartialParseResult.Rejected, result);
|
||||
MiscUtils.DoWithTimeoutIfNotDebugging(parseComplete.Wait);
|
||||
Assert.Equal(2, parseCount);
|
||||
}
|
||||
}
|
||||
|
||||
private TextChange CreateDummyChange()
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
//#define PARSER_TRACE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
|
@ -292,11 +290,11 @@ namespace Microsoft.AspNet.Razor.Test.Framework
|
|||
EvaluateSyntaxTreeNode(collector, actualRoot, expectedRoot);
|
||||
if (collector.Success)
|
||||
{
|
||||
WriteTraceLine("Parse Tree Validation Succeeded:\r\n{0}", collector.Message);
|
||||
WriteTraceLine("Parse Tree Validation Succeeded:" + Environment.NewLine + collector.Message);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.True(false, String.Format("\r\n{0}", collector.Message));
|
||||
Assert.True(false, Environment.NewLine + collector.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -458,20 +456,20 @@ namespace Microsoft.AspNet.Razor.Test.Framework
|
|||
// Evaluate the errors
|
||||
if (expectedErrors == null || expectedErrors.Count == 0)
|
||||
{
|
||||
Assert.True(realCount == 0,
|
||||
String.Format("Expected that no errors would be raised, but the following errors were:\r\n{0}", FormatErrors(actualErrors)));
|
||||
Assert.True(
|
||||
realCount == 0,
|
||||
"Expected that no errors would be raised, but the following errors were:" + Environment.NewLine + FormatErrors(actualErrors));
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.True(expectedErrors.Count == realCount,
|
||||
String.Format("Expected that {0} errors would be raised, but {1} errors were.\r\nExpected Errors: \r\n{2}\r\nActual Errors: \r\n{3}",
|
||||
expectedErrors.Count,
|
||||
realCount,
|
||||
FormatErrors(expectedErrors),
|
||||
FormatErrors(actualErrors)));
|
||||
Assert.True(
|
||||
expectedErrors.Count == realCount,
|
||||
$"Expected that {expectedErrors.Count} errors would be raised, but {realCount} errors were." +
|
||||
$"{Environment.NewLine}Expected Errors: {Environment.NewLine}{FormatErrors(expectedErrors)}" +
|
||||
$"{Environment.NewLine}Actual Errors: {Environment.NewLine}{FormatErrors(actualErrors)}");
|
||||
Assert.Equal(expectedErrors, actualErrors);
|
||||
}
|
||||
WriteTraceLine("Expected Errors were raised:\r\n{0}", FormatErrors(expectedErrors));
|
||||
WriteTraceLine("Expected Errors were raised:" + Environment.NewLine + FormatErrors(expectedErrors));
|
||||
}
|
||||
|
||||
public static string FormatErrors(IEnumerable<RazorError> errors)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. 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.Generator;
|
||||
using Microsoft.AspNet.Razor.Generator.Compiler.CSharp;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Test.Generator
|
||||
{
|
||||
public class CodeGenTestCodeBuilder : CSharpCodeBuilder
|
||||
{
|
||||
public CodeGenTestCodeBuilder(CodeBuilderContext context)
|
||||
: base(context)
|
||||
{
|
||||
}
|
||||
|
||||
internal override CSharpCodeWriter CreateCodeWriter()
|
||||
{
|
||||
return new TestCodeWriter();
|
||||
}
|
||||
|
||||
private class TestCodeWriter : CSharpCodeWriter
|
||||
{
|
||||
public TestCodeWriter()
|
||||
{
|
||||
// We normalize newlines so no matter what platform we're on they're consistent
|
||||
// (for code generation tests).
|
||||
NewLine = "\r\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. 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.Generator;
|
||||
using Microsoft.AspNet.Razor.Generator.Compiler;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Test.Generator
|
||||
{
|
||||
public class CodeGenTestHost : RazorEngineHost
|
||||
{
|
||||
public CodeGenTestHost(RazorCodeLanguage language)
|
||||
: base(language)
|
||||
{
|
||||
}
|
||||
|
||||
public override CodeBuilder DecorateCodeBuilder(CodeBuilder incomingBuilder, CodeBuilderContext context)
|
||||
{
|
||||
if (incomingBuilder is CodeGenTestCodeBuilder)
|
||||
{
|
||||
return incomingBuilder;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new CodeGenTestCodeBuilder(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -18,7 +18,7 @@ namespace Microsoft.AspNet.Razor.Test.Generator.CodeTree
|
|||
{
|
||||
var syntaxTreeNode = new Mock<Span>(new SpanBuilder());
|
||||
var language = new CSharpRazorCodeLanguage();
|
||||
var host = new RazorEngineHost(language);
|
||||
var host = new CodeGenTestHost(language);
|
||||
var codeBuilderContext = new CodeBuilderContext(
|
||||
host,
|
||||
"TestClass",
|
||||
|
|
@ -28,7 +28,7 @@ namespace Microsoft.AspNet.Razor.Test.Generator.CodeTree
|
|||
errorSink: new ParserErrorSink());
|
||||
codeBuilderContext.CodeTreeBuilder.AddUsingChunk("FakeNamespace1", syntaxTreeNode.Object);
|
||||
codeBuilderContext.CodeTreeBuilder.AddUsingChunk("FakeNamespace2.SubNamespace", syntaxTreeNode.Object);
|
||||
var codeBuilder = language.CreateCodeBuilder(codeBuilderContext);
|
||||
var codeBuilder = new CodeGenTestCodeBuilder(codeBuilderContext);
|
||||
|
||||
// Act
|
||||
var result = codeBuilder.Build();
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
|||
"");
|
||||
var expectedMappings = new LineMapping(
|
||||
new MappingLocation(location, 30),
|
||||
new MappingLocation(new SourceLocation(18, 1, 0), 11));
|
||||
new MappingLocation(new SourceLocation(16 + Environment.NewLine.Length, 1, 0), 11));
|
||||
var writer = new CSharpCodeWriter();
|
||||
|
||||
// Act
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
//#define GENERATE_BASELINES
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.AspNet.Razor.Generator;
|
||||
using Microsoft.AspNet.Razor.Generator.Compiler;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
|
|
@ -26,19 +26,20 @@ namespace Microsoft.AspNet.Razor.Test.Generator
|
|||
|
||||
protected RazorEngineHost CreateHost()
|
||||
{
|
||||
return new RazorEngineHost(new TLanguage());
|
||||
return new CodeGenTestHost(new TLanguage());
|
||||
}
|
||||
|
||||
protected void RunTest(string name,
|
||||
string baselineName = null,
|
||||
bool generatePragmas = true,
|
||||
bool designTimeMode = false,
|
||||
IList<LineMapping> expectedDesignTimePragmas = null,
|
||||
TestSpan[] spans = null,
|
||||
TabTest tabTest = TabTest.Both,
|
||||
Func<RazorEngineHost, RazorEngineHost> hostConfig = null,
|
||||
Func<RazorTemplateEngine, RazorTemplateEngine> templateEngineConfig = null,
|
||||
Action<GeneratorResults> onResults = null)
|
||||
protected void RunTest(
|
||||
string name,
|
||||
string baselineName = null,
|
||||
bool generatePragmas = true,
|
||||
bool designTimeMode = false,
|
||||
IList<LineMapping> expectedDesignTimePragmas = null,
|
||||
TestSpan[] spans = null,
|
||||
TabTest tabTest = TabTest.Both,
|
||||
Func<RazorEngineHost, RazorEngineHost> hostConfig = null,
|
||||
Func<RazorTemplateEngine, RazorTemplateEngine> templateEngineConfig = null,
|
||||
Action<GeneratorResults> onResults = null)
|
||||
{
|
||||
var testRun = false;
|
||||
|
||||
|
|
@ -85,16 +86,41 @@ namespace Microsoft.AspNet.Razor.Test.Generator
|
|||
Assert.True(testRun, "No test was run because TabTest is not set correctly");
|
||||
}
|
||||
|
||||
private void RunTestInternal(string name,
|
||||
string baselineName,
|
||||
bool generatePragmas,
|
||||
bool designTimeMode,
|
||||
IList<LineMapping> expectedDesignTimePragmas,
|
||||
TestSpan[] spans,
|
||||
bool withTabs,
|
||||
Func<RazorEngineHost, RazorEngineHost> hostConfig,
|
||||
Func<RazorTemplateEngine, RazorTemplateEngine> templateEngineConfig,
|
||||
Action<GeneratorResults> onResults = null)
|
||||
private Stream NormalizeNewLines(Stream inputStream)
|
||||
{
|
||||
if (!inputStream.CanSeek)
|
||||
{
|
||||
var memoryStream = new MemoryStream();
|
||||
inputStream.CopyTo(memoryStream);
|
||||
|
||||
// We don't have to dispose the input stream since it is owned externally.
|
||||
inputStream = memoryStream;
|
||||
}
|
||||
|
||||
inputStream.Position = 0;
|
||||
var reader = new StreamReader(inputStream);
|
||||
|
||||
// Normalize newlines to be \r\n. This is to ensure when running tests cross plat the final test output
|
||||
// is compared against test files in a normalized fashion.
|
||||
var fileContents = reader.ReadToEnd().Replace(Environment.NewLine, "\r\n");
|
||||
|
||||
// Since this is a test we can normalize to utf8.
|
||||
inputStream = new MemoryStream(Encoding.UTF8.GetBytes(fileContents));
|
||||
|
||||
return inputStream;
|
||||
}
|
||||
|
||||
private void RunTestInternal(
|
||||
string name,
|
||||
string baselineName,
|
||||
bool generatePragmas,
|
||||
bool designTimeMode,
|
||||
IList<LineMapping> expectedDesignTimePragmas,
|
||||
TestSpan[] spans,
|
||||
bool withTabs,
|
||||
Func<RazorEngineHost, RazorEngineHost> hostConfig,
|
||||
Func<RazorTemplateEngine, RazorTemplateEngine> templateEngineConfig,
|
||||
Action<GeneratorResults> onResults = null)
|
||||
{
|
||||
// Load the test files
|
||||
if (baselineName == null)
|
||||
|
|
@ -146,8 +172,9 @@ namespace Microsoft.AspNet.Razor.Test.Generator
|
|||
GeneratorResults results = null;
|
||||
using (var source = TestFile.Create(sourceLocation).OpenRead())
|
||||
{
|
||||
var sourceFile = NormalizeNewLines(source);
|
||||
var sourceFileName = generatePragmas ? String.Format("{0}.{1}", name, FileExtension) : null;
|
||||
results = engine.GenerateCode(source, className: name, rootNamespace: TestRootNamespaceName, sourceFileName: sourceFileName);
|
||||
results = engine.GenerateCode(sourceFile, className: name, rootNamespace: TestRootNamespaceName, sourceFileName: sourceFileName);
|
||||
}
|
||||
// Only called if GENERATE_BASELINES is set, otherwise compiled out.
|
||||
BaselineWriter.WriteBaseline(String.Format(@"test\Microsoft.AspNet.Razor.Test\TestFiles\CodeGenerator\{0}\Output\{1}.{2}", LanguageName, baselineName, BaselineExtension), results.GeneratedCode);
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ namespace Microsoft.AspNet.Razor.Test.Generator
|
|||
});
|
||||
}
|
||||
|
||||
private class CodeBuilderReplacingHost : RazorEngineHost
|
||||
private class CodeBuilderReplacingHost : CodeGenTestHost
|
||||
{
|
||||
public CodeBuilderReplacingHost(RazorEngineHost originalHost)
|
||||
: base(new CSharpRazorCodeLanguage())
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ namespace Microsoft.AspNet.Razor.Test.Generator
|
|||
}
|
||||
}
|
||||
|
||||
protected class TestCSharpCodeBuilder : CSharpCodeBuilder
|
||||
protected class TestCSharpCodeBuilder : CodeGenTestCodeBuilder
|
||||
{
|
||||
public TestCSharpCodeBuilder(CodeBuilderContext context)
|
||||
: base(context)
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.MetaCode("functions{")
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\nfoo")
|
||||
Factory.Code(Environment.NewLine + "foo")
|
||||
.AsFunctionsBody()
|
||||
.With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString)
|
||||
{
|
||||
|
|
@ -94,14 +94,14 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
.AutoCompleteWith("}", atEndOfSpan: true)
|
||||
.Accepts(AcceptedCharacters.Any),
|
||||
new MarkupBlock(
|
||||
Factory.Markup("\r\n"),
|
||||
Factory.Markup(Environment.NewLine),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("<p>")),
|
||||
Factory.Markup("Foo"),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("</p>")))),
|
||||
new RazorError(RazorResources.FormatParseError_Expected_X("}"),
|
||||
29, 1, 10));
|
||||
27 + Environment.NewLine.Length, 1, 10));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -112,7 +112,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("{").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n")
|
||||
Factory.Code(Environment.NewLine)
|
||||
.AsStatement()
|
||||
.With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = "}" }),
|
||||
new MarkupBlock(
|
||||
|
|
|
|||
|
|
@ -677,11 +677,11 @@ catch(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
|
|||
+ " </div>" + Environment.NewLine
|
||||
+ " }",
|
||||
new StatementBlock(
|
||||
Factory.Code("foreach(var c in db.Categories) {\r\n").AsStatement(),
|
||||
Factory.Code("foreach(var c in db.Categories) {" + Environment.NewLine).AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
BlockFactory.MarkupTagBlock("<div>", AcceptedCharacters.None),
|
||||
Factory.Markup("\r\n "),
|
||||
Factory.Markup(Environment.NewLine + " "),
|
||||
BlockFactory.MarkupTagBlock("<h1>", AcceptedCharacters.None),
|
||||
Factory.EmptyHtml(),
|
||||
new ExpressionBlock(
|
||||
|
|
@ -690,21 +690,27 @@ catch(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
|
|||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
BlockFactory.MarkupTagBlock("</h1>", AcceptedCharacters.None),
|
||||
Factory.Markup("\r\n "),
|
||||
Factory.Markup(Environment.NewLine + " "),
|
||||
BlockFactory.MarkupTagBlock("<ul>", AcceptedCharacters.None),
|
||||
Factory.Markup("\r\n"),
|
||||
Factory.Markup(Environment.NewLine),
|
||||
new StatementBlock(
|
||||
Factory.Code(@" ").AsStatement(),
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("foreach(var p in c.Products) {\r\n").AsStatement(),
|
||||
Factory.Code("foreach(var p in c.Products) {" + Environment.NewLine).AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
BlockFactory.MarkupTagBlock("<li>", AcceptedCharacters.None),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("<a"),
|
||||
new MarkupBlock(new AttributeBlockCodeGenerator("href", new LocationTagged<string>(" href=\"", 193, 5, 30), new LocationTagged<string>("\"", 256, 5, 93)),
|
||||
new MarkupBlock(
|
||||
new AttributeBlockCodeGenerator(
|
||||
"href",
|
||||
new LocationTagged<string>(" href=\"", 183 + Environment.NewLine.Length * 5, 5, 30),
|
||||
new LocationTagged<string>("\"", 246 + Environment.NewLine.Length * 5, 5, 93)),
|
||||
Factory.Markup(" href=\"").With(SpanCodeGenerator.Null),
|
||||
new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged<string>(string.Empty, 200, 5, 37), 200, 5, 37),
|
||||
new MarkupBlock(
|
||||
new DynamicAttributeBlockCodeGenerator(
|
||||
new LocationTagged<string>(string.Empty, 190 + Environment.NewLine.Length * 5, 5, 37), 190 + Environment.NewLine.Length * 5, 5, 37),
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("Html.ActionUrl(\"Products\", \"Detail\", new { id = p.Id })")
|
||||
|
|
@ -720,13 +726,13 @@ catch(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
|
|||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
BlockFactory.MarkupTagBlock("</a>", AcceptedCharacters.None),
|
||||
BlockFactory.MarkupTagBlock("</li>", AcceptedCharacters.None),
|
||||
Factory.Markup("\r\n").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Code(" }\r\n").AsStatement().Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup(Environment.NewLine).Accepts(AcceptedCharacters.None)),
|
||||
Factory.Code(" }" + Environment.NewLine).AsStatement().Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup(" "),
|
||||
BlockFactory.MarkupTagBlock("</ul>", AcceptedCharacters.None),
|
||||
Factory.Markup("\r\n "),
|
||||
Factory.Markup(Environment.NewLine + " "),
|
||||
BlockFactory.MarkupTagBlock("</div>", AcceptedCharacters.None),
|
||||
Factory.Markup("\r\n").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup(Environment.NewLine).Accepts(AcceptedCharacters.None)),
|
||||
Factory.Code(" }").AsStatement().Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
ParseBlockTest("using " + Environment.NewLine
|
||||
+ Environment.NewLine,
|
||||
new StatementBlock(
|
||||
Factory.Code("using \r\n").AsStatement()
|
||||
Factory.Code("using " + Environment.NewLine).AsStatement()
|
||||
));
|
||||
}
|
||||
|
||||
|
|
@ -83,16 +83,16 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
+ "}",
|
||||
new StatementBlock(
|
||||
Factory.MetaCode("{").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n ").AsStatement(),
|
||||
Factory.Code(Environment.NewLine + " ").AsStatement(),
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.EmptyCSharp()
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords, acceptTrailingDot: true)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
Factory.Code(" {}\r\n").AsStatement(),
|
||||
Factory.Code(" {}" + Environment.NewLine).AsStatement(),
|
||||
Factory.MetaCode("}").Accepts(AcceptedCharacters.None)
|
||||
),
|
||||
new RazorError(RazorResources.ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS, 8, 1, 5));
|
||||
new RazorError(RazorResources.ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS, 6 + Environment.NewLine.Length, 1, 5));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -102,7 +102,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
+ " @",
|
||||
new StatementBlock(
|
||||
Factory.MetaCode("{").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n ").AsStatement(),
|
||||
Factory.Code(Environment.NewLine + " ").AsStatement(),
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.EmptyCSharp()
|
||||
|
|
@ -110,7 +110,8 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
Factory.EmptyCSharp().AsStatement()
|
||||
),
|
||||
new RazorError(RazorResources.ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock, 8, 1, 5),
|
||||
new RazorError(
|
||||
RazorResources.ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock, 6 + Environment.NewLine.Length, 1, 5),
|
||||
new RazorError(
|
||||
RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_Code, "}", "{"),
|
||||
SourceLocation.Zero));
|
||||
|
|
@ -137,7 +138,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
+ "baz",
|
||||
new ExpressionBlock(
|
||||
Factory.MetaCode("(").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("foo bar\r\nbaz").AsExpression()
|
||||
Factory.Code($"foo bar{Environment.NewLine}baz").AsExpression()
|
||||
),
|
||||
new RazorError(
|
||||
RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_ExplicitExpression, ')', '('),
|
||||
|
|
@ -153,7 +154,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
+ "</html",
|
||||
new ExpressionBlock(
|
||||
Factory.MetaCode("(").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("foo bar\r\n").AsExpression()
|
||||
Factory.Code($"foo bar{Environment.NewLine}").AsExpression()
|
||||
),
|
||||
new RazorError(
|
||||
RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_ExplicitExpression, ')', '('),
|
||||
|
|
@ -166,7 +167,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
ParseBlockTest("Href(" + Environment.NewLine
|
||||
+ "<h1>@Html.Foo(Bar);</h1>" + Environment.NewLine,
|
||||
new ExpressionBlock(
|
||||
Factory.Code("Href(\r\n")
|
||||
Factory.Code("Href(" + Environment.NewLine)
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||
),
|
||||
new RazorError(
|
||||
|
|
@ -182,7 +183,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
+ "Biz" + Environment.NewLine
|
||||
+ "Boz",
|
||||
new ExpressionBlock(
|
||||
Factory.Code("Foo(Bar(Baz)\r\nBiz\r\nBoz")
|
||||
Factory.Code($"Foo(Bar(Baz){Environment.NewLine}Biz{Environment.NewLine}Boz")
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||
),
|
||||
new RazorError(RazorResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
||||
|
|
@ -199,7 +200,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
+ "Boz" + Environment.NewLine
|
||||
+ "</html>",
|
||||
new ExpressionBlock(
|
||||
Factory.Code("Foo(Bar(Baz)\r\nBiz\r\n")
|
||||
Factory.Code($"Foo(Bar(Baz){Environment.NewLine}Biz{Environment.NewLine}")
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||
),
|
||||
new RazorError(RazorResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
||||
|
|
@ -214,7 +215,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
+ "Biz" + Environment.NewLine
|
||||
+ "Boz",
|
||||
new ExpressionBlock(
|
||||
Factory.Code("Foo[Bar[Baz]\r\nBiz\r\nBoz")
|
||||
Factory.Code($"Foo[Bar[Baz]{Environment.NewLine}Biz{Environment.NewLine}Boz")
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||
),
|
||||
new RazorError(
|
||||
|
|
@ -232,7 +233,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
+ "Boz" + Environment.NewLine
|
||||
+ "</b>",
|
||||
new ExpressionBlock(
|
||||
Factory.Code("Foo[Bar[Baz]\r\nBiz\r\n")
|
||||
Factory.Code($"Foo[Bar[Baz]{Environment.NewLine}Biz{Environment.NewLine}")
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||
),
|
||||
new RazorError(
|
||||
|
|
@ -449,7 +450,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
ParseBlockTest("if(foo bar" + Environment.NewLine
|
||||
+ "baz",
|
||||
new StatementBlock(
|
||||
Factory.Code("if(foo bar\r\n").AsStatement()
|
||||
Factory.Code("if(foo bar" + Environment.NewLine).AsStatement()
|
||||
),
|
||||
new RazorError(
|
||||
RazorResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
||||
|
|
@ -462,7 +463,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
ParseBlockTest("foreach(foo bar" + Environment.NewLine
|
||||
+ "baz",
|
||||
new StatementBlock(
|
||||
Factory.Code("foreach(foo bar\r\n").AsStatement()
|
||||
Factory.Code("foreach(foo bar" + Environment.NewLine).AsStatement()
|
||||
),
|
||||
new RazorError(
|
||||
RazorResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
||||
|
|
@ -475,7 +476,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
ParseBlockTest("do { } while(foo bar" + Environment.NewLine
|
||||
+ "baz",
|
||||
new StatementBlock(
|
||||
Factory.Code("do { } while(foo bar\r\n").AsStatement()
|
||||
Factory.Code("do { } while(foo bar" + Environment.NewLine).AsStatement()
|
||||
),
|
||||
new RazorError(
|
||||
RazorResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
||||
|
|
@ -488,7 +489,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
ParseBlockTest("using(foo bar" + Environment.NewLine
|
||||
+ "baz",
|
||||
new StatementBlock(
|
||||
Factory.Code("using(foo bar\r\n").AsStatement()
|
||||
Factory.Code("using(foo bar" + Environment.NewLine).AsStatement()
|
||||
),
|
||||
new RazorError(
|
||||
RazorResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
||||
|
|
@ -501,7 +502,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
ParseBlockTest("if(" + Environment.NewLine
|
||||
+ "else { <p>Foo</p> }",
|
||||
new StatementBlock(
|
||||
Factory.Code("if(\r\nelse {").AsStatement(),
|
||||
Factory.Code($"if({Environment.NewLine}else {{").AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
BlockFactory.MarkupTagBlock("<p>", AcceptedCharacters.None),
|
||||
|
|
@ -523,7 +524,8 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
+ ";" + Environment.NewLine
|
||||
+ "}",
|
||||
BlockType.Statement, SpanKind.Code,
|
||||
new RazorError(RazorResources.ParseError_Unterminated_String_Literal, 23, 1, 12));
|
||||
new RazorError(
|
||||
RazorResources.ParseError_Unterminated_String_Literal, 21 + Environment.NewLine.Length, 1, 12));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -555,7 +557,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
+ " <p>Foo is @foo</p>" + Environment.NewLine
|
||||
+ "}",
|
||||
new StatementBlock(
|
||||
Factory.Code("if(foo) {\r\n var foo = \"foo bar baz\r\n ").AsStatement(),
|
||||
Factory.Code($"if(foo) {{{Environment.NewLine} var foo = \"foo bar baz{Environment.NewLine} ").AsStatement(),
|
||||
new MarkupBlock(
|
||||
BlockFactory.MarkupTagBlock("<p>", AcceptedCharacters.None),
|
||||
Factory.Markup("Foo is "),
|
||||
|
|
@ -565,12 +567,12 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
BlockFactory.MarkupTagBlock("</p>", AcceptedCharacters.None),
|
||||
Factory.Markup("\r\n").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup(Environment.NewLine).Accepts(AcceptedCharacters.None)),
|
||||
Factory.Code("}").AsStatement()
|
||||
),
|
||||
new RazorError(
|
||||
RazorResources.ParseError_Unterminated_String_Literal,
|
||||
25, 1, 14));
|
||||
23 + Environment.NewLine.Length, 1, 14));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("(").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("@\"\r\nFoo\r\nBar\r\nBaz\r\n\"").AsExpression(),
|
||||
Factory.Code($"@\"{Environment.NewLine}Foo{Environment.NewLine}Bar{Environment.NewLine}Baz{Environment.NewLine}\"").AsExpression(),
|
||||
Factory.MetaCode(")").Accepts(AcceptedCharacters.None)
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
new DirectiveBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("layout ").Accepts(AcceptedCharacters.None),
|
||||
Factory.MetaCode("Foo\r\n")
|
||||
Factory.MetaCode("Foo" + Environment.NewLine)
|
||||
.With(new SetLayoutCodeGenerator("Foo"))
|
||||
.Accepts(AcceptedCharacters.None)
|
||||
.WithEditorHints(EditorHints.VirtualPath | EditorHints.LayoutPage)
|
||||
|
|
@ -93,7 +93,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
new DirectiveBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("layout ").Accepts(AcceptedCharacters.None),
|
||||
Factory.MetaCode("Foo\r\n")
|
||||
Factory.MetaCode("Foo" + Environment.NewLine)
|
||||
.With(new SetLayoutCodeGenerator("Foo"))
|
||||
.Accepts(AcceptedCharacters.None)
|
||||
.WithEditorHints(EditorHints.VirtualPath | EditorHints.LayoutPage)
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
Factory.EmptyHtml(),
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("foo(\r\n")
|
||||
Factory.Code("foo(" + Environment.NewLine)
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords),
|
||||
new CommentBlock(
|
||||
Factory.CodeTransition(CSharpSymbolType.RazorCommentTransition)
|
||||
|
|
@ -79,7 +79,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.CodeTransition(CSharpSymbolType.RazorCommentTransition)
|
||||
.Accepts(AcceptedCharacters.None)),
|
||||
Factory.Code("\r\n")
|
||||
Factory.Code(Environment.NewLine)
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords))),
|
||||
new RazorError(
|
||||
RazorResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
||||
|
|
@ -122,12 +122,12 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("{").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n").AsStatement(),
|
||||
Factory.Code(Environment.NewLine).AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
new MarkupTagBlock(
|
||||
Factory.MarkupTransition("<text").Accepts(AcceptedCharacters.Any)),
|
||||
Factory.Markup("\r\n ").Accepts(AcceptedCharacters.None),
|
||||
Factory.Markup(Environment.NewLine + " ").Accepts(AcceptedCharacters.None),
|
||||
new CommentBlock(
|
||||
Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition)
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
|
|
@ -142,9 +142,9 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition)
|
||||
.Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup("\r\n}")))),
|
||||
new RazorError(RazorResources.ParseError_TextTagCannotContainAttributes, 8, 1, 4),
|
||||
new RazorError(RazorResources.FormatParseError_MissingEndTag("text"), 8, 1, 4),
|
||||
Factory.Markup(Environment.NewLine + "}")))),
|
||||
new RazorError(RazorResources.ParseError_TextTagCannotContainAttributes, 6 + Environment.NewLine.Length, 1, 4),
|
||||
new RazorError(RazorResources.FormatParseError_MissingEndTag("text"), 6 + Environment.NewLine.Length, 1, 4),
|
||||
new RazorError(RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_Code, "}", "{"), 1, 0, 1));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
Factory.EmptyHtml(),
|
||||
new SectionBlock(new SectionCodeGenerator(String.Empty),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("section\r\n"))),
|
||||
Factory.MetaCode("section" + Environment.NewLine))),
|
||||
new RazorError(
|
||||
RazorResources.FormatParseError_Unexpected_Character_At_Section_Name_Start(RazorResources.ErrorComponent_EndOfFile),
|
||||
10, 1, 0));
|
||||
8 + Environment.NewLine.Length, 1, 0));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -35,7 +35,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
Factory.EmptyHtml(),
|
||||
new SectionBlock(new SectionCodeGenerator("Foo"),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("section Foo \r\n")),
|
||||
Factory.MetaCode("section Foo " + Environment.NewLine)),
|
||||
Factory.Markup(" ")),
|
||||
new RazorError(RazorResources.ParseError_MissingOpenBraceAfterSection, 12, 0, 12));
|
||||
}
|
||||
|
|
@ -47,13 +47,13 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
+ " ",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new SectionBlock(new SectionCodeGenerator(String.Empty),
|
||||
new SectionBlock(new SectionCodeGenerator(string.Empty),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("section \r\n")),
|
||||
Factory.MetaCode("section " + Environment.NewLine)),
|
||||
Factory.Markup(" ")),
|
||||
new RazorError(
|
||||
RazorResources.FormatParseError_Unexpected_Character_At_Section_Name_Start(RazorResources.ErrorComponent_EndOfFile),
|
||||
23, 1, 4));
|
||||
21 + Environment.NewLine.Length, 1, 4));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -190,7 +190,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
Factory.EmptyHtml(),
|
||||
new SectionBlock(new SectionCodeGenerator("foo"),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("section foo \r\n"))),
|
||||
Factory.MetaCode("section foo " + Environment.NewLine))),
|
||||
new RazorError(RazorResources.ParseError_MissingOpenBraceAfterSection, 12, 0, 12));
|
||||
}
|
||||
|
||||
|
|
@ -210,16 +210,16 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
Factory.EmptyHtml(),
|
||||
new SectionBlock(new SectionCodeGenerator("foo"),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("section foo \r\n\r\n\r\n\r\n\r\n\r\n{")
|
||||
Factory.MetaCode(string.Format("section foo {0}{0}{0}{0}{0}{0}{{", Environment.NewLine))
|
||||
.AutoCompleteWith(null, atEndOfSpan: true),
|
||||
new MarkupBlock(
|
||||
Factory.Markup("\r\n"),
|
||||
Factory.Markup(Environment.NewLine),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("<p>")),
|
||||
Factory.Markup("Foo"),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("</p>")),
|
||||
Factory.Markup("\r\n")),
|
||||
Factory.Markup(Environment.NewLine)),
|
||||
Factory.MetaCode("}").Accepts(AcceptedCharacters.None)),
|
||||
Factory.EmptyHtml()));
|
||||
}
|
||||
|
|
@ -326,10 +326,10 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
Factory.MetaCode("section Foo {")
|
||||
.AutoCompleteWith(null, atEndOfSpan: true),
|
||||
new MarkupBlock(
|
||||
Factory.Markup("\r\n"),
|
||||
Factory.Markup(Environment.NewLine),
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("if(true) {\r\n}\r\n").AsStatement()
|
||||
Factory.Code($"if(true) {{{Environment.NewLine}}}{Environment.NewLine}").AsStatement()
|
||||
)),
|
||||
Factory.MetaCode("}").Accepts(AcceptedCharacters.None)),
|
||||
Factory.EmptyHtml()));
|
||||
|
|
@ -348,10 +348,10 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
Factory.MetaCode("section Foo {")
|
||||
.AutoCompleteWith(null, atEndOfSpan: true),
|
||||
new MarkupBlock(
|
||||
Factory.Markup("\r\n"),
|
||||
Factory.Markup(Environment.NewLine),
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("if(true) {\r\n}").AsStatement()
|
||||
Factory.Code($"if(true) {{{Environment.NewLine}}}").AsStatement()
|
||||
)),
|
||||
Factory.MetaCode("}").Accepts(AcceptedCharacters.None)),
|
||||
Factory.EmptyHtml()));
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
+ "foo",
|
||||
new DirectiveBlock(
|
||||
Factory.MetaCode("inherits ").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code(" \r\n")
|
||||
Factory.Code(" " + Environment.NewLine)
|
||||
.AsBaseType(String.Empty)
|
||||
),
|
||||
new RazorError(RazorResources.ParseError_InheritsKeyword_Must_Be_Followed_By_TypeName, 24, 0, 24));
|
||||
|
|
@ -95,7 +95,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
+ "}",
|
||||
new StatementBlock(
|
||||
Factory.MetaCode("{").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n List<dynamic> photos = gallery.Photo.ToList();\r\n").AsStatement(),
|
||||
Factory.Code($"{Environment.NewLine} List<dynamic> photos = gallery.Photo.ToList();{Environment.NewLine}").AsStatement(),
|
||||
Factory.MetaCode("}").Accepts(AcceptedCharacters.None)
|
||||
));
|
||||
}
|
||||
|
|
@ -187,7 +187,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
+ "\t<p>A real tag!</p>" + Environment.NewLine
|
||||
+ "}",
|
||||
new StatementBlock(
|
||||
Factory.Code("if(!false) {\r\n // Foo\r\n").AsStatement(),
|
||||
Factory.Code($"if(!false) {{{Environment.NewLine} // Foo{Environment.NewLine}").AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup("\t"),
|
||||
new MarkupTagBlock(
|
||||
|
|
@ -195,7 +195,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
Factory.Markup("A real tag!"),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("</p>").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup("\r\n").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup(Environment.NewLine).Accepts(AcceptedCharacters.None)),
|
||||
Factory.Code("}").AsStatement()
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
new MarkupBlock(
|
||||
Factory.MarkupTransition(),
|
||||
Factory.MetaMarkup(":", HtmlSymbolType.Colon),
|
||||
Factory.Markup(" bar\r\n")
|
||||
Factory.Markup(" bar" + Environment.NewLine)
|
||||
.With(new SingleLineMarkupEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString))
|
||||
.Accepts(AcceptedCharacters.None)
|
||||
)
|
||||
|
|
@ -110,7 +110,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
new MarkupBlock(
|
||||
Factory.MarkupTransition(),
|
||||
Factory.MetaMarkup(":", HtmlSymbolType.Colon),
|
||||
Factory.Markup(" bar\r\n")
|
||||
Factory.Markup(" bar" + Environment.NewLine)
|
||||
.With(new SingleLineMarkupEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString))
|
||||
.Accepts(AcceptedCharacters.None)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -54,12 +54,12 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
+ "@:<p>Foo</p> " + Environment.NewLine
|
||||
+ ")",
|
||||
new ExpressionBlock(
|
||||
Factory.Code("Foo( \r\n").AsImplicitExpression(CSharpCodeParser.DefaultKeywords),
|
||||
Factory.Code("Foo( " + Environment.NewLine).AsImplicitExpression(CSharpCodeParser.DefaultKeywords),
|
||||
new TemplateBlock(
|
||||
new MarkupBlock(
|
||||
Factory.MarkupTransition(),
|
||||
Factory.MetaMarkup(":", HtmlSymbolType.Colon),
|
||||
Factory.Markup("<p>Foo</p> \r\n")
|
||||
Factory.Markup("<p>Foo</p> " + Environment.NewLine)
|
||||
.With(new SingleLineMarkupEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString, AcceptedCharacters.None))
|
||||
)
|
||||
),
|
||||
|
|
@ -77,7 +77,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
+ "}",
|
||||
new StatementBlock(
|
||||
Factory.MetaCode("{").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n ").AsStatement(),
|
||||
Factory.Code(Environment.NewLine + " ").AsStatement(),
|
||||
new MarkupBlock(
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("<p>").Accepts(AcceptedCharacters.None)),
|
||||
|
|
@ -85,7 +85,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
new MarkupTagBlock(
|
||||
Factory.Markup("</p>").Accepts(AcceptedCharacters.None))
|
||||
),
|
||||
Factory.Code(" \r\n").AsStatement(),
|
||||
Factory.Code(" " + Environment.NewLine).AsStatement(),
|
||||
Factory.MetaCode("}").Accepts(AcceptedCharacters.None)
|
||||
), designTimeParser: true);
|
||||
}
|
||||
|
|
@ -98,7 +98,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
+ "}",
|
||||
new StatementBlock(
|
||||
Factory.MetaCode("{").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n ").AsStatement(),
|
||||
Factory.Code(Environment.NewLine + " ").AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.MarkupTransition(),
|
||||
new MarkupTagBlock(
|
||||
|
|
@ -107,10 +107,11 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
new MarkupTagBlock(
|
||||
Factory.Markup("</p>").Accepts(AcceptedCharacters.None))
|
||||
),
|
||||
Factory.Code(" \r\n").AsStatement(),
|
||||
Factory.Code(" " + Environment.NewLine).AsStatement(),
|
||||
Factory.MetaCode("}").Accepts(AcceptedCharacters.None)
|
||||
), true,
|
||||
new RazorError(RazorResources.ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start, 7, 1, 4));
|
||||
new RazorError(
|
||||
RazorResources.ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start, 5 + Environment.NewLine.Length, 1, 4));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -121,11 +122,11 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
+ "}",
|
||||
new StatementBlock(
|
||||
Factory.MetaCode("{").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n ").AsStatement(),
|
||||
Factory.Code(Environment.NewLine + " ").AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.MarkupTransition(),
|
||||
Factory.MetaMarkup(":", HtmlSymbolType.Colon),
|
||||
Factory.Markup("<p>Foo</p> \r\n")
|
||||
Factory.Markup("<p>Foo</p> " + Environment.NewLine)
|
||||
.With(new SingleLineMarkupEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString, AcceptedCharacters.None))
|
||||
),
|
||||
Factory.EmptyCSharp().AsStatement(),
|
||||
|
|
@ -140,7 +141,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
+ " @: @{}" + Environment.NewLine
|
||||
+ ")",
|
||||
new ExpressionBlock(
|
||||
Factory.Code("Repeat(10,\r\n ")
|
||||
Factory.Code($"Repeat(10,{Environment.NewLine} ")
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords),
|
||||
new TemplateBlock(
|
||||
new MarkupBlock(
|
||||
|
|
@ -154,7 +155,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
Factory.EmptyCSharp().AsStatement(),
|
||||
Factory.MetaCode("}").Accepts(AcceptedCharacters.None)
|
||||
),
|
||||
Factory.Markup("\r\n")
|
||||
Factory.Markup(Environment.NewLine)
|
||||
.With(new SingleLineMarkupEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString, AcceptedCharacters.None))
|
||||
)
|
||||
),
|
||||
|
|
@ -176,17 +177,17 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
+ "@:Bar" + Environment.NewLine
|
||||
+ "}",
|
||||
new StatementBlock(
|
||||
Factory.Code("foreach(var file in files){\r\n\r\n\r\n").AsStatement(),
|
||||
Factory.Code(string.Format("foreach(var file in files){{{0}{0}{0}", Environment.NewLine)).AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.MarkupTransition(),
|
||||
Factory.MetaMarkup(":", HtmlSymbolType.Colon),
|
||||
Factory.Markup("Baz\r\n")
|
||||
Factory.Markup("Baz" + Environment.NewLine)
|
||||
.With(new SingleLineMarkupEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString, AcceptedCharacters.None))
|
||||
),
|
||||
new MarkupBlock(
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("<br/>").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup("\r\n").Accepts(AcceptedCharacters.None)
|
||||
Factory.Markup(Environment.NewLine).Accepts(AcceptedCharacters.None)
|
||||
),
|
||||
new MarkupBlock(
|
||||
new MarkupTagBlock(
|
||||
|
|
@ -194,11 +195,11 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
Factory.Markup("Foo"),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("</a>").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup("\r\n").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup(Environment.NewLine).Accepts(AcceptedCharacters.None)),
|
||||
new MarkupBlock(
|
||||
Factory.MarkupTransition(),
|
||||
Factory.MetaMarkup(":", HtmlSymbolType.Colon),
|
||||
Factory.Markup("Bar\r\n")
|
||||
Factory.Markup("Bar" + Environment.NewLine)
|
||||
.With(new SingleLineMarkupEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString, AcceptedCharacters.None))
|
||||
),
|
||||
Factory.Code("}").AsStatement().Accepts(AcceptedCharacters.None)
|
||||
|
|
@ -218,29 +219,31 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
+ " var biz = boz;" + Environment.NewLine
|
||||
+ "}",
|
||||
new StatementBlock(
|
||||
Factory.Code("if(foo) {\r\n var foo = \"After this statement there are 10 spaces\"; \r\n").AsStatement(),
|
||||
Factory.Code(
|
||||
$"if(foo) {{{Environment.NewLine} var foo = \"After this statement there are " +
|
||||
"10 spaces\"; " + Environment.NewLine).AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("<p>").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup("\r\n Foo\r\n"),
|
||||
Factory.Markup($"{Environment.NewLine} Foo{Environment.NewLine}"),
|
||||
new ExpressionBlock(
|
||||
Factory.Code(" ").AsStatement(),
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("bar").AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharacters.NonWhiteSpace)
|
||||
),
|
||||
Factory.Markup("\r\n "),
|
||||
Factory.Markup(Environment.NewLine + " "),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("</p>").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup("\r\n").Accepts(AcceptedCharacters.None)
|
||||
Factory.Markup(Environment.NewLine).Accepts(AcceptedCharacters.None)
|
||||
),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
Factory.MarkupTransition(),
|
||||
Factory.MetaMarkup(":", HtmlSymbolType.Colon),
|
||||
Factory.Markup("Hello!\r\n").With(new SingleLineMarkupEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString, AcceptedCharacters.None))
|
||||
Factory.Markup("Hello!" + Environment.NewLine).With(new SingleLineMarkupEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString, AcceptedCharacters.None))
|
||||
),
|
||||
Factory.Code(" var biz = boz;\r\n}").AsStatement()));
|
||||
Factory.Code($" var biz = boz;{Environment.NewLine}}}").AsStatement()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -343,7 +346,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
+ " <p>Biz</p>" + Environment.NewLine
|
||||
+ "}",
|
||||
new StatementBlock(
|
||||
Factory.Code("switch(foo) {\r\n case 0:\r\n").AsStatement(),
|
||||
Factory.Code($"switch(foo) {{{Environment.NewLine} case 0:{Environment.NewLine}").AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
new MarkupTagBlock(
|
||||
|
|
@ -351,9 +354,9 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
Factory.Markup("Foo"),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("</p>").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup("\r\n").Accepts(AcceptedCharacters.None)
|
||||
Factory.Markup(Environment.NewLine).Accepts(AcceptedCharacters.None)
|
||||
),
|
||||
Factory.Code(" break;\r\n case 1:\r\n").AsStatement(),
|
||||
Factory.Code($" break;{Environment.NewLine} case 1:{Environment.NewLine}").AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
new MarkupTagBlock(
|
||||
|
|
@ -361,9 +364,11 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
Factory.Markup("Bar"),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("</p>").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup("\r\n").Accepts(AcceptedCharacters.None)
|
||||
Factory.Markup(Environment.NewLine).Accepts(AcceptedCharacters.None)
|
||||
),
|
||||
Factory.Code(" return;\r\n case 2:\r\n {\r\n").AsStatement(),
|
||||
Factory.Code(
|
||||
$" return;{Environment.NewLine} case 2:{Environment.NewLine}" +
|
||||
" {" + Environment.NewLine).AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
new MarkupTagBlock(
|
||||
|
|
@ -371,7 +376,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
Factory.Markup("Baz"),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("</p>").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup("\r\n").Accepts(AcceptedCharacters.None)
|
||||
Factory.Markup(Environment.NewLine).Accepts(AcceptedCharacters.None)
|
||||
),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
|
|
@ -380,9 +385,9 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
Factory.Markup("Boz"),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("</p>").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup("\r\n").Accepts(AcceptedCharacters.None)
|
||||
Factory.Markup(Environment.NewLine).Accepts(AcceptedCharacters.None)
|
||||
),
|
||||
Factory.Code(" }\r\n default:\r\n").AsStatement(),
|
||||
Factory.Code($" }}{Environment.NewLine} default:{Environment.NewLine}").AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
new MarkupTagBlock(
|
||||
|
|
@ -390,7 +395,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
Factory.Markup("Biz"),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("</p>").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup("\r\n").Accepts(AcceptedCharacters.None)
|
||||
Factory.Markup(Environment.NewLine).Accepts(AcceptedCharacters.None)
|
||||
),
|
||||
Factory.Code("}").AsStatement().Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
|
@ -416,7 +421,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
+ "} }",
|
||||
new StatementBlock(
|
||||
Factory.MetaCode("{").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code(" switch(foo) {\r\n case 0:\r\n").AsStatement(),
|
||||
Factory.Code($" switch(foo) {{{Environment.NewLine} case 0:{Environment.NewLine}").AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
new MarkupTagBlock(
|
||||
|
|
@ -424,9 +429,9 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
Factory.Markup("Foo"),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("</p>").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup("\r\n").Accepts(AcceptedCharacters.None)
|
||||
Factory.Markup(Environment.NewLine).Accepts(AcceptedCharacters.None)
|
||||
),
|
||||
Factory.Code(" break;\r\n case 1:\r\n").AsStatement(),
|
||||
Factory.Code($" break;{Environment.NewLine} case 1:{Environment.NewLine}").AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
new MarkupTagBlock(
|
||||
|
|
@ -434,9 +439,11 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
Factory.Markup("Bar"),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("</p>").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup("\r\n").Accepts(AcceptedCharacters.None)
|
||||
Factory.Markup(Environment.NewLine).Accepts(AcceptedCharacters.None)
|
||||
),
|
||||
Factory.Code(" return;\r\n case 2:\r\n {\r\n").AsStatement(),
|
||||
Factory.Code(
|
||||
$" return;{Environment.NewLine} case 2:{Environment.NewLine}"+
|
||||
" {" + Environment.NewLine).AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
new MarkupTagBlock(
|
||||
|
|
@ -444,7 +451,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
Factory.Markup("Baz"),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("</p>").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup("\r\n").Accepts(AcceptedCharacters.None)
|
||||
Factory.Markup(Environment.NewLine).Accepts(AcceptedCharacters.None)
|
||||
),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
|
|
@ -453,9 +460,9 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
Factory.Markup("Boz"),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("</p>").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup("\r\n").Accepts(AcceptedCharacters.None)
|
||||
Factory.Markup(Environment.NewLine).Accepts(AcceptedCharacters.None)
|
||||
),
|
||||
Factory.Code(" }\r\n default:\r\n").AsStatement(),
|
||||
Factory.Code($" }}{Environment.NewLine} default:{Environment.NewLine}").AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
new MarkupTagBlock(
|
||||
|
|
@ -463,7 +470,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
Factory.Markup("Biz"),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("</p>").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup("\r\n").Accepts(AcceptedCharacters.None)
|
||||
Factory.Markup(Environment.NewLine).Accepts(AcceptedCharacters.None)
|
||||
),
|
||||
Factory.Code("} ").AsStatement(),
|
||||
Factory.MetaCode("}").Accepts(AcceptedCharacters.None)));
|
||||
|
|
@ -520,7 +527,8 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
Factory.Markup(" "),
|
||||
Factory.MarkupTransition(),
|
||||
Factory.MetaMarkup(":", HtmlSymbolType.Colon),
|
||||
Factory.Markup("Bar\r\n").With(new SingleLineMarkupEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString, AcceptedCharacters.None))
|
||||
Factory.Markup("Bar" + Environment.NewLine)
|
||||
.With(new SingleLineMarkupEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString, AcceptedCharacters.None))
|
||||
),
|
||||
Factory.Code("}").AsStatement()));
|
||||
}
|
||||
|
|
@ -538,7 +546,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
Factory.Markup(" "),
|
||||
Factory.MarkupTransition(),
|
||||
Factory.MetaMarkup(":", HtmlSymbolType.Colon),
|
||||
Factory.Markup("Bar\r\n").Accepts(AcceptedCharacters.None)
|
||||
Factory.Markup("Bar" + Environment.NewLine).Accepts(AcceptedCharacters.None)
|
||||
),
|
||||
Factory.Code("} ").AsStatement(),
|
||||
Factory.MetaCode("}").Accepts(AcceptedCharacters.None)));
|
||||
|
|
@ -598,14 +606,15 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
+ "}",
|
||||
new StatementBlock(
|
||||
Factory.MetaCode("{").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n if(true) {\r\n").AsStatement(),
|
||||
Factory.Code($"{Environment.NewLine} if(true) {{{Environment.NewLine}").AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
Factory.MarkupTransition(),
|
||||
Factory.MetaMarkup(":", HtmlSymbolType.Colon),
|
||||
Factory.Markup("Single Line Markup\r\n").With(new SingleLineMarkupEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString, AcceptedCharacters.None))
|
||||
Factory.Markup("Single Line Markup" + Environment.NewLine)
|
||||
.With(new SingleLineMarkupEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString, AcceptedCharacters.None))
|
||||
),
|
||||
Factory.Code(" }\r\n foreach (var p in Enumerable.Range(1, 10)) {\r\n").AsStatement(),
|
||||
Factory.Code($" }}{Environment.NewLine} foreach (var p in Enumerable.Range(1, 10)) {{{Environment.NewLine}").AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
new MarkupTagBlock(
|
||||
|
|
@ -617,9 +626,9 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
),
|
||||
new MarkupTagBlock(
|
||||
Factory.MarkupTransition("</text>").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup("\r\n").Accepts(AcceptedCharacters.None)
|
||||
Factory.Markup(Environment.NewLine).Accepts(AcceptedCharacters.None)
|
||||
),
|
||||
Factory.Code(" }\r\n if(!false) {\r\n").AsStatement(),
|
||||
Factory.Code($" }}{Environment.NewLine} if(!false) {{{Environment.NewLine}").AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
new MarkupTagBlock(
|
||||
|
|
@ -627,9 +636,9 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
Factory.Markup("A real tag!"),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("</p>").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup("\r\n").Accepts(AcceptedCharacters.None)
|
||||
Factory.Markup(Environment.NewLine).Accepts(AcceptedCharacters.None)
|
||||
),
|
||||
Factory.Code(" }\r\n").AsStatement(),
|
||||
Factory.Code(" }" + Environment.NewLine).AsStatement(),
|
||||
Factory.MetaCode("}").Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,15 +76,16 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
+ "}",
|
||||
new StatementBlock(
|
||||
Factory.MetaCode("{").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n ").AsStatement(),
|
||||
Factory.Code(Environment.NewLine + " ").AsStatement(),
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.EmptyCSharp().AsImplicitExpression(KeywordSet, acceptTrailingDot: true).Accepts(AcceptedCharacters.NonWhiteSpace)
|
||||
),
|
||||
Factory.Code("\r\n").AsStatement(),
|
||||
Factory.Code(Environment.NewLine).AsStatement(),
|
||||
Factory.MetaCode("}").Accepts(AcceptedCharacters.None)),
|
||||
/* designTimeParser */ true,
|
||||
new RazorError(RazorResources.ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS, 8, 1, 5));
|
||||
new RazorError(
|
||||
RazorResources.ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS, 6 + Environment.NewLine.Length, 1, 5));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -98,7 +99,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("foo.").AsImplicitExpression(KeywordSet, acceptTrailingDot: true).Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
Factory.Code("\r\n").AsStatement(),
|
||||
Factory.Code(Environment.NewLine).AsStatement(),
|
||||
Factory.MetaCode("}").Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
|
|
@ -113,7 +114,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("foo.").AsImplicitExpression(KeywordSet, acceptTrailingDot: true).Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
Factory.Code("\r\n").AsStatement(),
|
||||
Factory.Code(Environment.NewLine).AsStatement(),
|
||||
Factory.MetaCode("}").Accepts(AcceptedCharacters.None)),
|
||||
designTimeParser: true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
Factory.Code("if (true) { }")
|
||||
.AsStatement()
|
||||
),
|
||||
Factory.Markup("\r\n")
|
||||
Factory.Markup(Environment.NewLine)
|
||||
.Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("{").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n").AsStatement(),
|
||||
Factory.Code(Environment.NewLine).AsStatement(),
|
||||
new MarkupBlock(
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("<"))))),
|
||||
|
|
@ -56,10 +56,10 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("{").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n").AsStatement(),
|
||||
Factory.Code(Environment.NewLine).AsStatement(),
|
||||
new MarkupBlock(
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("<\r\n"))
|
||||
Factory.Markup("<" + Environment.NewLine))
|
||||
),
|
||||
new MarkupBlock(
|
||||
new MarkupTagBlock(
|
||||
|
|
@ -71,7 +71,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
designTimeParser: true,
|
||||
expectedErrors: new[]
|
||||
{
|
||||
new RazorError(RazorResources.FormatParseError_UnexpectedEndTag("html"), 7, 2, 0),
|
||||
new RazorError(RazorResources.FormatParseError_UnexpectedEndTag("html"), 3 + Environment.NewLine.Length * 2, 2, 0),
|
||||
new RazorError(RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF("code", "}", "{"), 1, 0, 1)
|
||||
});
|
||||
}
|
||||
|
|
@ -83,7 +83,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
+ " ",
|
||||
new MarkupBlock(
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("< \r\n "))),
|
||||
Factory.Markup($"< {Environment.NewLine} "))),
|
||||
designTimeParser: true,
|
||||
expectedErrors: new RazorError(RazorResources.FormatParseError_UnfinishedTag(string.Empty), 0, 0, 0));
|
||||
}
|
||||
|
|
@ -113,7 +113,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
new MarkupBlock(
|
||||
Factory.MarkupTransition(),
|
||||
Factory.MetaMarkup(":", HtmlSymbolType.Colon),
|
||||
Factory.Markup("<li>Foo Bar Baz\r\n")
|
||||
Factory.Markup("<li>Foo Bar Baz" + Environment.NewLine)
|
||||
.With(new SingleLineMarkupEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString, AcceptedCharacters.None))
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,10 +103,10 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
Factory.MetaCode("section Foo {")
|
||||
.AutoCompleteWith(null, atEndOfSpan: true),
|
||||
new MarkupBlock(
|
||||
Factory.Markup("\r\n "),
|
||||
Factory.Markup(Environment.NewLine + " "),
|
||||
BlockFactory.MarkupTagBlock("<html>"),
|
||||
BlockFactory.MarkupTagBlock("</html>"),
|
||||
Factory.Markup("\r\n")),
|
||||
Factory.Markup(Environment.NewLine)),
|
||||
Factory.MetaCode("}").Accepts(AcceptedCharacters.None)),
|
||||
Factory.EmptyHtml()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
Factory.Code("Bar")
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
Factory.Markup(" Baz\r\n")
|
||||
Factory.Markup(" Baz" + Environment.NewLine)
|
||||
.With(new SingleLineMarkupEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString, AcceptedCharacters.None))));
|
||||
}
|
||||
|
||||
|
|
@ -224,11 +224,11 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
Factory.Markup(" "),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("<ul>").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup("\r\n"),
|
||||
Factory.Markup(Environment.NewLine),
|
||||
new StatementBlock(
|
||||
Factory.Code(" ").AsStatement(),
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("foreach(var p in Products) {\r\n").AsStatement(),
|
||||
Factory.Code("foreach(var p in Products) {" + Environment.NewLine).AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
new MarkupTagBlock(
|
||||
|
|
@ -241,8 +241,8 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("</li>").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup("\r\n").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Code(" }\r\n").AsStatement().Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup(Environment.NewLine).Accepts(AcceptedCharacters.None)),
|
||||
Factory.Code(" }" + Environment.NewLine).AsStatement().Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup(" "),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("</ul>").Accepts(AcceptedCharacters.None))));
|
||||
|
|
@ -260,11 +260,11 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
Factory.Markup(" "),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("<ul>")),
|
||||
Factory.Markup("\r\n"),
|
||||
Factory.Markup(Environment.NewLine),
|
||||
new StatementBlock(
|
||||
Factory.Code(" ").AsStatement(),
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("foreach(var p in Products) {\r\n").AsStatement(),
|
||||
Factory.Code("foreach(var p in Products) {" + Environment.NewLine).AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
new MarkupTagBlock(
|
||||
|
|
@ -277,8 +277,8 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("</li>").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup("\r\n").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Code(" }\r\n").AsStatement().Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup(Environment.NewLine).Accepts(AcceptedCharacters.None)),
|
||||
Factory.Code(" }" + Environment.NewLine).AsStatement().Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup(" "),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("</ul>"))));
|
||||
|
|
@ -300,14 +300,14 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("section foo {").AutoCompleteWith(null, atEndOfSpan: true),
|
||||
new MarkupBlock(
|
||||
Factory.Markup("\r\n "),
|
||||
Factory.Markup(Environment.NewLine + " "),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("<ul>")),
|
||||
Factory.Markup("\r\n"),
|
||||
Factory.Markup(Environment.NewLine),
|
||||
new StatementBlock(
|
||||
Factory.Code(" ").AsStatement(),
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("foreach(var p in Products) {\r\n").AsStatement(),
|
||||
Factory.Code("foreach(var p in Products) {" + Environment.NewLine).AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
new MarkupTagBlock(
|
||||
|
|
@ -320,12 +320,12 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("</li>").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup("\r\n").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Code(" }\r\n").AsStatement().Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup(Environment.NewLine).Accepts(AcceptedCharacters.None)),
|
||||
Factory.Code(" }" + Environment.NewLine).AsStatement().Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup(" "),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("</ul>")),
|
||||
Factory.Markup("\r\n")),
|
||||
Factory.Markup(Environment.NewLine)),
|
||||
Factory.MetaCode("}").Accepts(AcceptedCharacters.None)),
|
||||
Factory.EmptyHtml()));
|
||||
}
|
||||
|
|
@ -342,10 +342,10 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
Factory.Markup(" "),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("<ul>").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup("\r\n "),
|
||||
Factory.Markup(Environment.NewLine + " "),
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("foreach(var p in Products) {\r\n ").AsStatement(),
|
||||
Factory.Code($"foreach(var p in Products) {{{Environment.NewLine} ").AsStatement(),
|
||||
new MarkupBlock(
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("<li>").Accepts(AcceptedCharacters.None)),
|
||||
|
|
@ -355,8 +355,8 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
Factory.Code("p.Name").AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("</li>").Accepts(AcceptedCharacters.None))),
|
||||
Factory.Code("\r\n }").AsStatement().Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup("\r\n "),
|
||||
Factory.Code(Environment.NewLine + " }").AsStatement().Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup(Environment.NewLine + " "),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("</ul>").Accepts(AcceptedCharacters.None))),
|
||||
designTimeParser: true);
|
||||
|
|
|
|||
|
|
@ -50,13 +50,13 @@ namespace Microsoft.AspNet.Razor.Test.Parser.PartialParsing
|
|||
new StatementBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.MetaCode("{").Accepts(AcceptedCharacters.None),
|
||||
factory.Code("\r\n ").AsStatement(),
|
||||
factory.Code(Environment.NewLine + " ").AsStatement(),
|
||||
new ExpressionBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code("DateTime..Now")
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords, acceptTrailingDot: true)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
factory.Code("\r\n").AsStatement(),
|
||||
factory.Code(Environment.NewLine).AsStatement(),
|
||||
factory.MetaCode("}").Accepts(AcceptedCharacters.None)),
|
||||
factory.EmptyHtml()));
|
||||
}
|
||||
|
|
@ -91,51 +91,53 @@ namespace Microsoft.AspNet.Razor.Test.Parser.PartialParsing
|
|||
+ " @DateTime" + Environment.NewLine
|
||||
+ "}");
|
||||
|
||||
var textChange = new TextChange(17, 0, old, 1, changed);
|
||||
var manager = CreateParserManager();
|
||||
Action<TextChange, PartialParseResult, string> applyAndVerifyPartialChange = (changeToApply, expectedResult, expectedCode) =>
|
||||
var textChange = new TextChange(15 + Environment.NewLine.Length, 0, old, 1, changed);
|
||||
using (var manager = CreateParserManager())
|
||||
{
|
||||
var result = manager.CheckForStructureChangesAndWait(textChange);
|
||||
Action<TextChange, PartialParseResult, string> applyAndVerifyPartialChange = (changeToApply, expectedResult, expectedCode) =>
|
||||
{
|
||||
var result = manager.CheckForStructureChangesAndWait(textChange);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(expectedResult, result);
|
||||
Assert.Equal(1, manager.ParseCount);
|
||||
ParserTestBase.EvaluateParseTree(manager.Parser.CurrentParseTree, new MarkupBlock(
|
||||
factory.EmptyHtml(),
|
||||
new StatementBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.MetaCode("{").Accepts(AcceptedCharacters.None),
|
||||
factory.Code("\r\n ").AsStatement(),
|
||||
new ExpressionBlock(
|
||||
// Assert
|
||||
Assert.Equal(expectedResult, result);
|
||||
Assert.Equal(1, manager.ParseCount);
|
||||
ParserTestBase.EvaluateParseTree(manager.Parser.CurrentParseTree, new MarkupBlock(
|
||||
factory.EmptyHtml(),
|
||||
new StatementBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code(expectedCode)
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords, acceptTrailingDot: true)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
factory.Code("\r\n").AsStatement(),
|
||||
factory.MetaCode("}").Accepts(AcceptedCharacters.None)),
|
||||
factory.EmptyHtml()));
|
||||
};
|
||||
factory.MetaCode("{").Accepts(AcceptedCharacters.None),
|
||||
factory.Code(Environment.NewLine + " ").AsStatement(),
|
||||
new ExpressionBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code(expectedCode)
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords, acceptTrailingDot: true)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
factory.Code(Environment.NewLine).AsStatement(),
|
||||
factory.MetaCode("}").Accepts(AcceptedCharacters.None)),
|
||||
factory.EmptyHtml()));
|
||||
};
|
||||
|
||||
manager.InitializeWithDocument(textChange.OldBuffer);
|
||||
manager.InitializeWithDocument(textChange.OldBuffer);
|
||||
|
||||
// This is the process of a dotless commit when doing "." insertions to commit intellisense changes.
|
||||
applyAndVerifyPartialChange(textChange, PartialParseResult.Accepted, "DateTime.");
|
||||
// This is the process of a dotless commit when doing "." insertions to commit intellisense changes.
|
||||
applyAndVerifyPartialChange(textChange, PartialParseResult.Accepted, "DateTime.");
|
||||
|
||||
old = changed;
|
||||
changed = new StringTextBuffer("@{" + Environment.NewLine
|
||||
+ " @DateTime.." + Environment.NewLine
|
||||
+ "}");
|
||||
textChange = new TextChange(18, 0, old, 1, changed);
|
||||
old = changed;
|
||||
changed = new StringTextBuffer("@{" + Environment.NewLine
|
||||
+ " @DateTime.." + Environment.NewLine
|
||||
+ "}");
|
||||
textChange = new TextChange(16 + Environment.NewLine.Length, 0, old, 1, changed);
|
||||
|
||||
applyAndVerifyPartialChange(textChange, PartialParseResult.Accepted, "DateTime..");
|
||||
applyAndVerifyPartialChange(textChange, PartialParseResult.Accepted, "DateTime..");
|
||||
|
||||
old = changed;
|
||||
changed = new StringTextBuffer("@{" + Environment.NewLine
|
||||
+ " @DateTime.Now." + Environment.NewLine
|
||||
+ "}");
|
||||
textChange = new TextChange(18, 0, old, 3, changed);
|
||||
old = changed;
|
||||
changed = new StringTextBuffer("@{" + Environment.NewLine
|
||||
+ " @DateTime.Now." + Environment.NewLine
|
||||
+ "}");
|
||||
textChange = new TextChange(16 + Environment.NewLine.Length, 0, old, 3, changed);
|
||||
|
||||
applyAndVerifyPartialChange(textChange, PartialParseResult.Accepted, "DateTime.Now.");
|
||||
applyAndVerifyPartialChange(textChange, PartialParseResult.Accepted, "DateTime.Now.");
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -149,43 +151,45 @@ namespace Microsoft.AspNet.Razor.Test.Parser.PartialParsing
|
|||
+ " @DateT" + Environment.NewLine
|
||||
+ "}");
|
||||
|
||||
var textChange = new TextChange(14, 0, old, 1, changed);
|
||||
var manager = CreateParserManager();
|
||||
Action<TextChange, PartialParseResult, string> applyAndVerifyPartialChange = (changeToApply, expectedResult, expectedCode) =>
|
||||
var textChange = new TextChange(12 + Environment.NewLine.Length, 0, old, 1, changed);
|
||||
using (var manager = CreateParserManager())
|
||||
{
|
||||
var result = manager.CheckForStructureChangesAndWait(textChange);
|
||||
Action<TextChange, PartialParseResult, string> applyAndVerifyPartialChange = (changeToApply, expectedResult, expectedCode) =>
|
||||
{
|
||||
var result = manager.CheckForStructureChangesAndWait(textChange);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(expectedResult, result);
|
||||
Assert.Equal(1, manager.ParseCount);
|
||||
ParserTestBase.EvaluateParseTree(manager.Parser.CurrentParseTree, new MarkupBlock(
|
||||
factory.EmptyHtml(),
|
||||
new StatementBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.MetaCode("{").Accepts(AcceptedCharacters.None),
|
||||
factory.Code("\r\n ").AsStatement(),
|
||||
new ExpressionBlock(
|
||||
// Assert
|
||||
Assert.Equal(expectedResult, result);
|
||||
Assert.Equal(1, manager.ParseCount);
|
||||
ParserTestBase.EvaluateParseTree(manager.Parser.CurrentParseTree, new MarkupBlock(
|
||||
factory.EmptyHtml(),
|
||||
new StatementBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code(expectedCode)
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords, acceptTrailingDot: true)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
factory.Code("\r\n").AsStatement(),
|
||||
factory.MetaCode("}").Accepts(AcceptedCharacters.None)),
|
||||
factory.EmptyHtml()));
|
||||
};
|
||||
factory.MetaCode("{").Accepts(AcceptedCharacters.None),
|
||||
factory.Code(Environment.NewLine + " ").AsStatement(),
|
||||
new ExpressionBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code(expectedCode)
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords, acceptTrailingDot: true)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
factory.Code(Environment.NewLine).AsStatement(),
|
||||
factory.MetaCode("}").Accepts(AcceptedCharacters.None)),
|
||||
factory.EmptyHtml()));
|
||||
};
|
||||
|
||||
manager.InitializeWithDocument(textChange.OldBuffer);
|
||||
manager.InitializeWithDocument(textChange.OldBuffer);
|
||||
|
||||
// This is the process of a dotless commit when doing "." insertions to commit intellisense changes.
|
||||
applyAndVerifyPartialChange(textChange, PartialParseResult.Accepted, "DateT.");
|
||||
// This is the process of a dotless commit when doing "." insertions to commit intellisense changes.
|
||||
applyAndVerifyPartialChange(textChange, PartialParseResult.Accepted, "DateT.");
|
||||
|
||||
old = changed;
|
||||
changed = new StringTextBuffer("@{" + Environment.NewLine
|
||||
+ " @DateTime." + Environment.NewLine
|
||||
+ "}");
|
||||
textChange = new TextChange(14, 0, old, 3, changed);
|
||||
old = changed;
|
||||
changed = new StringTextBuffer("@{" + Environment.NewLine
|
||||
+ " @DateTime." + Environment.NewLine
|
||||
+ "}");
|
||||
textChange = new TextChange(12 + Environment.NewLine.Length, 0, old, 3, changed);
|
||||
|
||||
applyAndVerifyPartialChange(textChange, PartialParseResult.Accepted, "DateTime.");
|
||||
applyAndVerifyPartialChange(textChange, PartialParseResult.Accepted, "DateTime.");
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -195,33 +199,35 @@ namespace Microsoft.AspNet.Razor.Test.Parser.PartialParsing
|
|||
var changed = new StringTextBuffer("foo @DateT. baz");
|
||||
var old = new StringTextBuffer("foo @DateT baz");
|
||||
var textChange = new TextChange(10, 0, old, 1, changed);
|
||||
var manager = CreateParserManager();
|
||||
Action<TextChange, PartialParseResult, string> applyAndVerifyPartialChange = (changeToApply, expectedResult, expectedCode) =>
|
||||
using (var manager = CreateParserManager())
|
||||
{
|
||||
var result = manager.CheckForStructureChangesAndWait(textChange);
|
||||
Action<TextChange, PartialParseResult, string> applyAndVerifyPartialChange = (changeToApply, expectedResult, expectedCode) =>
|
||||
{
|
||||
var result = manager.CheckForStructureChangesAndWait(textChange);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(expectedResult, result);
|
||||
Assert.Equal(1, manager.ParseCount);
|
||||
// Assert
|
||||
Assert.Equal(expectedResult, result);
|
||||
Assert.Equal(1, manager.ParseCount);
|
||||
|
||||
ParserTestBase.EvaluateParseTree(manager.Parser.CurrentParseTree, new MarkupBlock(
|
||||
factory.Markup("foo "),
|
||||
new ExpressionBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code(expectedCode).AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
factory.Markup(" baz")));
|
||||
};
|
||||
ParserTestBase.EvaluateParseTree(manager.Parser.CurrentParseTree, new MarkupBlock(
|
||||
factory.Markup("foo "),
|
||||
new ExpressionBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code(expectedCode).AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
factory.Markup(" baz")));
|
||||
};
|
||||
|
||||
manager.InitializeWithDocument(textChange.OldBuffer);
|
||||
manager.InitializeWithDocument(textChange.OldBuffer);
|
||||
|
||||
// This is the process of a dotless commit when doing "." insertions to commit intellisense changes.
|
||||
applyAndVerifyPartialChange(textChange, PartialParseResult.Accepted | PartialParseResult.Provisional, "DateT.");
|
||||
// This is the process of a dotless commit when doing "." insertions to commit intellisense changes.
|
||||
applyAndVerifyPartialChange(textChange, PartialParseResult.Accepted | PartialParseResult.Provisional, "DateT.");
|
||||
|
||||
old = changed;
|
||||
changed = new StringTextBuffer("foo @DateTime. baz");
|
||||
textChange = new TextChange(10, 0, old, 3, changed);
|
||||
old = changed;
|
||||
changed = new StringTextBuffer("foo @DateTime. baz");
|
||||
textChange = new TextChange(10, 0, old, 3, changed);
|
||||
|
||||
applyAndVerifyPartialChange(textChange, PartialParseResult.Accepted | PartialParseResult.Provisional, "DateTime.");
|
||||
applyAndVerifyPartialChange(textChange, PartialParseResult.Accepted | PartialParseResult.Provisional, "DateTime.");
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -231,39 +237,41 @@ namespace Microsoft.AspNet.Razor.Test.Parser.PartialParsing
|
|||
var changed = new StringTextBuffer("foo @DateTime. baz");
|
||||
var old = new StringTextBuffer("foo @DateTime baz");
|
||||
var textChange = new TextChange(13, 0, old, 1, changed);
|
||||
var manager = CreateParserManager();
|
||||
Action<TextChange, PartialParseResult, string> applyAndVerifyPartialChange = (changeToApply, expectedResult, expectedCode) =>
|
||||
using (var manager = CreateParserManager())
|
||||
{
|
||||
var result = manager.CheckForStructureChangesAndWait(textChange);
|
||||
Action<TextChange, PartialParseResult, string> applyAndVerifyPartialChange = (changeToApply, expectedResult, expectedCode) =>
|
||||
{
|
||||
var result = manager.CheckForStructureChangesAndWait(textChange);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(expectedResult, result);
|
||||
Assert.Equal(1, manager.ParseCount);
|
||||
// Assert
|
||||
Assert.Equal(expectedResult, result);
|
||||
Assert.Equal(1, manager.ParseCount);
|
||||
|
||||
ParserTestBase.EvaluateParseTree(manager.Parser.CurrentParseTree, new MarkupBlock(
|
||||
factory.Markup("foo "),
|
||||
new ExpressionBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code(expectedCode).AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
factory.Markup(" baz")));
|
||||
};
|
||||
ParserTestBase.EvaluateParseTree(manager.Parser.CurrentParseTree, new MarkupBlock(
|
||||
factory.Markup("foo "),
|
||||
new ExpressionBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code(expectedCode).AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
factory.Markup(" baz")));
|
||||
};
|
||||
|
||||
manager.InitializeWithDocument(textChange.OldBuffer);
|
||||
manager.InitializeWithDocument(textChange.OldBuffer);
|
||||
|
||||
// This is the process of a dotless commit when doing "." insertions to commit intellisense changes.
|
||||
applyAndVerifyPartialChange(textChange, PartialParseResult.Accepted | PartialParseResult.Provisional, "DateTime.");
|
||||
// This is the process of a dotless commit when doing "." insertions to commit intellisense changes.
|
||||
applyAndVerifyPartialChange(textChange, PartialParseResult.Accepted | PartialParseResult.Provisional, "DateTime.");
|
||||
|
||||
old = changed;
|
||||
changed = new StringTextBuffer("foo @DateTime.. baz");
|
||||
textChange = new TextChange(14, 0, old, 1, changed);
|
||||
old = changed;
|
||||
changed = new StringTextBuffer("foo @DateTime.. baz");
|
||||
textChange = new TextChange(14, 0, old, 1, changed);
|
||||
|
||||
applyAndVerifyPartialChange(textChange, PartialParseResult.Accepted | PartialParseResult.Provisional, "DateTime..");
|
||||
applyAndVerifyPartialChange(textChange, PartialParseResult.Accepted | PartialParseResult.Provisional, "DateTime..");
|
||||
|
||||
old = changed;
|
||||
changed = new StringTextBuffer("foo @DateTime.Now. baz");
|
||||
textChange = new TextChange(14, 0, old, 3, changed);
|
||||
old = changed;
|
||||
changed = new StringTextBuffer("foo @DateTime.Now. baz");
|
||||
textChange = new TextChange(14, 0, old, 3, changed);
|
||||
|
||||
applyAndVerifyPartialChange(textChange, PartialParseResult.Accepted | PartialParseResult.Provisional, "DateTime.Now.");
|
||||
applyAndVerifyPartialChange(textChange, PartialParseResult.Accepted | PartialParseResult.Provisional, "DateTime.Now.");
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -338,19 +346,19 @@ namespace Microsoft.AspNet.Razor.Test.Parser.PartialParsing
|
|||
var old = new StringTextBuffer("@{" + Environment.NewLine
|
||||
+ " @foo" + Environment.NewLine
|
||||
+ "}");
|
||||
RunPartialParseTest(new TextChange(12, 0, old, 1, changed),
|
||||
RunPartialParseTest(new TextChange(10 + Environment.NewLine.Length, 0, old, 1, changed),
|
||||
new MarkupBlock(
|
||||
factory.EmptyHtml(),
|
||||
new StatementBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.MetaCode("{").Accepts(AcceptedCharacters.None),
|
||||
factory.Code("\r\n ").AsStatement(),
|
||||
factory.Code(Environment.NewLine + " ").AsStatement(),
|
||||
new ExpressionBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code("food")
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords, acceptTrailingDot: true)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
factory.Code("\r\n").AsStatement(),
|
||||
factory.Code(Environment.NewLine).AsStatement(),
|
||||
factory.MetaCode("}").Accepts(AcceptedCharacters.None)),
|
||||
factory.EmptyHtml()));
|
||||
}
|
||||
|
|
@ -365,19 +373,19 @@ namespace Microsoft.AspNet.Razor.Test.Parser.PartialParsing
|
|||
var old = new StringTextBuffer("@{" + Environment.NewLine
|
||||
+ " @foo." + Environment.NewLine
|
||||
+ "}");
|
||||
RunPartialParseTest(new TextChange(13, 0, old, 1, changed),
|
||||
RunPartialParseTest(new TextChange(11 + Environment.NewLine.Length, 0, old, 1, changed),
|
||||
new MarkupBlock(
|
||||
factory.EmptyHtml(),
|
||||
new StatementBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.MetaCode("{").Accepts(AcceptedCharacters.None),
|
||||
factory.Code("\r\n ").AsStatement(),
|
||||
factory.Code(Environment.NewLine + " ").AsStatement(),
|
||||
new ExpressionBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code("foo.d")
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords, acceptTrailingDot: true)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
factory.Code("\r\n").AsStatement(),
|
||||
factory.Code(Environment.NewLine).AsStatement(),
|
||||
factory.MetaCode("}").Accepts(AcceptedCharacters.None)),
|
||||
factory.EmptyHtml()));
|
||||
}
|
||||
|
|
@ -392,19 +400,19 @@ namespace Microsoft.AspNet.Razor.Test.Parser.PartialParsing
|
|||
var old = new StringTextBuffer("@{" + Environment.NewLine
|
||||
+ " @foo" + Environment.NewLine
|
||||
+ "}");
|
||||
RunPartialParseTest(new TextChange(12, 0, old, 1, changed),
|
||||
RunPartialParseTest(new TextChange(10 + Environment.NewLine.Length, 0, old, 1, changed),
|
||||
new MarkupBlock(
|
||||
factory.EmptyHtml(),
|
||||
new StatementBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.MetaCode("{").Accepts(AcceptedCharacters.None),
|
||||
factory.Code("\r\n ").AsStatement(),
|
||||
factory.Code(Environment.NewLine + " ").AsStatement(),
|
||||
new ExpressionBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code(@"foo.")
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords, acceptTrailingDot: true)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
factory.Code("\r\n").AsStatement(),
|
||||
factory.Code(Environment.NewLine).AsStatement(),
|
||||
factory.MetaCode("}").Accepts(AcceptedCharacters.None)),
|
||||
factory.EmptyHtml()));
|
||||
}
|
||||
|
|
@ -417,33 +425,35 @@ namespace Microsoft.AspNet.Razor.Test.Parser.PartialParsing
|
|||
// Arrange
|
||||
var dotTyped = new TextChange(8, 0, new StringTextBuffer("foo @foo @bar"), 1, new StringTextBuffer("foo @foo. @bar"));
|
||||
var charTyped = new TextChange(14, 0, new StringTextBuffer("foo @foo. @bar"), 1, new StringTextBuffer("foo @foo. @barb"));
|
||||
var manager = CreateParserManager();
|
||||
manager.InitializeWithDocument(dotTyped.OldBuffer);
|
||||
using (var manager = CreateParserManager())
|
||||
{
|
||||
manager.InitializeWithDocument(dotTyped.OldBuffer);
|
||||
|
||||
// Apply the dot change
|
||||
Assert.Equal(PartialParseResult.Provisional | PartialParseResult.Accepted, manager.CheckForStructureChangesAndWait(dotTyped));
|
||||
// Apply the dot change
|
||||
Assert.Equal(PartialParseResult.Provisional | PartialParseResult.Accepted, manager.CheckForStructureChangesAndWait(dotTyped));
|
||||
|
||||
// Act (apply the identifier start char change)
|
||||
var result = manager.CheckForStructureChangesAndWait(charTyped);
|
||||
// Act (apply the identifier start char change)
|
||||
var result = manager.CheckForStructureChangesAndWait(charTyped);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(PartialParseResult.Rejected, result);
|
||||
Assert.False(manager.Parser.LastResultProvisional, "LastResultProvisional flag should have been cleared but it was not");
|
||||
ParserTestBase.EvaluateParseTree(manager.Parser.CurrentParseTree,
|
||||
new MarkupBlock(
|
||||
factory.Markup("foo "),
|
||||
new ExpressionBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code("foo")
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
factory.Markup(". "),
|
||||
new ExpressionBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code("barb")
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
factory.EmptyHtml()));
|
||||
// Assert
|
||||
Assert.Equal(PartialParseResult.Rejected, result);
|
||||
Assert.False(manager.Parser.LastResultProvisional, "LastResultProvisional flag should have been cleared but it was not");
|
||||
ParserTestBase.EvaluateParseTree(manager.Parser.CurrentParseTree,
|
||||
new MarkupBlock(
|
||||
factory.Markup("foo "),
|
||||
new ExpressionBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code("foo")
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
factory.Markup(". "),
|
||||
new ExpressionBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code("barb")
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
factory.EmptyHtml()));
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -454,27 +464,29 @@ namespace Microsoft.AspNet.Razor.Test.Parser.PartialParsing
|
|||
// Arrange
|
||||
var dotTyped = new TextChange(8, 0, new StringTextBuffer("foo @foo bar"), 1, new StringTextBuffer("foo @foo. bar"));
|
||||
var charTyped = new TextChange(9, 0, new StringTextBuffer("foo @foo. bar"), 1, new StringTextBuffer("foo @foo.b bar"));
|
||||
var manager = CreateParserManager();
|
||||
manager.InitializeWithDocument(dotTyped.OldBuffer);
|
||||
using (var manager = CreateParserManager())
|
||||
{
|
||||
manager.InitializeWithDocument(dotTyped.OldBuffer);
|
||||
|
||||
// Apply the dot change
|
||||
Assert.Equal(PartialParseResult.Provisional | PartialParseResult.Accepted, manager.CheckForStructureChangesAndWait(dotTyped));
|
||||
// Apply the dot change
|
||||
Assert.Equal(PartialParseResult.Provisional | PartialParseResult.Accepted, manager.CheckForStructureChangesAndWait(dotTyped));
|
||||
|
||||
// Act (apply the identifier start char change)
|
||||
var result = manager.CheckForStructureChangesAndWait(charTyped);
|
||||
// Act (apply the identifier start char change)
|
||||
var result = manager.CheckForStructureChangesAndWait(charTyped);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(PartialParseResult.Accepted, result);
|
||||
Assert.False(manager.Parser.LastResultProvisional, "LastResultProvisional flag should have been cleared but it was not");
|
||||
ParserTestBase.EvaluateParseTree(manager.Parser.CurrentParseTree,
|
||||
new MarkupBlock(
|
||||
factory.Markup("foo "),
|
||||
new ExpressionBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code("foo.b")
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
factory.Markup(" bar")));
|
||||
// Assert
|
||||
Assert.Equal(PartialParseResult.Accepted, result);
|
||||
Assert.False(manager.Parser.LastResultProvisional, "LastResultProvisional flag should have been cleared but it was not");
|
||||
ParserTestBase.EvaluateParseTree(manager.Parser.CurrentParseTree,
|
||||
new MarkupBlock(
|
||||
factory.Markup("foo "),
|
||||
new ExpressionBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code("foo.b")
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
factory.Markup(" bar")));
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -21,30 +21,34 @@ namespace Microsoft.AspNet.Razor.Test.Parser.PartialParsing
|
|||
protected static void RunFullReparseTest(TextChange change, PartialParseResult additionalFlags = (PartialParseResult)0)
|
||||
{
|
||||
// Arrange
|
||||
var manager = CreateParserManager();
|
||||
manager.InitializeWithDocument(change.OldBuffer);
|
||||
using (var manager = CreateParserManager())
|
||||
{
|
||||
manager.InitializeWithDocument(change.OldBuffer);
|
||||
|
||||
// Act
|
||||
var result = manager.CheckForStructureChangesAndWait(change);
|
||||
// Act
|
||||
var result = manager.CheckForStructureChangesAndWait(change);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(PartialParseResult.Rejected | additionalFlags, result);
|
||||
Assert.Equal(2, manager.ParseCount);
|
||||
// Assert
|
||||
Assert.Equal(PartialParseResult.Rejected | additionalFlags, result);
|
||||
Assert.Equal(2, manager.ParseCount);
|
||||
}
|
||||
}
|
||||
|
||||
protected static void RunPartialParseTest(TextChange change, Block newTreeRoot, PartialParseResult additionalFlags = (PartialParseResult)0)
|
||||
{
|
||||
// Arrange
|
||||
var manager = CreateParserManager();
|
||||
manager.InitializeWithDocument(change.OldBuffer);
|
||||
using (var manager = CreateParserManager())
|
||||
{
|
||||
manager.InitializeWithDocument(change.OldBuffer);
|
||||
|
||||
// Act
|
||||
var result = manager.CheckForStructureChangesAndWait(change);
|
||||
// Act
|
||||
var result = manager.CheckForStructureChangesAndWait(change);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(PartialParseResult.Accepted | additionalFlags, result);
|
||||
Assert.Equal(1, manager.ParseCount);
|
||||
ParserTestBase.EvaluateParseTree(manager.Parser.CurrentParseTree, newTreeRoot);
|
||||
// Assert
|
||||
Assert.Equal(PartialParseResult.Accepted | additionalFlags, result);
|
||||
Assert.Equal(1, manager.ParseCount);
|
||||
ParserTestBase.EvaluateParseTree(manager.Parser.CurrentParseTree, newTreeRoot);
|
||||
}
|
||||
}
|
||||
|
||||
protected static TestParserManager CreateParserManager()
|
||||
|
|
@ -79,24 +83,26 @@ namespace Microsoft.AspNet.Razor.Test.Parser.PartialParsing
|
|||
RunFullReparseTest(new TextChange(keyword.Length, 0, old, 1, changed), additionalFlags: PartialParseResult.SpanContextChanged);
|
||||
}
|
||||
|
||||
protected class TestParserManager
|
||||
protected class TestParserManager : IDisposable
|
||||
{
|
||||
public RazorEditorParser Parser;
|
||||
public ManualResetEventSlim ParserComplete;
|
||||
public int ParseCount;
|
||||
|
||||
private readonly ManualResetEventSlim _parserComplete;
|
||||
|
||||
public TestParserManager(RazorEditorParser parser)
|
||||
{
|
||||
ParserComplete = new ManualResetEventSlim();
|
||||
_parserComplete = new ManualResetEventSlim();
|
||||
ParseCount = 0;
|
||||
Parser = parser;
|
||||
parser.DocumentParseComplete += (sender, args) =>
|
||||
{
|
||||
Interlocked.Increment(ref ParseCount);
|
||||
ParserComplete.Set();
|
||||
_parserComplete.Set();
|
||||
};
|
||||
}
|
||||
|
||||
public RazorEditorParser Parser { get; }
|
||||
|
||||
public void InitializeWithDocument(ITextBuffer startDocument)
|
||||
{
|
||||
CheckForStructureChangesAndWait(new TextChange(0, 0, new StringTextBuffer(String.Empty), startDocument.Length, startDocument));
|
||||
|
|
@ -114,8 +120,13 @@ namespace Microsoft.AspNet.Razor.Test.Parser.PartialParsing
|
|||
|
||||
public void WaitForParse()
|
||||
{
|
||||
MiscUtils.DoWithTimeoutIfNotDebugging(ParserComplete.Wait); // Wait for the parse to finish
|
||||
ParserComplete.Reset();
|
||||
MiscUtils.DoWithTimeoutIfNotDebugging(_parserComplete.Wait); // Wait for the parse to finish
|
||||
_parserComplete.Reset();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Parser.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "AttributeTargetingTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "e5aa16869aaf5543b30289e98ee5733b08bfe423"
|
||||
#pragma checksum "AttributeTargetingTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "edaa271f830648a99892d01bb55f49e328fa621c"
|
||||
namespace TestOutput
|
||||
{
|
||||
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "Await.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "5a02c3ec89081f6e0a8f4810e127eed40467c358"
|
||||
#pragma checksum "Await.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "00b5e01b7a405dcfde7e4d512ee930daaa1778b5"
|
||||
namespace TestOutput
|
||||
{
|
||||
using System;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "BasicTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "ef59308f8b0456ad2f49a08604e8ba36ca11a4b2"
|
||||
#pragma checksum "BasicTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "90382b3c748e0f948dfb6b452b775ba3024b2fe6"
|
||||
namespace TestOutput
|
||||
{
|
||||
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "BasicTagHelpers.Prefixed.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "27630097585fd58e68cb0ac5b772154eff02a52a"
|
||||
#pragma checksum "BasicTagHelpers.Prefixed.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "da1aeb71c15bd7443662536f58df99382b0a47f2"
|
||||
namespace TestOutput
|
||||
{
|
||||
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "BasicTagHelpers.RemoveTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "48dc91408dc7bf6406139461afa4867d176adaf7"
|
||||
#pragma checksum "BasicTagHelpers.RemoveTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "833fbb5056a48116b0fe6386da7b14bc18d3b330"
|
||||
namespace TestOutput
|
||||
{
|
||||
using System;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "BasicTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "ef59308f8b0456ad2f49a08604e8ba36ca11a4b2"
|
||||
#pragma checksum "BasicTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "90382b3c748e0f948dfb6b452b775ba3024b2fe6"
|
||||
namespace TestOutput
|
||||
{
|
||||
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "Blocks.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "ed55fda2b7b0b96b044fc45da658dc062479924f"
|
||||
#pragma checksum "Blocks.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "ba7d8f5f5159a2389c780aa606885ef6c917a45a"
|
||||
namespace TestOutput
|
||||
{
|
||||
using System;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "CodeBlock.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "d570564dcb19afbfb9fcd1b8a7e339d22c0d0c97"
|
||||
#pragma checksum "CodeBlock.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "019ce8023d064d08ca88c597b764aea895ec5841"
|
||||
namespace TestOutput
|
||||
{
|
||||
using System;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "ComplexTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "184461ac3cd2d1747e4480d78478e69dbf800e65"
|
||||
#pragma checksum "ComplexTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "e63f87bb14f278343a07e293df68e44e88600352"
|
||||
namespace TestOutput
|
||||
{
|
||||
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "ConditionalAttributes.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "f0a97e23ecfbaaaa77b528650156cb123ebdbe60"
|
||||
#pragma checksum "ConditionalAttributes.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "088be4e50958bcab0f1d1ac04d2c28dcd8049bf5"
|
||||
namespace TestOutput
|
||||
{
|
||||
using System;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "DuplicateTargetTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "9cd2f5a40be40d26a0756bf6a74cee58bd13927f"
|
||||
#pragma checksum "DuplicateTargetTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "77e70e938d77f71e489354b1e7c351c588001690"
|
||||
namespace TestOutput
|
||||
{
|
||||
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "EmptyAttributeTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "20e2b8804c3af56e185a59be9d21ab33fb33774f"
|
||||
#pragma checksum "EmptyAttributeTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "cdf68f4aae781fadf4445e465c23df6d758fcd81"
|
||||
namespace TestOutput
|
||||
{
|
||||
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "EscapedTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "34a293044db8d18ae2c99fc1e4231e9e7ee96137"
|
||||
#pragma checksum "EscapedTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "dcdd88b4f52fa03367f94849021a84a290cb3c1e"
|
||||
namespace TestOutput
|
||||
{
|
||||
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "ExplicitExpression.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "0fa6894c606c7426da1d8cacfbacf8be971c777f"
|
||||
#pragma checksum "ExplicitExpression.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "a897a227b26c531d644bdff988df46d3c8178346"
|
||||
namespace TestOutput
|
||||
{
|
||||
using System;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "ExpressionsInCode.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "3ccb5b16f61b84dd82d7402e4a17870a39d09ca9"
|
||||
#pragma checksum "ExpressionsInCode.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "8c7ae67489dbddec9f2dbef3c2b65def1149e507"
|
||||
namespace TestOutput
|
||||
{
|
||||
using System;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "FunctionsBlock.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "e6a053bfeb65ba3e17885a8ae1523f28a3483258"
|
||||
#pragma checksum "FunctionsBlock.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "94813053694a285515d791c48d703f1131881d0c"
|
||||
namespace TestOutput
|
||||
{
|
||||
using System;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "FunctionsBlock_Tabs.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "93dd195557fe9c2e5a15b75d76608f2cb7082f3f"
|
||||
#pragma checksum "FunctionsBlock_Tabs.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "3e566e32504e461e14de41901beb954faf0a3724"
|
||||
namespace TestOutput
|
||||
{
|
||||
using System;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "HtmlCommentWithQuote_Double.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "520aebbcdbdb163b131356be8f3aef0eb0809c47"
|
||||
#pragma checksum "HtmlCommentWithQuote_Double.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "a07711bc1fd0478b3b8329a68ab2028ef93429df"
|
||||
namespace TestOutput
|
||||
{
|
||||
using System;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "HtmlCommentWithQuote_Single.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "2080c7f4c5de3e5e7f309c11a6be5c5e8d86e75a"
|
||||
#pragma checksum "HtmlCommentWithQuote_Single.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "2d9bb4407e7aac9563aaeac9f0534a48f54e3d44"
|
||||
namespace TestOutput
|
||||
{
|
||||
using System;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "ImplicitExpression.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "68460c577f1cb90794f25535a35a82ff2aa4c193"
|
||||
#pragma checksum "ImplicitExpression.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "77befd9645f3c2d9ab48b935faebf9f731f42abc"
|
||||
namespace TestOutput
|
||||
{
|
||||
using System;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "Imports.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "6e81e2fa106d657a3f2e198f0c687cb19b2f7e9e"
|
||||
#pragma checksum "Imports.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "1b57def0ce2632d0f50d63dbdc5e0e719c202863"
|
||||
namespace TestOutput
|
||||
{
|
||||
#line 1 "Imports.cshtml"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "Inherits.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "b9264c58289dbea68e46a818fd0c4c4d835b3a84"
|
||||
#pragma checksum "Inherits.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "72d6e21c6366f99a17c63abebb46db3470f4d1da"
|
||||
namespace TestOutput
|
||||
{
|
||||
using System;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "InlineBlocks.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "e7fa74a13b1e78fed87942ccd83aa733810e8664"
|
||||
#pragma checksum "InlineBlocks.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "e827e93343a95c7254a19287b095dfba9390d29f"
|
||||
namespace TestOutput
|
||||
{
|
||||
using System;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "Instrumented.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "3d0d9c94b62eeccf0a2a106b257a1ea1e22412a9"
|
||||
#pragma checksum "Instrumented.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "9b521264e3e64710635c0f0490a368845d90da66"
|
||||
namespace TestOutput
|
||||
{
|
||||
using System;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "LayoutDirective.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "936a0ebedd8d855480541640e61dacbb8b0e56c0"
|
||||
#pragma checksum "LayoutDirective.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "018a686988146d5eb7d51f83c22f820e66b276e0"
|
||||
namespace TestOutput
|
||||
{
|
||||
using System;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "MarkupInCodeBlock.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "539d5763b7091d29df375085f623b9086e7f8ad6"
|
||||
#pragma checksum "MarkupInCodeBlock.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "cf059b36d7e93e260c1d5b852f7a59e6c99ae33d"
|
||||
namespace TestOutput
|
||||
{
|
||||
using System;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "NestedCodeBlocks.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "d83923f86f1c84f081916ef7308513ab80a65675"
|
||||
#pragma checksum "NestedCodeBlocks.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "a4eb7397719094ea9da5b7d6674d317314fa26b4"
|
||||
namespace TestOutput
|
||||
{
|
||||
using System;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "c6fa3992fa56644768995c97941d682d90f6d8ec"
|
||||
#pragma checksum "" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "682929a2038f56f4737f1b7aa3c9eaa5488cc001"
|
||||
namespace TestOutput
|
||||
{
|
||||
using System;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "RazorComments.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "051345e2cc0313fea445db2f6cf48fe28b0b4edf"
|
||||
#pragma checksum "RazorComments.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "45c16f152aef80d7de27c7df32dc522af5842197"
|
||||
namespace TestOutput
|
||||
{
|
||||
using System;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "ResolveUrl.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "ef2ca9797f9fbd9788685830524a0daacb2a30e8"
|
||||
#pragma checksum "ResolveUrl.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "ee17a91893cee3c8590202192de89abe32776cc2"
|
||||
namespace TestOutput
|
||||
{
|
||||
using System;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "Sections.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "0bd579cc5b9e6bd12b720003df47899d0a0207cf"
|
||||
#pragma checksum "Sections.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "19b065ba387522fb8b9b4aea4820b3752d898d0a"
|
||||
namespace TestOutput
|
||||
{
|
||||
using System;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "SingleTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "60ad52f4a16ebc0499d729dfd4b79358331907f4"
|
||||
#pragma checksum "SingleTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "070b72826371f13e4d364e6324cf512220ec1c0f"
|
||||
namespace TestOutput
|
||||
{
|
||||
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "TagHelpersInSection.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "f228c34bdcee3e7f64bc3de14469d11a61efb825"
|
||||
#pragma checksum "TagHelpersInSection.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "b6492c68360b85d4993de94eeac547b7fb012a26"
|
||||
namespace TestOutput
|
||||
{
|
||||
using System;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "Templates.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "3a6da4fcc3d9b28618d5703e4925d45491b5a013"
|
||||
#pragma checksum "Templates.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "32d88538b3b0ca3648493b240101d304878756fe"
|
||||
namespace TestOutput
|
||||
{
|
||||
using System;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -189,13 +190,13 @@ namespace Microsoft.AspNet.Razor.Test.Tokenizer
|
|||
[Fact]
|
||||
public void Character_Literal_Terminated_By_CRLF_Even_When_Last_Char_Is_Slash()
|
||||
{
|
||||
TestTokenizer("'foo\\\r\n", new CSharpSymbol(0, 0, 0, "'foo\\", CSharpSymbolType.CharacterLiteral), IgnoreRemaining);
|
||||
TestTokenizer("'foo\\" + Environment.NewLine, new CSharpSymbol(0, 0, 0, "'foo\\", CSharpSymbolType.CharacterLiteral), IgnoreRemaining);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Character_Literal_Terminated_By_CRLF_Even_When_Last_Char_Is_Slash_And_Followed_By_Stuff()
|
||||
{
|
||||
TestTokenizer("'foo\\\r\nflarg", new CSharpSymbol(0, 0, 0, "'foo\\", CSharpSymbolType.CharacterLiteral), IgnoreRemaining);
|
||||
TestTokenizer($"'foo\\{Environment.NewLine}flarg", new CSharpSymbol(0, 0, 0, "'foo\\", CSharpSymbolType.CharacterLiteral), IgnoreRemaining);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -243,13 +244,13 @@ namespace Microsoft.AspNet.Razor.Test.Tokenizer
|
|||
[Fact]
|
||||
public void String_Literal_Terminated_By_CRLF_Even_When_Last_Char_Is_Slash()
|
||||
{
|
||||
TestTokenizer("\"foo\\\r\n", new CSharpSymbol(0, 0, 0, "\"foo\\", CSharpSymbolType.StringLiteral), IgnoreRemaining);
|
||||
TestTokenizer("\"foo\\" + Environment.NewLine, new CSharpSymbol(0, 0, 0, "\"foo\\", CSharpSymbolType.StringLiteral), IgnoreRemaining);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void String_Literal_Terminated_By_CRLF_Even_When_Last_Char_Is_Slash_And_Followed_By_Stuff()
|
||||
{
|
||||
TestTokenizer("\"foo\\\r\nflarg", new CSharpSymbol(0, 0, 0, "\"foo\\", CSharpSymbolType.StringLiteral), IgnoreRemaining);
|
||||
TestTokenizer($"\"foo\\{Environment.NewLine}flarg", new CSharpSymbol(0, 0, 0, "\"foo\\", CSharpSymbolType.StringLiteral), IgnoreRemaining);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ namespace Microsoft.AspNet.Razor.Test.Tokenizer
|
|||
}
|
||||
}
|
||||
}
|
||||
Assert.True(success, "\r\n" + output.ToString());
|
||||
Assert.True(success, Environment.NewLine + output.ToString());
|
||||
WriteTraceLine(output.Replace("{", "{{").Replace("}", "}}").ToString());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue