Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Docstring converter #596

Merged
merged 12 commits into from
Feb 13, 2019
15 changes: 14 additions & 1 deletion src/Core/Impl/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public static bool CharsAreLatin1LetterOrDigitOrUnderscore(this string s, int st
return true;
}

public static int IndexOfOrdinal(this string s, string value, int startIndex = 0, bool ignoreCase = false)
public static int IndexOfOrdinal(this string s, string value, int startIndex = 0, bool ignoreCase = false)
=> s?.IndexOf(value, startIndex, ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal) ?? -1;

public static bool EqualsIgnoreCase(this string s, string other)
Expand Down Expand Up @@ -266,5 +266,18 @@ public static bool TryGetNextNonEmptySpan(this string s, char separator, int sub
span = (start, nextSeparatorIndex == -1 || nextSeparatorIndex >= substringLength ? substringLength - start : nextSeparatorIndex - start);
return true;
}

public static string[] SplitLines(this string s, params string[] lineEndings) {
if (lineEndings == null || lineEndings.Length == 0) {
lineEndings = new[] { "\r\n", "\r", "\n" };
}

return s.Split(lineEndings, StringSplitOptions.None);
}

public static string NormalizeLineEndings(this string s, string lineEnding = null) {
lineEnding = lineEnding ?? Environment.NewLine;
return string.Join(lineEnding, s.SplitLines());
}
}
}
Loading