Skip to content

Releases: skybrud/Skybrud.Essentials

v1.2.0-alpha001

08 Jul 19:30
Compare
Choose a tag to compare
v1.2.0-alpha001 Pre-release
Pre-release

Installation

Install via NuGet - either via the .NET CLI:

dotnet add package Skybrud.Essentials --version 1.2.0-alpha001

or the NuGet Package Manager:

Install-Package Skybrud.Essentials -Version 1.2.0-alpha001

v1.1.60

10 Jun 10:12
Compare
Choose a tag to compare

Installation

Install via NuGet - either via the .NET CLI:

dotnet add package Skybrud.Essentials --version 1.1.60

or the NuGet Package Manager:

Install-Package Skybrud.Essentials -Version 1.1.60

Changelog

  • Added new GetNativeLanguageName extension method for CultureInfo (see 8577b69)
    A CultureInfo may be based on a language or a language in a specific country. For the latter, the native name will be something like "Dansk (Danmark)", but when based on both a language and a country, the CultureInfo will have a reference to parent CultureInfo that will only be based on the language, so the native name for this will be "Dansk" instead, which is exactly what we want for this method.

  • Added Extends and Implements method overloads (see 9a570f2)
    Abstract or static classes can't be used as a generic type parameter, so the new method overloads take a Type instance instead.

  • Added logic for getting the build date from an assembly (see aa01744)
    This is mainly an internal thing.

  • Added misc extension methods for parsing IConfiguration values (see b955d44)
    This makes manual parsing of IConfiguration instances a bit easier.

  • Added ParseJsonObject and LoadJsonObject method overloads to the JsonUtils class (see 43dca9a)
    The new method overloads allow specifying a Type parameter instead of a generic type parameter.

  • Introduced new StreamUtils class (c19a61f)
    The class contains various utility/helper methods from converting to a stream and back again.

  • Introduced new JsonUtils.LoadJsonToken, JsonUtils.LoadJsonObject, and JsonUtils.LoadJsonArray method overloads (see 7b7434f)
    The existing methods supports loading JSON values from a path the disk, whereas the new methods allow loading JSON values from a stream.

  • Fixed issue with the "EssentialsWeek.GetStartOfWeek" method returning an incorrect in edge cases (see 5c30341)
    Time calculations with time zones and daylight savings can be a bit tricky. The EssentialsWeek.GetStartOfWeek method would in some cases return an incorrect result by not properly accounting for days daylight savings starts or ends.

v1.1.59

22 Apr 18:04
Compare
Choose a tag to compare

Installation

Install via NuGet - either via the .NET CLI:

dotnet add package Skybrud.Essentials --version 1.1.59

or the NuGet Package Manager:

Install-Package Skybrud.Essentials -Version 1.1.59

Changelog

  • Added [Obsolete] attribute to various extension methods (see 1b234a0)
    The JArrayExtensions, JObjectExtensions and LocationsExtensions classes have been marked as obsolete for a while, but their methods aren't flagged as obsolete when used as extension methods. This release therefore adds [Obsolete] attributes to the individual extension methods similar to those already found on the classes in which they are declared.

  • Fixed misc issues with IXmlNamespaceResolver parameters not being passed on to underlying method calls (see b2133b6)
    For some of the methods in the XPathExtensions class that takes a parameter with an instance of IXmlNamespaceResolver, the parameter wasn't passed on to the underlying method calls, thereby having no effect.

  • Fixed misc issues with HexFormat parameters not being passed on to underlying method calls (see f15813b)
    The SecurityUtils has a number of GetSha256Hash methods, where two of them takes a HexFormat parameter, which wasn't passed on to the underlying method calls.

  • Added WhereList, WhereArray and WhereReadonlyList extension methods for IEnumerable<T> (see 76d8a33)
    These should only be used when converting to a list or array is required.

  • Updated the EnumUtils.TryParseEnum methods to not throw exceptions (see #54 and b820070)
    The general idea with TryParseX methods is that they should fail silently, and then return a boolean value to indicate whether the input value could be parsed. For the TryParseEnum, they would in some cases throw an exception - e.g. if the input string was null. With this commit, they will return false instead and thus fail silently.

  • Better exception handling for EnumUtils.Parse method (see 0e2648f)
    In previous releases, the method would throw an ArgumentNullException regardless of the input string being null or just empty/white space. As of this commit, the method will instead throw the lesser ArgumentException. This matches .NET's behavior, and it also ensures that the exception message matches the actual issue.

  • Added SaveJsonToken to the JsonUtils class (see 4c01d73)
    The class already have SaveJsonObject and SaveJsonArray methods ... and now also SaveJsonToken.

  • Updated the EnumUtils.TryParseEnum to support some edge cases (see 8de688d)
    The implementation would convert the input string to camel case, and then lower case for having a common value for comparing against known values of the target enum type. While the .NET convention is to name these using upper camel case, we should still support when the convention isn't followed (e.g. for some abbreviation and/or numbers, it makes sense to use an underscore). As of this commit, the enum value names are now converted to camel case before any comparisons, thus improving the chances that the parsing is successful.

v1.1.58

18 Feb 15:12
Compare
Choose a tag to compare

Installation

Install via NuGet - either via the .NET CLI:

dotnet add package Skybrud.Essentials --version 1.1.58

or the NuGet Package Manager:

Install-Package Skybrud.Essentials -Version 1.1.58

Changelog

  • Added missing [NotNullWhen(true)] attribute to one of the IsObsolete method overloads (see 34643c8)
    This should make the code analysis happy again.

  • Implemented Extends and Implements extension methods for the Type class (see #49 and c302d28)

  • The two new methods introduces a more "friendly" way to determine whether a type extends or implements another class or interface interface.

  • Made JsonTokenUtils methods public (see #48 and aa3c562)
    The JsonTokenUtils class has been used internally in the package for a while for converting JToken instances into something else. Until now the methods have been internal, but since they have a broader usage than just within the package, they are now public instead.

  • Added extension methods for the Regex class (see #47 and a7e921e)
    Similar to the RegexUtils.IsMatch methods already in the package, IsMatch extension methods are now available for Regex instances.

  • Introduced new GetRequired{Type} extension methods for JObject (see 16a0706)
    This release introduces an alternative to the existing Get{Type} extension methods. While the existing GetString, GetInt32 and similar methods already in the package are designed to somewhat failed silent if the underlying property doesn't exist or the value type doesn't match, the GetRequiredString, GetRequiredInt32 and similar methods will throw an exception if a required value isn't found.

  • Added new Get{Type}Value and GetRequired{Type}Value extension methods for XElement (see b906fb6)
    These methods are intended to replace the existing GetAttributeValue and GetElementValue methods, since the new methods have better naming and also proper support for nullable (reference) types.

v1.1.57

21 Apr 10:10
Compare
Choose a tag to compare

Installation

Install via NuGet - either via the .NET CLI:

dotnet add package Skybrud.Essentials --version 1.1.57

or the NuGet Package Manager:

Install-Package Skybrud.Essentials -Version 1.1.57

Changelog

  • Added ToInvariantString extension method overloads (211e954)
    Classes implementing the IFormattable interface indicates that they can be converted to a string representation using a specified format. The first overload therefore takes an instance of IFormattable and a second parameter for the format.

    From .NET 7 and up, .NET features the StringSyntaxAttribute class, that can be used to specify the available format for the "format" parameter, which then can improve the intellisense. Additional extension method overloads for DateTime, DateTimeOffset and TimeSpan are added as well.

    The extension method overloads are added for all of the current target frameworks. Since StringSyntaxAttribute is only supported from .NET 7 and up, Skybrud.Essentials adds an internal StringSyntaxAttribute class to also support older target frameworks. This should then - in theory - also allow better intellisense for those target frameworks.

  • Updated the EssentialsDate and EssentialsTime classes to implement the IFormattable interface (see 65ae719)
    By implementing the IFormattable interface a format may now be specified when using the EssentialsDate and EssentialsTime classes in string interpolation.

  • Added StringSyntaxAttribute to various format parameters (see 2cd19a5)
    This may help IDEs give a better developer experience by indicating the format to be used.

  • Added Split extension method overloads (see 20eafee)
    The package already contains a number of Split extension methods. With this release, a number of additional overloads have been added with additonal parameters.

  • Introduced new ReadOnlySet class and ReadOnlySet.Empty<T> static method (see fc0614e)
    Similar to the Enumerable.Empty<T> and Array.Empty method in .NET, Skybrud.Essentials now offers a method to get an empty immutable instance of IReadOnlySet. As the IReadOnlySet interface is only supported from .NET 5 and up, the new class and method is also only available for .NET 5 and up, but not .NET Framework and .NET Standard.

  • Added additional RegexUtils.IsMatch extension method overloads (see a5c5148)
    The new overloads support additional scenarios - e.g. with more out parameters.

  • Introduced new static ParseStringList and ParseStringReadOnlyList methods (fbccb0d)
    Supports a few additional scenarios - in additional to the existing ParseStringArray method.

  • EssentialsDate.ToString methods should be culture invariant when no culture is specified (see 782e932)
    This has always been my intention, b

  • Added fallback format when no formatting is specified for the EssentialsDate.ToString and EssentialsTime.ToString methods (see 85316d9)
    Normally when an object is used in string interpolation, the object's parameterless ToString method is called for getting a string representation of the object. But if the object implements the IFormattable interface - as both EssentialsDate and EssentialsTime do now - the ToString(string? format, IFormatProvider? provider) method will be called instead, but with the format parameter being null. In order to not introduce any breaking changes, the EssentialsDate.ToString(string? format, IFormatProvider? provider) and EssentialsTime.ToString(string? format, IFormatProvider? provider) methods have now been updated to return the same value as the parameterless EssentialsDate.ToString() and EssentialsTime.ToString() methods, which are an ISO 8601 formatted date and timestamp respectively.

  • Added ToEssentialsDate and ToEssentialsTime extension methods for both DateTime and DateTimeOffset (d556dc9)
    The extension methods offer the same functionality as the EssentialsDate and EssentialsTime constructors, but may be used in a method chain which is not possible with a constructor.

v1.1.56

06 Feb 08:27
Compare
Choose a tag to compare

Installation

Install via NuGet - either via the .NET CLI:

dotnet add package Skybrud.Essentials --version 1.1.56

or the NuGet Package Manager:

Install-Package Skybrud.Essentials -Version 1.1.56

Changelog

  • The JsonObjectBaseConverter class shouldn't be internal (see 58c34a7)
    Class was copied from a client project, and I didn't notice the class was internal. It should be public in order for it to be used outside of the package.

v1.1.55

05 Feb 22:11
Compare
Choose a tag to compare

Installation

Install via NuGet - either via the .NET CLI:

dotnet add package Skybrud.Essentials --version 1.1.55

or the NuGet Package Manager:

Install-Package Skybrud.Essentials -Version 1.1.55

Changelog

  • Introduced new SelectArray extension method (see e68d941)
    Basically a shorter version of .Select(...).ToArray().

  • Introduced new SelectReadOnlyList extension method (see 744fb20)
    An alternative version of .Select(...).ToArray() or .Select(...).ToList().

  • Introduced new AppendTo extension method (see c6f575c)
    The method allows appending an IEnumerable<T> to a List<T> - eg. via at the end of a method chain.

  • Introduced new ReadOnlyCollection and ReadOnlyList classes (see d8ab691)
    This also introduces the static ReadOnlyCollection.Empty<T> and ReadOnlyList<T> methods as an alternative to Array.Empty<T>.

  • Introduced IsDanish, IsEnglish and IsGerman extension methods for CultureInfo (see 2def2c5)
    Allows checking whether a CultureInfo instance represents either a Danish, English or German language.

  • Introduced new JsonObjectBaseConverter JSON converter (see 6c2cfc1)
    The converter allows converting a JsonObjectBase instance to a JSON string and from a JSON string to a JsonObjectBase instance.

  • Introduced new FirstCharToLower extension method (see d298fdb)
    Replaces the first character of an input string to it's lower case representation.

v1.1.54

13 Dec 22:57
Compare
Choose a tag to compare

Installation

Install via NuGet - either via the .NET CLI:

dotnet add package Skybrud.Essentials --version 1.1.54

or the NuGet Package Manager:

Install-Package Skybrud.Essentials -Version 1.1.54

Changelog

  • Compile constants for .NET 5 and .NET 6 should also apply to .NET 7 and .NET 8 (see #44 and 6fe82aa)
    For the v1.1.53 I added .NET 7 as an additional target framework, but forgot updating the compile constants used throughout the package, so large portions of the package weren't part of v1.1.53 when using the .NET 7 build. This release fixes the compile constants so the missing functionality is now is back.

  • Changed compile constants used in the NameValueCollectionExtensions.cs file and similar files (see 8790b87)
    Prior to this commit, the file content has only been enabled when the NET_FRAMEWORK compile constant is set. While the NameValueCollection class isn't available in all target frameworks, it is available from .NET Standard 2.0 and up as well as .NET 5 and up. To also enabled the file content for these target frameworks, we should instead check against the I_CAN_HAS_NAME_VALUE_COLLECTION compile constant.

  • Added ToTitleCase extension methods (see fc2f736)
    The implementation uses .NET's TextInfo.ToTitleCase method to convert a string to title case.

  • Added additional extension methods for "NameValueCollection" (see a93bfd0 and a68aa06)
    This provides some additional functionality for reading and parsing values from a NameValueCollection and also matches similar named extension methods for other collection.

v1.1.53

03 Nov 16:01
Compare
Choose a tag to compare

Installation

Install via NuGet - either via the .NET CLI:

dotnet add package Skybrud.Essentials --version 1.1.53

or the NuGet package manager:

Install-Package Skybrud.Essentials -Version 1.1.53

Changelog

  • Added .NET 7 as an additional target framework (see 3bc7637)
    This means that the package can start using some of the newer C# features that are specific to .NET 7.

  • Added additional properties to EssentialsTime that exists on DateTimeOffset (see 7887034)
    The following properties were added:

    • Date
    • DateTime
    • LocalDateTime
    • UtcDateTime
    • Microsecond (.NET 7+)
    • Nanosecond (.NET 7+)
    • UtcTicks
  • Added IsSameDay extension methods for DateTime and DateTimeOffset (see e5fed31)
    Similar methods already exist as static utility methods, so they might as well be available as extension methods.

v1.1.52

12 Sep 15:01
Compare
Choose a tag to compare

Installation

Install via NuGet - either via the .NET CLI:

dotnet add package Skybrud.Essentials --version 1.1.52

or the NuGet package manager:

Install-Package Skybrud.Essentials -Version 1.1.52

Changelog

  • Improved the logic for reading from NameValueCollection (see e1c6759)