Releases: skybrud/Skybrud.Essentials
v1.1.64
Installation
Install via NuGet - either via the .NET CLI:
dotnet add package Skybrud.Essentials --version 1.1.64
or the NuGet Package Manager:
Install-Package Skybrud.Essentials -Version 1.1.64
Changelog
v1.1.63
Installation
Install via NuGet - either via the .NET CLI:
dotnet add package Skybrud.Essentials --version 1.1.63
or the NuGet Package Manager:
Install-Package Skybrud.Essentials -Version 1.1.63
Changelog
-
Added misc utility and extension methods for converting string values into corresponding
HashSet<>values (see 22cbf8b)
Similar to the existingStringUtils.Parse{Type}ArrayandStringUtils.Parse{Type}List, similarStringUtils.Parse{Type}Setmethods are now available with this release. -
Added .NET 8 and .NET 10 as additional target frameworks (see 22da437)
These are LTS releases of .NET and as such should be the primary target frameworks for this package. Ideally all EOL target frameworks should be removed, but as this would be a breaking change, this will be addressed in av1.2.0or2.0.0release instead.
v1.1.62
Installation
Install via NuGet - either via the .NET CLI:
dotnet add package Skybrud.Essentials --version 1.1.62
or the NuGet Package Manager:
Install-Package Skybrud.Essentials -Version 1.1.62
Changelog
- Fixed issue with
EssentialsTime.FromTicks(see 109a493)
Two of the method overloads would internally parse the ticks into aDateTimeinstance, but not specify aKind, in which case this falls back toUnspecified, thereby creating a lot of uncertainty when converting back and forth between time zones. With this commit, the two method overloads will instead use parse the ticks into aDateTimeOffsetrelative to UTC, and then convert to the time zone specified by the user.
v1.1.61
Installation
Install via NuGet - either via the .NET CLI:
dotnet add package Skybrud.Essentials --version 1.1.61
or the NuGet Package Manager:
Install-Package Skybrud.Essentials -Version 1.1.61
Changelog
-
Fixed issue with
ToInvariantStringextension methods (see a01b5f1)
For the overloading taking anIFormattable, we shouldn't usestring.Formatas the format is directly for theIFormattable. -
Fixed misc issues when getting values from
JArray(see 63c9245)
The idea behind these methods is that they should to call, meaning if you callGetInt32(0)and the item isn't found, or the value cannot be converted to a 32-bit integer, the method should return a default value instead of throwing an exception. As this wasn't the case, the implementation has been updated to reflect this.- added check for min and max values
- no longer tries to cast values
- added additional
GetTypeandTryGetTypeextension methods - added lots of unit tests
- etc.
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
GetNativeLanguageNameextension method forCultureInfo(see 8577b69)
ACultureInfomay 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, theCultureInfowill have a reference to parentCultureInfothat 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
ExtendsandImplementsmethod overloads (see 9a570f2)
Abstract or static classes can't be used as a generic type parameter, so the new method overloads take aTypeinstance 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
IConfigurationvalues (see b955d44)
This makes manual parsing ofIConfigurationinstances a bit easier. -
Added
ParseJsonObjectandLoadJsonObjectmethod overloads to theJsonUtilsclass (see 43dca9a)
The new method overloads allow specifying aTypeparameter instead of a generic type parameter. -
Introduced new
StreamUtilsclass (c19a61f)
The class contains various utility/helper methods from converting to a stream and back again. -
Introduced new
JsonUtils.LoadJsonToken,JsonUtils.LoadJsonObject, andJsonUtils.LoadJsonArraymethod 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.GetStartOfWeekmethod 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,JObjectExtensionsandLocationsExtensionsclasses 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
IXmlNamespaceResolverparameters not being passed on to underlying method calls (see b2133b6)
For some of the methods in theXPathExtensionsclass 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
HexFormatparameters not being passed on to underlying method calls (see f15813b)
TheSecurityUtilshas a number ofGetSha256Hashmethods, where two of them takes aHexFormatparameter, which wasn't passed on to the underlying method calls. -
Added
WhereList,WhereArrayandWhereReadonlyListextension methods forIEnumerable<T>(see 76d8a33)
These should only be used when converting to a list or array is required. -
Updated the
EnumUtils.TryParseEnummethods to not throw exceptions (see #54 and b820070)
The general idea withTryParseXmethods 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.Parsemethod (see 0e2648f)
In previous releases, the method would throw anArgumentNullExceptionregardless 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
SaveJsonTokento theJsonUtilsclass (see 4c01d73)
The class already haveSaveJsonObjectandSaveJsonArraymethods ... and now alsoSaveJsonToken. -
Updated the
EnumUtils.TryParseEnumto 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 theIsObsoletemethod overloads (see 34643c8)
This should make the code analysis happy again. -
Implemented
ExtendsandImplementsextension methods for theTypeclass (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
JsonTokenUtilsmethods public (see #48 and aa3c562)
TheJsonTokenUtilsclass has been used internally in the package for a while for convertingJTokeninstances 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
Regexclass (see #47 and a7e921e)
Similar to theRegexUtils.IsMatchmethods already in the package,IsMatchextension methods are now available forRegexinstances. -
Introduced new
GetRequired{Type}extension methods forJObject(see 16a0706)
This release introduces an alternative to the existingGet{Type}extension methods. While the existingGetString,GetInt32and 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,GetRequiredInt32and similar methods will throw an exception if a required value isn't found. -
Added new
Get{Type}ValueandGetRequired{Type}Valueextension methods forXElement(see b906fb6)
These methods are intended to replace the existingGetAttributeValueandGetElementValuemethods, 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
ToInvariantStringextension method overloads (211e954)
Classes implementing theIFormattableinterface indicates that they can be converted to a string representation using a specified format. The first overload therefore takes an instance ofIFormattableand a second parameter for the format.From .NET 7 and up, .NET features the
StringSyntaxAttributeclass, that can be used to specify the available format for the "format" parameter, which then can improve the intellisense. Additional extension method overloads forDateTime,DateTimeOffsetandTimeSpanare added as well.The extension method overloads are added for all of the current target frameworks. Since
StringSyntaxAttributeis only supported from .NET 7 and up, Skybrud.Essentials adds an internalStringSyntaxAttributeclass to also support older target frameworks. This should then - in theory - also allow better intellisense for those target frameworks. -
Updated the
EssentialsDateandEssentialsTimeclasses to implement theIFormattableinterface (see 65ae719)
By implementing theIFormattableinterface a format may now be specified when using theEssentialsDateandEssentialsTimeclasses in string interpolation. -
Added
StringSyntaxAttributeto variousformatparameters (see 2cd19a5)
This may help IDEs give a better developer experience by indicating the format to be used. -
Added
Splitextension method overloads (see 20eafee)
The package already contains a number ofSplitextension methods. With this release, a number of additional overloads have been added with additonal parameters. -
Introduced new
ReadOnlySetclass andReadOnlySet.Empty<T>static method (see fc0614e)
Similar to theEnumerable.Empty<T>andArray.Emptymethod in .NET, Skybrud.Essentials now offers a method to get an empty immutable instance ofIReadOnlySet. As theIReadOnlySetinterface 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.IsMatchextension method overloads (see a5c5148)
The new overloads support additional scenarios - e.g. with more out parameters. -
Introduced new static
ParseStringListandParseStringReadOnlyListmethods (fbccb0d)
Supports a few additional scenarios - in additional to the existingParseStringArraymethod. -
EssentialsDate.ToStringmethods 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.ToStringandEssentialsTime.ToStringmethods (see 85316d9)
Normally when an object is used in string interpolation, the object's parameterlessToStringmethod is called for getting a string representation of the object. But if the object implements theIFormattableinterface - as bothEssentialsDateandEssentialsTimedo now - theToString(string? format, IFormatProvider? provider)method will be called instead, but with theformatparameter 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
ToEssentialsDateandToEssentialsTimeextension methods for bothDateTimeandDateTimeOffset(d556dc9)
The extension methods offer the same functionality as theEssentialsDateandEssentialsTimeconstructors, 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
JsonObjectBaseConverterclass 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.