From a5dac7f1b27ee84d31754c997d01e1d1578840a3 Mon Sep 17 00:00:00 2001 From: Chris3606 Date: Tue, 5 Dec 2023 21:33:56 -0600 Subject: [PATCH] Upgraded packages and removed ToString extension methods duplicated by the primitives library. Bumped csproj for 3.0.0-beta09 release. --- GoRogue.Debugger/GoRogue.Debugger.csproj | 2 +- .../GoRogue.PerformanceTests.csproj | 2 +- GoRogue.UnitTests/GoRogue.UnitTests.csproj | 4 +- GoRogue/DisjointSet.cs | 1 + GoRogue/Effects/EffectTriggerBase.cs | 1 + GoRogue/GoRogue.csproj | 6 +- GoRogue/Utility.cs | 232 ------------------ changelog.md | 4 + 8 files changed, 13 insertions(+), 239 deletions(-) diff --git a/GoRogue.Debugger/GoRogue.Debugger.csproj b/GoRogue.Debugger/GoRogue.Debugger.csproj index 2e06592f..2d6fcfa2 100644 --- a/GoRogue.Debugger/GoRogue.Debugger.csproj +++ b/GoRogue.Debugger/GoRogue.Debugger.csproj @@ -62,7 +62,7 @@ - + all diff --git a/GoRogue.PerformanceTests/GoRogue.PerformanceTests.csproj b/GoRogue.PerformanceTests/GoRogue.PerformanceTests.csproj index e69f592b..30d6cbaf 100644 --- a/GoRogue.PerformanceTests/GoRogue.PerformanceTests.csproj +++ b/GoRogue.PerformanceTests/GoRogue.PerformanceTests.csproj @@ -9,7 +9,7 @@ - + diff --git a/GoRogue.UnitTests/GoRogue.UnitTests.csproj b/GoRogue.UnitTests/GoRogue.UnitTests.csproj index a44840e1..e7075374 100644 --- a/GoRogue.UnitTests/GoRogue.UnitTests.csproj +++ b/GoRogue.UnitTests/GoRogue.UnitTests.csproj @@ -18,10 +18,10 @@ - + all - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/GoRogue/DisjointSet.cs b/GoRogue/DisjointSet.cs index 50811602..0531859d 100644 --- a/GoRogue/DisjointSet.cs +++ b/GoRogue/DisjointSet.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using JetBrains.Annotations; +using SadRogue.Primitives; namespace GoRogue { diff --git a/GoRogue/Effects/EffectTriggerBase.cs b/GoRogue/Effects/EffectTriggerBase.cs index c7a680c3..b3783cac 100644 --- a/GoRogue/Effects/EffectTriggerBase.cs +++ b/GoRogue/Effects/EffectTriggerBase.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using JetBrains.Annotations; +using SadRogue.Primitives; namespace GoRogue.Effects { diff --git a/GoRogue/GoRogue.csproj b/GoRogue/GoRogue.csproj index 7fd7aec7..57b62962 100644 --- a/GoRogue/GoRogue.csproj +++ b/GoRogue/GoRogue.csproj @@ -11,7 +11,7 @@ Configure versioning information, making sure to append "debug" to Debug version to allow publishing to NuGet seperately from Release version. --> - 3.0.0-beta08 + 3.0.0-beta09 $(Version)-debug @@ -79,10 +79,10 @@ - + all - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/GoRogue/Utility.cs b/GoRogue/Utility.cs index 49816e62..64fa425b 100644 --- a/GoRogue/Utility.cs +++ b/GoRogue/Utility.cs @@ -28,238 +28,6 @@ public static ReadOnlyDictionary AsReadOnly( where TKey : notnull => new ReadOnlyDictionary(dictionary); - /// - /// Extension method for that allows retrieving a string - /// representing the contents. - /// - /// - /// Built-in C# data structures like implement , - /// and as such this method can be used to stringify the contents of C# built-in data structures. - /// When no customization parameters are specified, it defaults to a representation looking something - /// like [elem1, elem2, elem3]. - /// - /// - /// - /// Character(s) that should precede the string representation of the IEnumerable's elements. - /// - /// Function to use to get the string representation of each element. Specifying null uses the ToString - /// function of type T. - /// - /// Characters to separate the IEnumerable's elements by. - /// Character(s) that should follow the string representation of the IEnumerable's elements. - /// A string representation of the IEnumerable. - public static string ExtendToString(this IEnumerable enumerable, string begin = "[", - Func? elementStringifier = null, string separator = ", ", - string end = "]") - { - elementStringifier ??= obj => obj?.ToString() ?? "null"; - - var result = new StringBuilder(begin); - var first = true; - foreach (var item in enumerable) - { - if (first) - first = false; - else - result.Append(separator); - - result.Append(elementStringifier(item)); - } - - result.Append(end); - - return result.ToString(); - } - - /// - /// Extension method for that allows retrieving a string representing the - /// contents. - /// - /// - /// Built-in C# data structures like implement , - /// and as such this method can be used to stringify the contents of C# built-in set structures. - /// When no customization parameters are specified, it defaults to a representation looking something - /// like set(elem1, elem2, elem3). - /// - /// - /// - /// Character(s) that should precede the string representation of the set's elements. - /// - /// Function to use to get the string representation of each element. Specifying null uses the ToString - /// function of type T. - /// - /// Characters to separate the set's items by. - /// Character(s) that should follow the string representation of the set's elements. - /// A string representation of the ISet. - public static string ExtendToString(this ISet set, string begin = "set(", - Func? elementStringifier = null, string separator = ", ", - string end = ")") - => ExtendToString((IEnumerable)set, begin, elementStringifier, separator, end); - - /// - /// Extension method for dictionaries that allows retrieving a string representing the dictionary's contents. - /// - /// - /// Built-in C# data structures like implement , - /// and as such this method can be used to stringify the contents of C# built-in dictionary structures. - /// When no customization parameters are specified, it defaults to a representation looking something - /// like {key1 : value, key2 : value}. - /// - /// - /// - /// - /// Character(s) that should precede the string representation of the dictionary's elements. - /// - /// Function to use to get the string representation of each key. Specifying null uses the ToString - /// function of type K. - /// - /// - /// Function to use to get the string representation of each value. Specifying null uses the ToString - /// function of type V. - /// - /// Characters used to separate each value from its key. - /// Characters used to separate each key-value pair from the next. - /// Character(s) that should follow the string representation of the dictionary's elements. - /// A string representation of the IDictionary. - public static string ExtendToString(this IDictionary dictionary, string begin = "{", - Func? keyStringifier = null, - Func? valueStringifier = null, - string kvSeparator = " : ", string pairSeparator = ", ", - string end = "}") - where TKey : notnull - { - keyStringifier ??= obj => obj.ToString() ?? "null"; - - valueStringifier ??= obj => obj?.ToString() ?? "null"; - - var result = new StringBuilder(begin); - var first = true; - foreach (var (key, value) in dictionary) - { - if (first) - first = false; - else - result.Append(pairSeparator); - - result.Append(keyStringifier(key) + kvSeparator + valueStringifier(value)); - } - - result.Append(end); - - return result.ToString(); - } - - /// - /// Extension method for 2D arrays that allows retrieving a string representing the contents. - /// - /// - /// - /// Character(s) that should precede the string representation of the 2D array. - /// Character(s) that should precede the string representation of each row. - /// - /// Function to use to get the string representation of each value. Specifying null uses the ToString - /// function of type T. - /// - /// Character(s) used to separate each row from the next. - /// Character(s) used to separate each element from the next. - /// Character(s) that should follow the string representation of each row. - /// Character(s) that should follow the string representation of the 2D array. - /// A string representation of the 2D array. - public static string ExtendToString(this T[,] array, string begin = "[\n", string beginRow = "\t[", - Func? elementStringifier = null, - string rowSeparator = ",\n", string elementSeparator = ", ", - string endRow = "]", string end = "\n]") - { - elementStringifier ??= obj => obj?.ToString() ?? "null"; - - var result = new StringBuilder(begin); - for (var x = 0; x < array.GetLength(0); x++) - { - result.Append(beginRow); - for (var y = 0; y < array.GetLength(1); y++) - { - result.Append(elementStringifier(array[x, y])); - if (y != array.GetLength(1) - 1) result.Append(elementSeparator); - } - - result.Append(endRow); - if (x != array.GetLength(0) - 1) result.Append(rowSeparator); - } - - result.Append(end); - return result.ToString(); - } - - /// - /// Extension method for 2D arrays that allows retrieving a string representing the contents, - /// formatted as if the 2D array represents a coordinate plane/grid. - /// - /// - /// This differs from - /// - /// in that this method prints the array - /// such that array[x+1, y] is printed to the RIGHT of array[x, y], rather than BELOW it. - /// Effectively it assumes the indexes being used are grid/coordinate plane coordinates. - /// - /// - /// - /// Character(s) that should precede the string representation of the 2D array. - /// Character(s) that should precede the string representation of each row. - /// - /// Function to use to get the string representation of each value. Specifying null uses the ToString - /// function of type T. - /// - /// Character(s) used to separate each row from the next. - /// Character(s) used to separate each element from the next. - /// Character(s) that should follow the string representation of each row. - /// Character(s) that should follow the string representation of the 2D array. - /// - /// A string representation of the 2D array, formatted as if the array represents a 2D coordinate plane/grid map. - /// - public static string ExtendToStringGrid(this T[,] array, string begin = "", string beginRow = "", - Func? elementStringifier = null, - string rowSeparator = "\n", string elementSeparator = " ", - string endRow = "", string end = "") - => new ArrayView2D(array).ExtendToString(begin, beginRow, elementStringifier, rowSeparator, - elementSeparator, endRow, end); - - /// - /// Extension method for 2D arrays that allows retrieving a string representing the contents, - /// formatted as if the 2D array represents a coordinate plane/grid. - /// - /// - /// This differs from - /// - /// in that this method prints the array such that array[x+1, y] is printed to the RIGHT of array[x, y], rather than BELOW - /// it. - /// Effectively it assumes the indexes being used are grid/coordinate plane coordinates. - /// - /// - /// - /// - /// The amount of space each element should take up in characters. A positive number aligns - /// the text to the right of the space, while a negative number aligns the text to the left. - /// - /// Character(s) that should precede the string representation of the 2D array. - /// Character(s) that should precede the string representation of each row. - /// - /// Function to use to get the string representation of each value. Specifying null uses the ToString - /// function of type T. - /// - /// Character(s) used to separate each row from the next. - /// Character(s) used to separate each element from the next. - /// Character(s) that should follow the string representation of each row. - /// Character(s) that should follow the string representation of the 2D array. - /// - /// A string representation of the 2D array, formatted as if the array represents a 2D coordinate plane/grid map. - /// - public static string ExtendToStringGrid(this T[,] array, int fieldSize, string begin = "", - string beginRow = "", Func? elementStringifier = null, - string rowSeparator = "\n", string elementSeparator = " ", - string endRow = "", string end = "") - => new ArrayView2D(array).ExtendToString(fieldSize, begin, beginRow, elementStringifier, rowSeparator, - elementSeparator, endRow, end); - /// /// "Multiplies", aka repeats, a string the given number of times. /// diff --git a/changelog.md b/changelog.md index 0c9f8a1b..4c0c4f96 100644 --- a/changelog.md +++ b/changelog.md @@ -7,6 +7,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - None +## [3.0.0-beta09] - 2023-12-05 +### Removed +- `ExtendToString` and `ExtendToGrid` extension methods from `Utility` class are removed (they now exist in the primitives library instead) + ## [3.0.0-beta08] - 2023-07-12 ### Added