Skip to content

Releases: skybrud/Skybrud.Essentials

v1.1.45

11 Jan 20:13

Choose a tag to compare

Installation

Install via NuGet - either via the .NET CLI:

dotnet add package Skybrud.Essentials --version 1.1.45

or the NuGet package manager:

Install-Package Skybrud.Essentials -Version 1.1.45

Changelog

  • Fixed time zone issues with EssentialsWeek.GetStartOfWeek and EssentialsWeek.GetEndOfWeek methods (see c1782ab)
    The two methods would return wrong results if the EssentialsWeek instance wasn't created from the TimeZoneInfo as specified as parameter for the two methods.

  • Added utility and extension methods for parsing enum lists (see bf4557d)
    This release introduces static utility methods for converting a CSV sting value into a corresponding an array or a list of enum values via the ParseEnumArray and ParseEnumList methods respectively. ToEnumArray and ToEnumList extension methods are now also available to be called directly on a string values.

  • Added extension methods for encoding and hashing string values (see ffd61ca)
    Skybrud.Essentials already contains a number of static Get{Algorithm}Hash utility methods. Matching To{Algorithm}Hash extension methods have now been added as well allowing them to be called directly on string values.

v1.1.44

12 Dec 21:49

Choose a tag to compare

Installation

Install via NuGet - either via the .NET CLI:

dotnet add package Skybrud.Essentials --version 1.1.44

or the NuGet package manager:

Install-Package Skybrud.Essentials -Version 1.1.44

Changelog

JSON

  • Internal JsonTokenUtils.String method should use invariant culture (see 2e6c476)
    The method is used internally in the package for converting a JToken to a string representation, and as such it's important that the method uses an invariant culture instead of the current culture.

  • Added Get{ValueType}OrNull and Get{ValueType}OrNullByPath extension methods to the NewtonsoftJsonObjectExtensions class (see 743ba7a)
    The new method allows getting nullable value types as an alternative to the default non-nullable value types already in the package.

EssentialsYear

  • Added explicit Start and End properties for the EssentialsYear class (see cc4bdca)
    The EssentialsYear class inherits the Start and End properties from EssentialsPeriod, but as EssentialsPeriod on it's own allows the to properties to be null. As a result, the new Start and End are not nullable as we know them to never be null for an EssentialsYear instance.

  • Added GetStartOfYear and GetEndOfYear methods to the EssentialsYear class (see 2520688)
    The two methods getting either the the start or end of the year, according to a specific time zone.

  • Added static Min and Max methods to the EssentialsYear class (see 6e08cbb)
    The methods allow finding either the minimum or maximum value of two EssentialsYear instances. Method overloads also support specifying multiple EssentialsYear instances.

  • Added GetStartOfYear and GetEndOfYear method overloads to the EssentialsYear class (see 8783f57)
    The two method overloads don't have any paramters, and the returned values will be based on the local time zone.

EssentialsMonth

  • Added explicit Start and End properties for the EssentialsMonth class (see 02df0a3)
    The EssentialsMonth class inherits the Start and End properties from EssentialsPeriod, but as EssentialsPeriod on it's own allows the to properties to be null. As a result, the new Start and End are not nullable as we know them to never be null for an EssentialsMonth instance.

  • Added static Min and Max methods to the EssentialsMonth class (see 355aa85)
    The methods allow finding either the minimum or maximum value of two EssentialsMonth instances. Method overloads also support specifying multiple EssentialsMonth instances.

  • Added GetStartOfMonth, GetStartOfYear, GetEndOfMonth and GetEndOfYear methods to the EssentialsMonth class (see fafd25a)
    The methods allows finding the start and end of either the month or the year - and based on either the local time zone or a specific time zone. The methods will take daylight savings into account if used by the time zone.

EssentialsWeek

  • Implemented ToString method in the EssentialsWeek class (see 5459a90)
    The ToString now returns an ISO 8601 string representation of the week.

  • Added GetYear method to the EssentialsWeek class (see 2df2c99)
    The method returns an EssentialsYear instance representing the year of the week.

  • Added Parse and TryParse methods to the EssentialsWeek class (see ec9c8fd)
    The methods allow parsing a ISO 8601 week string representation into an instance of EssentialsWeek.

  • Added static Min and Max methods to the EssentialsWeek class (see f256ee3)
    The methods allow finding either the minimum or maximum value of two EssentialsWeek instances. Method overloads also support specifying multiple EssentialsWeek instances.

  • Added GetStartOfWeek and GetEndOfWeek methods to the EssentialsWeek class (see 1cc68c1)
    The two methods allows getting the EssentialsTime for either the start of the week or end of the week respectively.

EssentialsDate

  • Added static Min and Max methods to the EssentialsDate class (see 13db5d2)
    The methods allow finding either the minimum or maximum value of two EssentialsDate instances. Method overloads also support specifying multiple EssentialsDate instances.

  • Added static Min and Max methods to the EssentialsTime class (see e5b0fb9)
    The methods allow finding either the minimum or maximum value of two EssentialsTime instances. Method overloads also support specifying multiple EssentialsTime instances.

EssentialsPeriod

  • Added EssentialsPeriod constructor overload (see afded4a)
    The overload takes a TimeZoneInfo instance as the third parameter to determine the time zone to be used for the Start and End properties.

EssentialsWeekRange

  • Added ToString, Parse and TryParse methods to the EssentialsWeekRange class (see #34 and 9fc08fb)
    This adds logic for converting a EssentialsWeekRange to a string and parsing from a string back to a EssentialsWeekRange instance.

EssentialsDateRange

  • Added ToString, Parse and TryParse methods to the EssentialsDateRange class (#32 and see 7e7d0ed)
    This adds logic for converting a EssentialsDateRange to a string and parsing from a string back to a EssentialsDateRange instance.

v1.1.43

01 Nov 13:26

Choose a tag to compare

Installation

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

dotnet add package Skybrud.Essentials --version 1.1.43

or the NuGet package manager:

Install-Package Skybrud.Essentials -Version 1.1.43

Changelog

  • Added support for nullable reference types (see b25e281, acbee18)
    This includes adding .NET 5 and .NET 6 as additional target frameworks, as they come with extended code analysis functionality out of the box. The Nullable package is added a development dependency to older target frameworks to provide the same code analysis functionality.

  • Added additional extension methods for NameValueCollection (see f0fb6bf)
    The .NET Framework versions of this package now features a number of new extension method for reading from NameValueCollection instances - eg. TryGetBoolean, TruGetGuid, TryGetInt32 and similar.

  • Added additional extension methods for DateTime and DateTimeOffset (see 7311284)
    The IsToday, IsTomorrow and IsYesterday extension methods are now available for both DateTime and DateTimeOffset.

  • Added static utility methods for working with ISO 8601 durations (see 0cd5538)
    The ISO 8601 standard also describes a way to specify durations - eg. PT30M or even P1Y2M10DT2H30M. Static methods for converting back and forth between this format and TimeSpan are now available in the Iso8601Utils class.

  • Introduced new extension methods for JObject and JArray (see 8e75a29, 24ded82 and 6034cfa)
    Skybrud.Essentials have had similar extension methods in the Skybrud.Essentials.Json.Extensions namespace for a while now, but the new extension methods are added to clean up the implementation and indicate that they are specifically for Newtonsoft.Json, and they are therefore located in the Skybrud.Essentials.Json.Newtonsoft.Extensions namespace. The old extension methods still exist, but will likely be marked as obsolete in a future release.

v1.1.42

27 Aug 20:04

Choose a tag to compare

Installation

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

dotnet add package Skybrud.Essentials --version 1.1.42

or the NuGet package manager:

Install-Package Skybrud.Essentials -Version 1.1.42

Changelog

Formatting

  • Introduced StringUtils.FormatFileSize methods for formatting file size (see #29, 1b15443 and f6acd89)
    Depending on the input, file sixes may be formatted using either kilobytes, kibibytes, or a mix of the two.

  • Added missing this keyword to ToHexString extension method (see 50f616a)
    The method doesn't really work as an extension method without the keyword.

Parsing

  • Added TryParse{Type} method overloads support a nullable result (see #30, 003a1f8)

  • Added IsBoolean method overloads to the StringExtensions class (see #30 and 4239551)
    The first method overload takes a string as it's only parameter, and returns whether the string value can be parsed and converted into a bool equivalent.

    The second method overload does the same, but has an additional parameter that uses the "out" keyword to expose the "bool?" value that resulted from the conversion.

  • Added new TryParseInt32 methods to the StringUtils class + unit tests (see #30 and 1caee9f)
    The new methods provides a culture invariant way to try/parsing integers.

  • Introduced new StringUtils.Parse{Type}List methods and StringUtils.To{Type}List extension methods (see #38 and fc9476d)
    This also changes the implementation of the "StringUtils.Parse{Type}Array" methods as they should never have used regular expressions for validating the individual number values.

  • Added new TryParse{Type} methods where necessary (see #30 and 589f87c)
    The new methods provides a culture invariant way to try/parsing various simple types.

  • Added Is{Type} method overloads to the StringExtensions class (see #30 and fd0b70a)
    The methods include IsBoolean, IsInt32, IsInt64 and similar to quickly test whether an input string matches a given simple type.

Enums

  • Added IsBetween methods to the EnumUtils and EnumExtensions classes (see #31 and 09556ec)
    Similar to elsewhere in the package, roughly the same functionality is implemented as both static utility methods and extensions methods.

XML

  • Updated XmlUtils.ToString method to set correct encoding in the generated XML declaration (see #37 and 7eab851)

  • This ensures that the XML declaration is part of the generated XML string when using the XmlUtils.ToString(XDocument) method - opposed to the default XDocument.ToString method where the XML declaration is omitted.

  • Added new XmlUtils.ToString method overload (see #37 and b4b10e1)
    The new overload takes a second parameter of the type SaveOptions, thereby controlling the format of the generated XML string.

Arrays & Collections

  • Implemented new ArrayUtils.Empty<T> utility method (see #40 and eb2b19b)
    As this package targets multiple frameworks, we can't really use Array.Empty<T> in all of them, so the ArrayUtils.Empty<T> provides a way to accomplish the same across all target frameworks.

  • Introduced new RandomOrDefault and OrderByRandom methods (see #39 and 49fa772)
    This adds methods for getting a random item of an IEnumerable<T> as well as sorting a IEnumerable<T>.

Reflection

  • Added GetVersion, GetFileVersion, GetInformationalVersion and GetFileVersionInfo method overloads (see 5074590)
    The new overloads take a Type instance as a single parameter, thereby supporting a few extra scenarios where using Type makes sense.

  • Added new IsExtensionClass and IsExtensionMethod methods to the ReflectionUtils and ReflectionExtensions classes (see 7fe6134)
    The methods may be used to check whether a class is an extension class or a method is an extension method.

Time

  • Added logic for working with quarters (see #41 and cbdf605)
    This exposes new Quarter properties to the EssentialsDate and EssentialsTime classes, as well as methods to the EssentialsDate, EssentialsTime and TimeUtils classes for finding either the start of the quarter or the end of the quarter.

v1.1.41

09 May 09:03

Choose a tag to compare

Installation

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

dotnet add package Skybrud.Essentials --version 1.1.41

or the NuGet package manager:

Install-Package Skybrud.Essentials -Version 1.1.41

v1.1.40

30 Apr 19:46

Choose a tag to compare

Installation

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

dotnet add package Skybrud.Essentials --version 1.1.40

or the NuGet package manager:

Install-Package Skybrud.Essentials -Version 1.1.40

Changelog

  • Updated Iso8601Utils.ToString to include milliseconds (see #23 and ef6deac)
    In previous releases, the Iso8601Utils.ToString method and logic relying on this method, would return an ISO 8601 string representation of timestamps but, without including the milliseconds (as was using the yyyy-MM-ddTHH:mm:ssK format rather than yyyy-MM-ddTHH:mm:ss.fffK). With this release, the method now uses yyyy-MM-ddTHH:mm:ss.fffK for timestamps with an offset to UTC and yyyy-MM-ddTHH:mm:ss.fffZ for UTC based timestamps (using Z' for Zulu time instead of +00:00).

    All formats are valid according to the ISO 8601 specification, so this technically doesn't change the validity of the output string, but the change could be seen as a breaking change if one relies on the format being yyyy-MM-ddTHH:mm:ssK.

  • Added new Subtract(TimeSpan) method to the EssentialsTime class (see #24 and 878b381)
    Like the DateTimeOffset.Subtract methods allows subtracting a TimeSpan instance of a DateTimeOffset, the EssentialsTime.Subtract method now allows similar functionality.

  • EssentialsTime.Add... methods should keep time zone information (see #25 and 504e158)
    The various Add... methods now carry over the time zone (if specified) to the resulting EssentialsTime instance.

  • EssentialsTime.ToLocalTime and EssentialsTime.ToUniversalTime methods should set the time zone for the resulting EssentialsTime (see #25 and 6cff8d5)
    The time zone is now set to TimeZoneInfo.Local and TimeZoneInfo.Utc respectively for the resulting EssentialsTime instances returned by the two methods.

  • Introduced new RegexUtils.IsMatch method overloads (see #26 cad2474)
    The method overloads utilizes out parameters to make the methods easier to use in certain scenarios. See #26 for more information.

v1.1.39

21 Apr 11:42

Choose a tag to compare

Installation

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

dotnet add package Skybrud.Essentials --version 1.1.39

or the NuGet package manager:

Install-Package Skybrud.Essentials -Version 1.1.39

Changelog

  • Introduced new Split extension methods for the String class (see #22 and 6432f89)
    The extension methods may be more favorable compared to the default String.Split method, as they support a number of different scenarios.

v1.1.38

24 Mar 17:45

Choose a tag to compare

Installation

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

dotnet add package Skybrud.Essentials --version 1.1.38

or the NuGet package manager:

Install-Package Skybrud.Essentials -Version 1.1.38

Changelog

  • Implemented collection deconstructors (see #20 and f447c78)
    This allows for tuple like deconstruction of IEnumerable<T> based collections.

  • Updated TimeSpanSecondsConverter class to support TimeSpan? (see #21 and b8d8fc9)
    The TimeSpanSecondsConverter JSON converter now supports serializing and deserializing both TimeSpan and TimeSpan? - opposed to only TimeSpan in earlier releases.

Skybrud.Essentials v1.1.37

07 Mar 18:51

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

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.