From 21e4d30f9813616bef3861fa38f721c287d28906 Mon Sep 17 00:00:00 2001 From: adelikat Date: Tue, 19 May 2020 19:37:52 -0500 Subject: [PATCH] remove another string extension method that was unused, and consolidate classes --- .../Extensions/StringExtensions.cs | 26 ++++++++++++-- .../Extensions/SubstringExtensions.cs | 34 ------------------- 2 files changed, 24 insertions(+), 36 deletions(-) delete mode 100644 src/BizHawk.Common/Extensions/SubstringExtensions.cs diff --git a/src/BizHawk.Common/Extensions/StringExtensions.cs b/src/BizHawk.Common/Extensions/StringExtensions.cs index 5ccebffa09..ca4c0ecce3 100644 --- a/src/BizHawk.Common/Extensions/StringExtensions.cs +++ b/src/BizHawk.Common/Extensions/StringExtensions.cs @@ -5,7 +5,29 @@ namespace BizHawk.Common.StringExtensions { public static class StringExtensions { - /// if appears in (case-insensitive) - public static bool In(this string str, params string[] options) => options.Any(opt => string.Equals(opt, str, StringComparison.InvariantCultureIgnoreCase)); + /// + /// if appears in (case-insensitive) + /// + public static bool In(this string str, params string[] options) => + options.Any(opt => string.Equals(opt, str, StringComparison.InvariantCultureIgnoreCase)); + + /// + /// with the last char removed, or the original + /// if the last char of is not + /// + public static string RemoveSuffix(this string str, char suffix) => + str.Length != 0 && str[str.Length - 1] == suffix + ? str.Substring(0, str.Length - 1) + : str; + + /// + /// the substring of before the first occurrence of + /// , or if not found + /// + public static string? SubstringBeforeOrNull(this string str, string delimiter) + { + var index = str.IndexOf(delimiter); + return index < 0 ? null : str.Substring(0, index); + } } } diff --git a/src/BizHawk.Common/Extensions/SubstringExtensions.cs b/src/BizHawk.Common/Extensions/SubstringExtensions.cs deleted file mode 100644 index 5077c0fa77..0000000000 --- a/src/BizHawk.Common/Extensions/SubstringExtensions.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace BizHawk.Common.StringExtensions -{ - public static class SubstringExtensions - { - /// - /// with the last char removed, or the original - /// if the last char of is not - /// - public static string RemoveSuffix(this string str, char suffix) => - str.Length != 0 && str[str.Length - 1] == suffix - ? str.Substring(0, str.Length - 1) - : str; - - /// - /// the substring of before the first occurrence of - /// , or the original if not found - /// - public static string SubstringBefore(this string str, char delimiter) - { - var index = str.IndexOf(delimiter); - return index < 0 ? str : str.Substring(0, index); - } - - /// - /// the substring of before the first occurrence of - /// , or if not found - /// - public static string? SubstringBeforeOrNull(this string str, string delimiter) - { - var index = str.IndexOf(delimiter); - return index < 0 ? null : str.Substring(0, index); - } - } -}