Skip to content

Releases: skybrud/Skybrud.Essentials

Skybrud.Essentials v1.1.35

14 Jan 16:58

Choose a tag to compare

Installation

Install the NuGet package - either via the .NET CLI:

dotnet add package Skybrud.Essentials --version 1.1.35

or the NuGet package manager:

Install-Package Skybrud.Essentials -Version 1.1.35

Changelog

  • Introduced new StringUtils.ToHexString utility methods (see 4f35fda)
    The ToHexString methods allow converting a byte array to a corresponding HEX string. The ToHexString(byte[]) method will return the HEX string in lower case, whereas the ToHexString(byte[], HexFormat) method overload allows specifying either HexFormat.LowerCase or HexFormat.UpperCase for the second parameter.

  • Introduced new StringExtensions.ToHexString extension methods (see 4f35fda)
    Similar to the static StringUtils.ToHexString utility methods, the StringExtensions.ToHexString offer the same functionality but as extension methods.

  • Introduced new SecurityUtils.GetHmacSha1Hash methods (see b20f76b)
    This introduces four new method signatures for getting the HMACSHA1 hash of a given key and value.

  • Introduced new SecurityUtils.GetHmacSha256Hash methods (see b20f76b)
    This introduces four new method signatures for getting the HMACSHA256 hash of a given key and value.

  • Introduced new SecurityUtils.GetHmacSha512Hash methods (see b20f76b)
    This introduces four new method signatures for getting the HMACSHA512 hash of a given key and value.

  • Added new SecurityUtils.GetMd5Hash method overloads (see b20f76b)
    This introduces two new method overloads with a HexFormat parameter for controlling the case of the returned hash.

  • Added new SecurityUtils.GetSha1Hash method overloads (see b20f76b)
    This introduces two new method overloads with a HexFormat parameter for controlling the case of the returned hash.

  • Added new SecurityUtils.GetSha256Hash method overloads (see b20f76b)
    This introduces two new method overloads with a HexFormat parameter for controlling the case of the returned hash.

  • Added new SecurityUtils.Get512Hash method overloads (see b20f76b)
    This introduces two new method overloads with a HexFormat parameter for controlling the case of the returned hash.

Skybrud.Essentials v1.1.34

21 Dec 16:02

Choose a tag to compare

Installation

Install the NuGet package - either via the .NET CLI:

dotnet add package Skybrud.Essentials --version 1.1.34

or the NuGet package manager:

Install-Package Skybrud.Essentials -Version 1.1.34

Changelog

  • Added generic overloads for the StringExtensions.Join methods (see 28f074a)
    The two methods aren't really that useful if not generic. The two existing methods should have been generic in the first place, but are now kept for backwards compatibility.

Skybrud.Essentials v1.1.33

25 Nov 20:17

Choose a tag to compare

Installation

Changelog

  • Added StringExtensions.ToBoolean method overload (see d78f58d)
    The class already has the ParseBoolean method, but this being an extension method, the name should instead of ToBoolean. To ensure backwards compatibility, the ParseBoolean method is now marked as obsolete, and a new ToBoolean with the same implementation is added instead.

  • Introduced new StringExtensions.IfNullOrWhiteSpace extension methods (see 3ff3b92)
    For the first method, if it's passed a value that is either null, empty or white space, the specified fallback value is returned instead.

    The second method works in a similar way, but supports a fallback function instead. This is useful if the fallback value requires expensive lookups, as the function is only invoked when needed.

  • Introduced new StringExtensions.NullIfWhiteSpace extension methods (see 696732c)
    If the method is passed a value that is either empty or white space, a null value is returned; otherwise the input value is returned untouched.

Skybrud.Essentials v1.1.32

30 Oct 22:11

Choose a tag to compare

Installation

Changelog

  • Fixed issue with EssentialsDate.IsWeekend calling the wrong utility method (see 1ac081d)
    This is the same as the issue reported in #16, but in a different, but similar part of the code.

  • Added new IsTomorrow and IsYesterday properties to the EssentialsDate class (see aa23c9a)
    The EssentialsTime class already has similar properties, so makes sense to add matching properties for the EssentialsDate class.

  • Introduced new ToHtmlString extension method (see ee365ec)
    This release adds a ToHtmlString extension method which can be used for turning a string into an IHtmlString, which is in particular useful for method chaining.

  • Added missing this keyword for string extension methods (see 7656d6b)
    As the affected method has always been intended as being extension methods, it's a bug that they were missing the this keyword.

  • Added logic for converting a NameValueCollection to an URL encoded string and back again (see 41b9338)
    The StringUtils class now contains a static ToUrlEncocedString utility method for converting NameValueCollection instances to an URL encoded string.

    In a similar way, the StringExtensions class now contains a ToUrlEncodedString extension method for converting to an URL encoded string, and a ToNameValueCollection extension method for converting an URL encoded string back to a NameValueCollection instance.

  • Introduced new StringJsonConverter and NameValueCollectionJsonConverter classes (see c7fb51e)
    The new StringJsonConverter class replaces the ToStringJsonConverter class, and serializes any .NET type to it's corresponding string representation. For NameValueCollection, this means an URL encoded string, but for any other types, the value will be the same as calling the ToString method with an invariant culture. Generally the converter doesn't support deserialization, as most types can't be converted from a string to an object. But specifically, the converter currently supports deserializing to back to a NameValueCollection instance or any enum type.

    The NameValueCollectionJsonConverter class serializes a NameValueCollection to a corresponding JObject, where each key value pair in the value collection is added as properties and in the resulting JObject. The converter also supports deserializing a JObject back to a corresponding NameValueCollection.

  • Introduced new Truncate utility and extension methods (see 509c92e)
    The methods allows truncating a given string to a maximum length. This is possible either via the static StringUtils.Truncate utility method, or the StringExtensions.Truncate extension method.

  • Added MinValue and MaxValue fields to the EssentialsDate class (see ab27666)
    Similar to DateTime.MinValue and DateTime.MaxValue, the EssentialsDate now contains a EssentialsDate.MinValue field and a EssentialsDate.MaxValue field respectively. This can be useful when comparing instance of EssentialsDate.

  • Introduced new GuidUtils and GuidExtensions classes (see 990a7d6 and #17)
    The two classes contains various logic for working with GUIDs, either as static utility methods or as extension methods. This includes methods for converting GUIDs back and forth between their numeric representations, as as well as extension methods for validating GUIDs.

  • Added constructor overload to the EssentialsPartialDate class (see 1cdea40 and #14)
    The new constructor takes an instance of EssentialsTime as it's only parameter.

Skybrud.Essentials v1.1.31

17 Oct 16:52

Choose a tag to compare

Installation

Changelog

  • Introduced new GetFlags enum extension method (see a8fdbd2)
    The new GetFlags method takes a enum value with the [Flags] attribute and returns each flag individual instances.

  • Introduced new utility and extension methods for converting a collection of enums to a given case (see a8fdbd2)
    The package already contains methods for converting a single enum value to a textual representation using given case. The new methods takes a collection of enum values, and returns a comma separated string with the textual representation of each enum value in the collection.

  • Introduced new ToHashSet extension methods (see e6816e3)
    The two extension methods allow for method chaining, which may make code more readable - opposed to having to call the HashSet<T> constructor manually.

  • Added new EnumerableExtensions.GetReverse extension method for getting the opposite value of a SortOrder value (see 6b078ee)
    Allows turning SortOrder.Ascending into SortOrder.Descending, or SortOrder.Descending into SortOrder.Ascending.

  • Introduced new StringUtils.FirstWithValue utility methods (see 0d434c9 and de4e191)
    Both overloads return the first value that is not either null, empty or whitespace.

  • Introduced new StringExtensions.Join extension methods for the System.String class (see 2fb0d42)
    Using the extension methods instead of the string.Join method allows for method chaining.

  • Fixed indices typo for StringUtils.ToPlural and StringUtils.ToSingular methods (see e5f04b1)
    The word indices was incorrectly spelled indeces - also in the unit tests, resulting in this issue going unnoticed until now.

  • Introduced StringUtils.ToPlural method overloads (see d0965fb)
    The two new methods allow specifying either a count or a boolean to indicate whether the returned value should be plural or singular.

Skybrud.Essentials v1.1.30

27 Sep 21:10

Choose a tag to compare

Installation

Changelog

  • Added DaySuffix property to the EssentialsDateTime class (see 7c5ac10)
    The EssentialsTime class already has a similar property, so might as well add one for the EssentialsDateTime class.

  • Fixed issue with EssentialsTime.IsWeekend and EssentialsDateTime.IsWeekend properties should call the correct utility method (see d6b11ea and #16)
    The two properties wrongly called the TimeUtils.IsLeapYear utility method instead of TimeUtils.IsWeekend. Thanks to @enkelmedia for reporting 👍

  • Improved the code base behind GetBoolean JSON extension methods (see c8593d0)

    • Introduced JsonTokenUtils to avoid duplicate code throughout the package
    • Added GetBoolean overloads with a fallback parameter
    • Added new TryGetBoolean extension methods
    • Added unit tests to ensure changes does work as intended
  • Added GetMd5Guid methods to the SecurityUtils class (see ca23b5a)
    Sometimes it may be useful to have a MD5 hash formatted as a GUID.

Skybrud.Essentials v1.1.29

18 Jun 10:54

Choose a tag to compare

Installation

Changelog

  • Introduced new static methods and extension methods for working with enums (see 79a6f6b)
    This release introduces the ToEnum and ToInt32 extension methods in the EnumExtensions class.

  • Introduced new ToStringArray extension methods (see f0b1148)
    The first ToStringArray method takes a string and splits it's into an array using a predefined list of separators. The second ToStringArray method has a second parameter for specifying the separator to be used.

  • EnumUtils.TryParseEnum shouldn't fail if the input is null or empty (see 0952e0c and #13)
    Passing null or an empty string to the method shouldn't trigger an exception, but instead cause to method to return false; indicating that the parsing failed.

Skybrud.Essentials v1.1.28

10 Apr 15:30

Choose a tag to compare

Installation

Changelog

  • StripHtml methods shouldn't break on null values (see 3bda45b, e5d6528)
    The two StripHtml methods in the StringUtils class would break if passed a null value. With this release, the two methods will now return null if the input string is a null value.

  • Added ReplaceLineBreaks extension method (see 2ad8dd1)
    The previous release added a ReplaceLineBreaks method in the StringUtils class. With this release, a similar ReplaceLineBreaks extension method is now also available via the StringExtensions class.

  • Extended the implementation of the EssentialsMonth class (see 2bd860a)
    The class has been updated with the following changes:

    • Introduced new GetPrevious member methods for getting the previous month
    • Introduced new GetNext member methods for getting the next month
    • Introduced new GetMonths static methods for getting an array of multiple months

Skybrud.Essentials v1.1.27

21 Mar 20:56

Choose a tag to compare

Installation

Changelog

  • Introduced the StringUtils.ReplaceLineBreaks method (see 50deea5)
    The method replaces carriage return and new line characters (\r\n, \r, and \n) with HTML line breaks <br />.

  • Added more method overloads for ReflectionUtils and ReflectionExtensions (see 18c9c0c, 0f93924 and ddce8ae)
    With this release, more overloads of the HasCustomAttribute, HasCustomAttributes, GetCustomAttribute, GetCustomAttribute and IsObsolete methods are now available.

Skybrud.Essentials v1.1.26

09 Feb 22:36

Choose a tag to compare

Installation

Changelog

  • Added support for Swatch Internet Time (see 32c1483, aeccd83, e3a177d, 00820d3)
    While holding little use today, Swatch Internet Time is an alternative way to describe the time of day using beats - a whole day being 1000 beats. A single beat equals 86.4 seconds.

  • Introduced new Iso8601Utils and Iso8601Constants classes (b018ee6, 9dee41d)
    The new classes separate ISO 8601 related logic into it's own namespace and classes, hopefully making the classes easier to understand. Similar ISO 8601 related methods in the TimeUtils class have now been marked as obsolete.

  • Introduced new Rfc822Utils class (see 9dee41d)
    The new class separates a lot of the RFC 822 related logic into it's own class. The methods in the TimeUtils class still exist, but are now marked as obsolete in favor of the methods in the new class.

  • Introduced new Rfc2822Utils class (see 9dee41d)
    The new class separates a lot of the RFC 2822 related logic into it's own class. The methods in the TimeUtils class still exist, but are now marked as obsolete in favor of the methods in the new class.

  • Introduced new UnixTimeUtils class (see 83af7a4)
    The new class separates a lot of the Unix time related logic into it's own class. The methods in the TimeUtils class still exist, but are now marked as obsolete in favor of the methods in the new class.

  • Introduced new EssentialsPeriod class (see 3267181, a29d1b4)
    The new class describes a period of time, identified by two instances of EssentialsTime for the start date and end date respectively.

  • Introduced static FromTicks methods in the EssentialsTime class (see c172e85)
    The EssentialsTime class now support creating a new instance from a specified amount of ticks - similar to the FromTicks methods in DateTime and DateTimeOffset classes.

  • The EssentialsDateTime class is now marked as obsolete (see 9dee41d)
    The class has been around in this package for quite some time, but was superseded by the EssentialsTime class a while back, as the latter wraps an instance of DateTimeOffset instead of DateTime.

    It's still possible to use the EssentialsDateTime, but it's recommended to use the EssentialsTime class instead.

  • Introduced EssentialsMonth class (see 15351ca)
    Inheriting from the EssentialsPeriod class, EssentialsMonth can be used to represent a specific month, and provides some additional month-specific properties compared to the properties found in the base class.

  • Introduced EssentialsYear class (see db3cd86)
    Inheriting from the EssentialsPeriod class, EssentialsYear can be used to represent a specific year, and provides some additional year-specific properties compared to the properties found in the base class.

  • EssentialsTime operator overloads from Unix timestamp should be avoided (see b06f9ab)
    The operators seem to lead to more confusion than they do good, so they have now been marked as obsolete, and will be removed in a future release.

  • Introduced new JObjectExtensions.GetGuidArray extension method (see 0a4c5c9)
    The new extension method allows getting an array of Guid's from a JObject property. The method works similar to the other extension methods in the same class, but contains a bit more error handling.