From f09fd291a74a1b0221227fea9ff5257d6456b71b Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Thu, 8 Dec 2016 10:45:30 -0800 Subject: [PATCH] Make `HtmlContentIRNode` content newlines platform agnostic. - Prior to this the platform that the newlines were escaped on would be the platform the baselines would pass on. - Updated baselines to reflect new newline escaping. #888 --- .../IntegrationTests/RazorIRNodeWriter.cs | 6 ++++-- .../HtmlWithConditionalAttribute.ir.txt | 4 ++-- .../HtmlWithDataDashAttribute.ir.txt | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/IntegrationTests/RazorIRNodeWriter.cs b/test/Microsoft.AspNetCore.Razor.Evolution.Test/IntegrationTests/RazorIRNodeWriter.cs index 375d582281..a4e2ccf151 100644 --- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/IntegrationTests/RazorIRNodeWriter.cs +++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/IntegrationTests/RazorIRNodeWriter.cs @@ -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 System.Collections.Generic; using System.IO; using Microsoft.AspNetCore.Razor.Evolution.Intermediate; @@ -155,9 +156,10 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests return; } - // We explicitly escape newlines in node content so that the IR can be compared line-by-line. + // We explicitly escape newlines in node content so that the IR can be compared line-by-line. The escaped + // newline cannot be platform specific so we need to drop the windows \r. // Also, escape our separator so we can search for ` - `to find delimiters. - _writer.Write(content.Replace("\r", "\\r").Replace("\n", "\\n").Replace("-", "\\-")); + _writer.Write(content.Replace("\r", string.Empty).Replace("\n", "\\n").Replace(" - ", "\\-")); } } } diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/HtmlAttributeIntegrationTest/HtmlWithConditionalAttribute.ir.txt b/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/HtmlAttributeIntegrationTest/HtmlWithConditionalAttribute.ir.txt index 8ed15041a2..b353920f6b 100644 --- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/HtmlAttributeIntegrationTest/HtmlWithConditionalAttribute.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/HtmlAttributeIntegrationTest/HtmlWithConditionalAttribute.ir.txt @@ -2,9 +2,9 @@ Document - NamespaceDeclaration - - ClassDeclaration - - - - - RazorMethodDeclaration - - - - - - HtmlContent - (0:0,0 [6] ) - \r\n\r\n \n\n \r\n\r\n" + HtmlContent - (38:2,22 [3] ) - />\n\n" diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/HtmlAttributeIntegrationTest/HtmlWithDataDashAttribute.ir.txt b/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/HtmlAttributeIntegrationTest/HtmlWithDataDashAttribute.ir.txt index 6f2258bf2f..2ada8eee97 100644 --- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/HtmlAttributeIntegrationTest/HtmlWithDataDashAttribute.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/HtmlAttributeIntegrationTest/HtmlWithDataDashAttribute.ir.txt @@ -2,7 +2,7 @@ Document - NamespaceDeclaration - - ClassDeclaration - - - - - RazorMethodDeclaration - - - - - - HtmlContent - (0:0,0 [6] ) - \r\n\r\n \r\n\r\n" + HtmlContent - (42:2,26 [1] ) - " />\n\n"