Releases: skybrud/Skybrud.Essentials
v1.2.0-alpha001
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
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 forCultureInfo
(see 8577b69)
ACultureInfo
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, theCultureInfo
will have a reference to parentCultureInfo
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
andImplements
method overloads (see 9a570f2)
Abstract or static classes can't be used as a generic type parameter, so the new method overloads take aType
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 ofIConfiguration
instances a bit easier. -
Added
ParseJsonObject
andLoadJsonObject
method overloads to theJsonUtils
class (see 43dca9a)
The new method overloads allow specifying aType
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
, andJsonUtils.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. TheEssentialsWeek.GetStartOfWeek
method would in some cases return an incorrect result by not properly accounting for days daylight savings starts or ends.
v1.1.59
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)
TheJArrayExtensions
,JObjectExtensions
andLocationsExtensions
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 theXPathExtensions
class that takes a parameter with an instance ofIXmlNamespaceResolver
, 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)
TheSecurityUtils
has a number ofGetSha256Hash
methods, where two of them takes aHexFormat
parameter, which wasn't passed on to the underlying method calls. -
Added
WhereList
,WhereArray
andWhereReadonlyList
extension methods forIEnumerable<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 withTryParseX
methods is that they should fail silently, and then return a boolean value to indicate whether the input value could be parsed. For theTryParseEnum
, 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 anArgumentNullException
regardless of the input string being null or just empty/white space. As of this commit, the method will instead throw the lesserArgumentException
. This matches .NET's behavior, and it also ensures that the exception message matches the actual issue. -
Added
SaveJsonToken
to theJsonUtils
class (see 4c01d73)
The class already haveSaveJsonObject
andSaveJsonArray
methods ... and now alsoSaveJsonToken
. -
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
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 theIsObsolete
method overloads (see 34643c8)
This should make the code analysis happy again. -
Implemented
Extends
andImplements
extension methods for theType
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)
TheJsonTokenUtils
class has been used internally in the package for a while for convertingJToken
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 theRegexUtils.IsMatch
methods already in the package,IsMatch
extension methods are now available forRegex
instances. -
Introduced new
GetRequired{Type}
extension methods forJObject
(see 16a0706)
This release introduces an alternative to the existingGet{Type}
extension methods. While the existingGetString
,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, theGetRequiredString
,GetRequiredInt32
and similar methods will throw an exception if a required value isn't found. -
Added new
Get{Type}Value
andGetRequired{Type}Value
extension methods forXElement
(see b906fb6)
These methods are intended to replace the existingGetAttributeValue
andGetElementValue
methods, since the new methods have better naming and also proper support for nullable (reference) types.
v1.1.57
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 theIFormattable
interface indicates that they can be converted to a string representation using a specified format. The first overload therefore takes an instance ofIFormattable
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 forDateTime
,DateTimeOffset
andTimeSpan
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 internalStringSyntaxAttribute
class to also support older target frameworks. This should then - in theory - also allow better intellisense for those target frameworks. -
Updated the
EssentialsDate
andEssentialsTime
classes to implement theIFormattable
interface (see 65ae719)
By implementing theIFormattable
interface a format may now be specified when using theEssentialsDate
andEssentialsTime
classes in string interpolation. -
Added
StringSyntaxAttribute
to variousformat
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 ofSplit
extension methods. With this release, a number of additional overloads have been added with additonal parameters. -
Introduced new
ReadOnlySet
class andReadOnlySet.Empty<T>
static method (see fc0614e)
Similar to theEnumerable.Empty<T>
andArray.Empty
method in .NET, Skybrud.Essentials now offers a method to get an empty immutable instance ofIReadOnlySet
. As theIReadOnlySet
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
andParseStringReadOnlyList
methods (fbccb0d)
Supports a few additional scenarios - in additional to the existingParseStringArray
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
andEssentialsTime.ToString
methods (see 85316d9)
Normally when an object is used in string interpolation, the object's parameterlessToString
method is called for getting a string representation of the object. But if the object implements theIFormattable
interface - as bothEssentialsDate
andEssentialsTime
do now - theToString(string? format, IFormatProvider? provider)
method will be called instead, but with theformat
parameter being null. In order to not introduce any breaking changes, theEssentialsDate.ToString(string? format, IFormatProvider? provider)
andEssentialsTime.ToString(string? format, IFormatProvider? provider)
methods have now been updated to return the same value as the parameterlessEssentialsDate.ToString()
andEssentialsTime.ToString()
methods, which are an ISO 8601 formatted date and timestamp respectively. -
Added
ToEssentialsDate
andToEssentialsTime
extension methods for bothDateTime
andDateTimeOffset
(d556dc9)
The extension methods offer the same functionality as theEssentialsDate
andEssentialsTime
constructors, but may be used in a method chain which is not possible with a constructor.
v1.1.56
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
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 anIEnumerable<T>
to aList<T>
- eg. via at the end of a method chain. -
Introduced new
ReadOnlyCollection
andReadOnlyList
classes (see d8ab691)
This also introduces the staticReadOnlyCollection.Empty<T>
andReadOnlyList<T>
methods as an alternative toArray.Empty<T>
. -
Introduced
IsDanish
,IsEnglish
andIsGerman
extension methods forCultureInfo
(see 2def2c5)
Allows checking whether aCultureInfo
instance represents either a Danish, English or German language. -
Introduced new
JsonObjectBaseConverter
JSON converter (see 6c2cfc1)
The converter allows converting aJsonObjectBase
instance to a JSON string and from a JSON string to aJsonObjectBase
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
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 thev1.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 ofv1.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 theNET_FRAMEWORK
compile constant is set. While theNameValueCollection
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 theI_CAN_HAS_NAME_VALUE_COLLECTION
compile constant. -
Added
ToTitleCase
extension methods (see fc2f736)
The implementation uses .NET'sTextInfo.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 aNameValueCollection
and also matches similar named extension methods for other collection.
v1.1.53
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 onDateTimeOffset
(see 7887034)
The following properties were added:Date
DateTime
LocalDateTime
UtcDateTime
Microsecond
(.NET 7+)Nanosecond
(.NET 7+)UtcTicks
-
Added
IsSameDay
extension methods forDateTime
andDateTimeOffset
(see e5fed31)
Similar methods already exist as static utility methods, so they might as well be available as extension methods.