Skip to content

Releases: skybrud/Skybrud.Essentials

Skybrud.Essentials v1.1.37

07 Mar 18:51
Compare
Choose a tag to compare

Installation

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

dotnet add package Skybrud.Essentials --version 1.1.37

or the NuGet package manager:

Install-Package Skybrud.Essentials -Version 1.1.37

Bug Fixes

  • Fixed incorrect ISO 8601 milliseconds format (see #18 and 8ab31d6)
    The Iso8601Constans.DateTimeMilliseconds constant was missing a period in the format, causing formatted dates to be incorrect.

  • The EssentialsTime.ToString(format) method is now using an invariant culture (see #19 and 22aa776)
    The point with the EssentialsTime class is that it should be culture invariant unless a culture is explicitly specified, so the method has now been updated to reflect this.

Skybrud.Essentials v1.1.36

14 Feb 15:45
Compare
Choose a tag to compare

Installation

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

dotnet add package Skybrud.Essentials --version 1.1.36

or the NuGet package manager:

Install-Package Skybrud.Essentials -Version 1.1.36

Changelog

  • Introduced new constants to the Iso8601Constants class (see b6c2961)
    As part of introducing better support for milliseconds, this release introduces the Date, DateTimeSeconds and DateTimeMilliseconds constants. The DateFormat (replaced by Date) and DateTimeFormat (replaced by DateTimeSeconds) are now marked as obsolete.

  • Introduced new logic for working with Unix time in milliseconds (see fe79cb5)
    New methods were added to the EssentialsTime and UnixTimeUtils classes for making working with Unix time more convenient. Changes include:

    • Marked EssentialsTime.FromUnixTimestamp methods as obsolete (as it was replaced by EssentialsTime.FromUnixTimeSeconds)
    • Introduced new EssentialsTime.FromUnixTimeSeconds methods
    • Introduced new EssentialsTime.FromUnixTimeMilliseconds methods
    • Introduced new UnixTimeUtils.FromMilliseconds methods
    • Introduced new UnixTimeUtils.ToMilliseconds methods
  • Introduced new UnixTimeFormat enum for UnixTimeConverter class (see a6837d6)
    The JSON converter now supports specifying the format of the converter - either UnixTimeFormat.Seconds (default) or UnixTimeFormat.Milliseconds. Until now, the converter has only supported converting back and forth between the UNIX timestamp expressed with seconds, but by setting the format to UnixTimeFormat.Milliseconds, the converter will now convert back and forth between milliseconds instead.

  • Improved the Unix time logic in the EssentialsTime class (see 32860ca)
    New properties were added to the EssentialsTime class for making working with Unix time more convenient. Changes include:

    • Introduced new CurrentUnixTimeSeconds static property
    • Introduced new CurrentUnixTimeMilliseconds static property
    • Marked UnixTimestamp property as obsolete (as it was replaced by UnixTimeSeconds)
    • Introduced new UnixTimeSeconds property
    • Introduced new UnixTimeMilliseconds property
    • Introduced new ToUnixTimeSeconds methodty
    • Introduced new ToUnixTimeMilliseconds method
  • EssentialsDate.TryParse method should invariant culture if not a culture isn't explicitly specified (see 1733f2f)
    The general idea with Skybrud.Essentials is that various logic should be culture invariant - unless specified otherwise. The TryParse(string input, out EssentialsDate result) relied on the current culture, which was wrong.

  • Added new method overloads to the ReflectionUtils class (see 3753413)
    As typical usage to get the version of an assembly would be something like ReflectionUtils.GetVersion(typeof(MyType).Assembly), it's now possibly to use ReflectionUtils.GetVersion<MyType>() instead.

  • Introduced new TryParseJsonToken, TryParseJsonObject and TryParseJsonArray method to the JsonUtils class (see dfef0f7)
    The new methods add a more safe way of parsing JSON values - eg. if the validity of the JSON is not certain. The implementation will catch an exception should it be triggered by JSON.net's parsing logic. It may still be best to do some simple validation on the input value first - eg. if it starts with [ or {.

  • Introduced new StringUtils.ParseHexString method (see 3fa44a3)
    The method allows parsing a HEX string into a corresponding byte array; the opposite of the StringUtils.ToHexString method.

Skybrud.Essentials v1.1.35

14 Jan 16:58
Compare
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
Compare
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
Compare
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
Compare
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
Compare
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
Compare
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
Compare
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
Compare
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