/
githubmirror
/
roslyn
Обзор
Документация
Войти
/
githubmirror
/
roslyn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Compilers/Test/Core/FX/StringExtensions.cs
40 строк
1 KB
Jason Malinowski
Clean up our newline-fixing extension methods
03 апр 2026, 00:46
03 апр 2026, 00:46
dc5ac1d
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; namespace Roslyn.Test.Utilities { public static class StringExtensions { public static string NormalizeLineEndings(this string input) { return input.ReplaceLineEndings("\r\n"); } #if !NET6_0_OR_GREATER public static string ReplaceLineEndings(this string input) { return ReplaceLineEndings(input, Environment.NewLine); } public static string ReplaceLineEndings(this string input, string replacementText) { // First normalize to LF var lineFeedInput = input .Replace("\r\n", "\n") .Replace("\r", "\n") .Replace("\f", "\n") .Replace("\x0085", "\n") .Replace("\x2028", "\n") .Replace("\x2029", "\n"); // Then normalize to the replacement text return lineFeedInput.Replace("\n", replacementText); } #endif } }