Skip to content

Releases: skybrud/Skybrud.Essentials

v1.1.47

06 Feb 16:36
Compare
Choose a tag to compare

Installation

Install via NuGet - either via the .NET CLI:

dotnet add package Skybrud.Essentials --version 1.1.47

or the NuGet package manager:

Install-Package Skybrud.Essentials -Version 1.1.47

Changelog

  • Added misc Parse{Type}OrNull methods (see ada8998)
    The methods tries to parse a string value to a desired value type. Opposed to the existing Parse{Type} methods, which returns the default value for the respective value types, the new methods return null if the parsing fails.

  • Added new To{Type}OrNull extension methods (see 053a536)
    The methods tries to parse a string value to a desired value type. Opposed to the existing To{Type} extension methods, which returns the default value for the respective value types, the new methods return null if the parsing fails.

  • Introduced new ParseEnumOrNull utility method and ToEnumOrNull extension method (see a4baefb)
    As an alternative to the existing ParseEnum utility method and the ToEnum extension method, this release introduces ParseEnumOrNull and ToEnumOrNull alternatives that return null if the parsing fails.

v1.1.46

23 Jan 19:53
Compare
Choose a tag to compare

Installation

Install via NuGet - either via the .NET CLI:

dotnet add package Skybrud.Essentials --version 1.1.46

or the NuGet package manager:

Install-Package Skybrud.Essentials -Version 1.1.46

Changelog

This release fixed a few minor bugs, but mainly adds additional functionality for working with date and time.

StringExtensions

  • Added [NotNullWhen(true)] attribute to HasValue out parameter (see 79fedd9)
    The out parameter of the StringExtensions.HasValue method is known to be not null when the method returns true, so the API contract should reflect that.

EssentialsTime

  • Fixed issue with time zone not being set via EssentialsTime constructor (see d57979b)
    Since the constructor takes a TimeZoneInfo parameter as it's second parameter, we also need to set that time zone on the created EssentialsTime instance.

  • Added To{Type} methods to the EssentialsTime class (see dc512ef)
    The new methods allow converting to EssentialsDate, EssentialsWeek, EssentialsMonth and EssentialsYear respectively. The four types already have constructors for create a new instance from an EssentialsTime instance. The new method does the same, but may be more useful in some scenarios - eg. when using method chaining.

EssentialsMonth

  • Added static Current property to the EssentialsMonth class (see b926f20)
    The new EssentialsMonth.Current property allows getting a reference to the current month.

  • Added IsCurrent property to the EssentialsMonth class (see e431ff7)
    The new property returns whether a EssentialsMonth instance represents the current month.

  • Added new constructors to the EssentialsMonth class (see d1820c9)
    As an alternative to the existing constructors, the new constructors allow creating new instances based on either DateTime, DateTimeOffset or EssentialsDate.

EssentialsWeek

  • Added IsCurrent property to the EssentialsWeek class (see 9b806f0)
    The property returns whether an EssentialsWeek instance equals the current ISO 8601 week.

EssentialsYear

  • Added static Current property to the EssentialsYear class (see 9ff4b84)
    The property allows getting a reference to an EssentialsYear instance representing the current year.

  • Added IsCurrent property to the EssentialsYear class (see fdb52e9)
    The property returns whether an EssentialsYear instance equals the current year.

  • Additional constructors to the EssentialsYear class (see 7e880de)
    The two new constructors allow creating a new EssentialsYear instance from an EssentialsDate instance.

TimeUtils

  • Added additional utility methods for working with DateTime (see 433548f)
    The new methods allow similar functionality as already available for DateTimeOffset and other classes.

EssentialsDateUtils

  • Introduced new EssentialsDateUtils class (see 0c7e76b)
    The new class provides a number of static utility methods for various date and time operations where the return value is an instance of EssentialsDate.

Other

  • Misc improvements to the EssentialsWeekRange class (see 0add3b3)
    Mainly the EssentialsWeekRange class now implements the IReadOnlyList<EssentialsWeek> rather than IEnumerable<EssentialsWeek>.

  • Introduced the EssentialsMonthRange class (see f55300d)
    The new EssentialsMonthRange allows representing a range of months in either ascending or descending order.

v1.1.45

11 Jan 20:13
Compare
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
Compare
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
Compare
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
Compare
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
Compare
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
Compare
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
Compare
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
Compare
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.