-
Notifications
You must be signed in to change notification settings - Fork 508
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3607 from bjornhellander/feature/sa1513-linefeed
Update SA1513 codefix to use the existing newline character sequence
- Loading branch information
Showing
4 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/StringExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
namespace StyleCop.Analyzers.Test.Helpers | ||
{ | ||
public static class StringExtensions | ||
{ | ||
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters