Skip to content

Commit

Permalink
Clarifying docs on StringExtensions that you shouldn't use
Browse files Browse the repository at this point in the history
  • Loading branch information
Piedone committed Nov 15, 2023
1 parent 21b3ed2 commit 9fcb88e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Lombiq.HelpfulLibraries.Common/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,15 @@ public static string ReplaceOrdinalIgnoreCase(this string text, string oldValue,
text.Replace(oldValue, newValue ?? string.Empty, StringComparison.OrdinalIgnoreCase);

/// <summary>
/// A shortcut for <c>string.Equals(string, StringComparison.Ordinal)</c>.
/// Use simple <see cref="string"/> equality check with <c>=</c> instead, since it already uses ordinal string
/// comparison.
/// </summary>
[Obsolete("The string equals operator already uses ordinal string comparison.")]
public static bool EqualsOrdinal(this string text, string? value) =>
throw new NotSupportedException();

/// <summary>
/// A shortcut for <c>string.Contains(string, StringComparison.Ordinal)</c>.
/// Use <c>string.Contains(string)</c> instead, since it already uses ordinal string comparison..
/// </summary>
[Obsolete("The string.Contains(value) member method already uses ordinal string comparison.")]
public static bool ContainsOrdinal(this string text, string value) =>
Expand Down Expand Up @@ -168,7 +169,7 @@ public static bool EndsWithOrdinal(this string text, string value) =>
text.EndsWith(value, StringComparison.Ordinal);

/// <summary>
/// A shortcut for <c>string.Replace(string, string, StringComparison.Ordinal)</c>.
/// Use <c>string.Replace(string, string) instead, since it already uses ordinal string comparison.</c>.
/// </summary>
[Obsolete("The string.Replace(oldValue, newValue) member method already uses ordinal string comparison.")]
public static string ReplaceOrdinal(this string text, string oldValue, string? newValue = "") =>
Expand Down

0 comments on commit 9fcb88e

Please sign in to comment.