Adjust tokenizer to understand environment based newlines.

This commit is contained in:
N. Taylor Mullen 2015-09-01 01:41:48 -07:00
parent 09bcc67955
commit 43fce8c927
2 changed files with 4 additions and 2 deletions

View File

@ -23,7 +23,7 @@ namespace Microsoft.AspNet.Razor.Parser
public static bool IsNewLine(string value)
{
return (value.Length == 1 && (IsNewLine(value[0]))) ||
(string.Equals(value, "\r\n", StringComparison.Ordinal));
(string.Equals(value, Environment.NewLine, StringComparison.Ordinal));
}
// Returns true if the character is Whitespace and NOT a newline

View File

@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNet.Razor.Parser;
namespace Microsoft.AspNet.Razor.Text
@ -65,7 +66,8 @@ namespace Microsoft.AspNet.Razor.Text
{
_absoluteIndex++;
if (ParserHelpers.IsNewLine(characterRead) && (characterRead != '\r' || nextCharacter != '\n'))
if (Environment.NewLine.Length == 1 && characterRead == Environment.NewLine[0] ||
ParserHelpers.IsNewLine(characterRead) && (characterRead != '\r' || nextCharacter != '\n'))
{
_lineIndex++;
_characterIndex = 0;