* Update gitignore * Move csproj * Update project references * Update solutions * Update build scripts * Tests used to share editorconfig with projects in src * Fix broken tests. * Stop copying around .editorconfig merged root one with linting * csharp_style_expression_bodied -> suggestion * Move StyleCop rulesets to matching directories and update shared build properties * Remove legacy build files, update NuGet.cofig and solution files * Restore myget source * Clean up .gitignore * Update .gitignore * Move new test classes to tests after merge * Gitignore + nuget config * Move new test Co-authored-by: Ronald Barendse <ronald@barend.se>
60 lines
1.7 KiB
C#
60 lines
1.7 KiB
C#
// Copyright (c) Umbraco.
|
|
// See LICENSE for more details.
|
|
|
|
namespace Umbraco.Cms.Tests.Common.TestHelpers
|
|
{
|
|
public static class StringNewLineExtensions
|
|
{
|
|
/// <summary>
|
|
/// Ensures Lf only everywhere.
|
|
/// </summary>
|
|
/// <param name="text">The text to filter.</param>
|
|
/// <returns>The filtered text.</returns>
|
|
public static string Lf(this string text)
|
|
{
|
|
if (string.IsNullOrEmpty(text))
|
|
{
|
|
return text;
|
|
}
|
|
|
|
text = text.Replace("\r", string.Empty); // remove CR
|
|
return text;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ensures CrLf everywhere.
|
|
/// </summary>
|
|
/// <param name="text">The text to filter.</param>
|
|
/// <returns>The filtered text.</returns>
|
|
public static string CrLf(this string text)
|
|
{
|
|
if (string.IsNullOrEmpty(text))
|
|
{
|
|
return text;
|
|
}
|
|
|
|
text = text.Replace("\r", string.Empty); // remove CR
|
|
text = text.Replace("\n", "\r\n"); // add CRLF everywhere
|
|
return text;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Replaces Cr/Lf by a single space.
|
|
/// </summary>
|
|
/// <param name="text">The text to filter.</param>
|
|
/// <returns>The filtered text.</returns>
|
|
public static string NoCrLf(this string text)
|
|
{
|
|
if (string.IsNullOrEmpty(text))
|
|
{
|
|
return text;
|
|
}
|
|
|
|
text = text.Replace("\r\n", " "); // remove CRLF
|
|
text = text.Replace("\r", " "); // remove CR
|
|
text = text.Replace("\n", " "); // remove LF
|
|
return text;
|
|
}
|
|
}
|
|
}
|