The changes each version of this project brings are documented here.
This file's format is based on Keep a Changelog.
This project adheres to Semantic Versioning.
Legend:
💜 - Bug fix
🟢 - New feature
🔴 - Removed feature
🟡 - Altered existing feature
⚪ - Note not directly relating to the project functionality
💜 Sanitized exception messages to not include potentially sensitive data, restructure exception messages a bit to be more readable, update method signatures and summaries.
⚪ Renamed "StringExtensions" classes to "UsefulStringExtensions", as the previous name was too generic and could cause conflicts with user code or other libraries.
⚪ Changed the CHANGELOG date format.
💜 Fixed some test names, test data and added missing tests for "TrimStart" and "TrimEnd" methods. 🟢 Updated library to .Net 8.
🟡 Changed library class structure to additionally facilitate users. Now all classes are partial and named "StringExtensions" to allow users to have their own classes using the old class names. File names remain unchanged for ease of structural navigation.
🟢 Updated to .Net 7
⚪ Inconsequently, from this point onwards changelog sections names (such as "Changes", "Fixes", etc.) will be omitted, as there is a visual legend present.
🟡 All "Trim", "TrimStart" and "TrimEnd" methods now remove all leading/trailing occurrences of the given string, instead of just the first, as this is more in line with the existing .NET methods.
While this could more be regarded as a "bug fix" it significantly changes the way those methods work and, thus, this is a new major version release.
💜 Fixed debug symbols not being embedded in the package.
💜 Fixed KeepOnlySpecialCharacters() method only keeping a single instance of each special character.
🟢 Updated to .Net 6.
🟢 Updated NuGet Icon.
🟢 Added NuGet README.
🟢 Improved all method validation and thrown exception messages. Now any problems will be caught better and any exceptions caused will contain more useful information.
🟢 Embedded debug symbols, so that the library source code can be stepped through during debugging.
🟢 Added Remove(string removeString, StringComparison stringComparison = StringComparison.CurrentCulture) method that removes all occurrences of the given removeString.
🟢 Added Trim(string trimString, StringComparison stringComparison = StringComparison.CurrentCulture, bool trimWhitespace = false) and Trim(string trimString, bool ignoreCase, CultureInfo? culture, bool trimWhitespace = false) methods that remove leading and tailing occurrences of the given trimString.
🟡 Improved some summaries.
🟡 Consolidated the Replace(IEnumerable<string> oldStrings, string newString) and Replace(IEnumerable<string> oldStrings, string newString, bool ignoreCase) methods into Replace(string newString, IEnumerable<string> oldStrings, StringComparison stringComparison = StringComparison.CurrentCulture). This allows more string comparison flexibility and features improved validation of arguments and information in thrown exceptions.
🟡 Consolidated the Replace(IEnumerable<string> oldStrings, string newString) and Replace(IEnumerable<string> oldStrings, string newString, bool ignoreCase) methods into Replace(string newString, IEnumerable<string> oldStrings, StringComparison stringComparison = StringComparison.CurrentCulture). This allows more string comparison flexibility.
🟡 Consolidated the Remove(IEnumerable<string> removeStrings) and Remove(bool ignoreCase, IEnumerable<string> removeStrings) methods into Remove(IEnumerable<string> removeStrings, StringComparison stringComparison = StringComparison.CurrentCulture).
🟡 Changed signature of method Replace(bool ignoreCase, string newString, params string[] oldStrings) to Replace(string newString, bool ignoreCase = false, params string[] oldStrings).
🟡 Added additional information in ArgumentNullExceptions about the name of the method the exception occurred in.
Before the message would be akin to "The argument given for 'keychars' was null.", now the message will be akin to "The argument given for parameter "keychars" of method "Contains" was null.".
This was done to give more details to developers trying to debug the source of such an exception, as many different methods can have parameters with the same name.
🟡 Added boolean "trimWhitespace" parameter and changed parameter "culture" of methods TrimStart(string trimString, bool ignoreCase, CultureInfo culture) and TrimEnd(string trimString, bool ignoreCase, CultureInfo culture) to be nullable. The signatures are now TrimStart(string trimString, bool ignoreCase, CultureInfo? culture, bool trimWhitespace = false) and TrimEnd(string trimString, bool ignoreCase, CultureInfo? culture, bool trimWhitespace = false).
🔴 Replace(string newString, params string[] oldStrings)
🔴 Replace(bool ignoreCase, string newString, params string[] oldStrings)
🔴 Contains(params string[] keywords)
🔴 Contains(StringComparison comparison, params string[] keywords)
🔴 Contains(params char[] keychars)
🔴 Contains(StringComparison comparison, params char[] keychars)
🔴 Remove(params string[] removeStrings)
🔴 Remove(bool ignoreCase, params string[] removeStrings)
These methods could be legally called with no argument for the params parameter, which would either do nothing or throw an exception. This is a very confusing and unpleasant behaviour, even when fully documented.
It was decided that the convenience of, potentially, saving the user from passing these arguments as an IEnumerable is not worth the hassle.
🔴 Trim(int amount)
🔴 TrimStart(int amount)
🔴 TrimEnd(int amount)
These methods' functionality can be easily achieved with indices and ranges or the "Substring" method.
🔴 TrimStart(string trimString)
🔴 TrimEnd(string trimString)
Added default value for parameter stringComparison of methods TrimStart(string trimString, StringComparison stringComparison) and TrimEnd(string trimString, StringComparison stringComparison), thus the same functionality can be achieved with them.
Rebranded from IvanStoychev.StringExtensions.