Releases: skybrud/Skybrud.Essentials
Skybrud.Essentials v1.1.37
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)
TheIso8601Constans.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 theEssentialsTime
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
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 theDate
,DateTimeSeconds
andDateTimeMilliseconds
constants. TheDateFormat
(replaced byDate
) andDateTimeFormat
(replaced byDateTimeSeconds
) are now marked as obsolete. -
Introduced new logic for working with Unix time in milliseconds (see fe79cb5)
New methods were added to theEssentialsTime
andUnixTimeUtils
classes for making working with Unix time more convenient. Changes include:- Marked
EssentialsTime.FromUnixTimestamp
methods as obsolete (as it was replaced byEssentialsTime.FromUnixTimeSeconds
) - Introduced new
EssentialsTime.FromUnixTimeSeconds
methods - Introduced new
EssentialsTime.FromUnixTimeMilliseconds
methods - Introduced new
UnixTimeUtils.FromMilliseconds
methods - Introduced new
UnixTimeUtils.ToMilliseconds
methods
- Marked
-
Introduced new
UnixTimeFormat
enum forUnixTimeConverter
class (see a6837d6)
The JSON converter now supports specifying the format of the converter - eitherUnixTimeFormat.Seconds
(default) orUnixTimeFormat.Milliseconds
. Until now, the converter has only supported converting back and forth between the UNIX timestamp expressed with seconds, but by setting the format toUnixTimeFormat.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 theEssentialsTime
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 byUnixTimeSeconds
) - Introduced new
UnixTimeSeconds
property - Introduced new
UnixTimeMilliseconds
property - Introduced new
ToUnixTimeSeconds
methodty - Introduced new
ToUnixTimeMilliseconds
method
- Introduced new
-
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. TheTryParse(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 likeReflectionUtils.GetVersion(typeof(MyType).Assembly)
, it's now possibly to useReflectionUtils.GetVersion<MyType>()
instead. -
Introduced new
TryParseJsonToken
,TryParseJsonObject
andTryParseJsonArray
method to theJsonUtils
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 theStringUtils.ToHexString
method.
Skybrud.Essentials v1.1.35
Installation
Install the NuGet package - either via the .NET CLI:
dotnet add package Skybrud.Essentials --version 1.1.35
or the NuGet package manager:
Install-Package Skybrud.Essentials -Version 1.1.35
Changelog
-
Introduced new
StringUtils.ToHexString
utility methods (see 4f35fda)
TheToHexString
methods allow converting a byte array to a corresponding HEX string. TheToHexString(byte[])
method will return the HEX string in lower case, whereas theToHexString(byte[], HexFormat)
method overload allows specifying eitherHexFormat.LowerCase
orHexFormat.UpperCase
for the second parameter. -
Introduced new
StringExtensions.ToHexString
extension methods (see 4f35fda)
Similar to the staticStringUtils.ToHexString
utility methods, theStringExtensions.ToHexString
offer the same functionality but as extension methods. -
Introduced new
SecurityUtils.GetHmacSha1Hash
methods (see b20f76b)
This introduces four new method signatures for getting the HMACSHA1 hash of a given key and value. -
Introduced new
SecurityUtils.GetHmacSha256Hash
methods (see b20f76b)
This introduces four new method signatures for getting the HMACSHA256 hash of a given key and value. -
Introduced new
SecurityUtils.GetHmacSha512Hash
methods (see b20f76b)
This introduces four new method signatures for getting the HMACSHA512 hash of a given key and value. -
Added new
SecurityUtils.GetMd5Hash
method overloads (see b20f76b)
This introduces two new method overloads with aHexFormat
parameter for controlling the case of the returned hash. -
Added new
SecurityUtils.GetSha1Hash
method overloads (see b20f76b)
This introduces two new method overloads with aHexFormat
parameter for controlling the case of the returned hash. -
Added new
SecurityUtils.GetSha256Hash
method overloads (see b20f76b)
This introduces two new method overloads with aHexFormat
parameter for controlling the case of the returned hash. -
Added new
SecurityUtils.Get512Hash
method overloads (see b20f76b)
This introduces two new method overloads with aHexFormat
parameter for controlling the case of the returned hash.
Skybrud.Essentials v1.1.34
Installation
Install the NuGet package - either via the .NET CLI:
dotnet add package Skybrud.Essentials --version 1.1.34
or the NuGet package manager:
Install-Package Skybrud.Essentials -Version 1.1.34
Changelog
- Added generic overloads for the
StringExtensions.Join
methods (see 28f074a)
The two methods aren't really that useful if not generic. The two existing methods should have been generic in the first place, but are now kept for backwards compatibility.
Skybrud.Essentials v1.1.33
Installation
Changelog
-
Added
StringExtensions.ToBoolean
method overload (see d78f58d)
The class already has theParseBoolean
method, but this being an extension method, the name should instead ofToBoolean
. To ensure backwards compatibility, theParseBoolean
method is now marked as obsolete, and a newToBoolean
with the same implementation is added instead. -
Introduced new
StringExtensions.IfNullOrWhiteSpace
extension methods (see 3ff3b92)
For the first method, if it's passed a value that is eithernull
, empty or white space, the specifiedfallback
value is returned instead.The second method works in a similar way, but supports a
fallback
function instead. This is useful if the fallback value requires expensive lookups, as the function is only invoked when needed. -
Introduced new
StringExtensions.NullIfWhiteSpace
extension methods (see 696732c)
If the method is passed a value that is either empty or white space, a null value is returned; otherwise the input value is returned untouched.
Skybrud.Essentials v1.1.32
Installation
Changelog
-
Fixed issue with
EssentialsDate.IsWeekend
calling the wrong utility method (see 1ac081d)
This is the same as the issue reported in #16, but in a different, but similar part of the code. -
Added new
IsTomorrow
andIsYesterday
properties to theEssentialsDate
class (see aa23c9a)
TheEssentialsTime
class already has similar properties, so makes sense to add matching properties for theEssentialsDate
class. -
Introduced new
ToHtmlString
extension method (see ee365ec)
This release adds aToHtmlString
extension method which can be used for turning astring
into anIHtmlString
, which is in particular useful for method chaining. -
Added missing
this
keyword for string extension methods (see 7656d6b)
As the affected method has always been intended as being extension methods, it's a bug that they were missing thethis
keyword. -
Added logic for converting a
NameValueCollection
to an URL encoded string and back again (see 41b9338)
TheStringUtils
class now contains a staticToUrlEncocedString
utility method for convertingNameValueCollection
instances to an URL encoded string.In a similar way, the
StringExtensions
class now contains aToUrlEncodedString
extension method for converting to an URL encoded string, and aToNameValueCollection
extension method for converting an URL encoded string back to aNameValueCollection
instance. -
Introduced new
StringJsonConverter
andNameValueCollectionJsonConverter
classes (see c7fb51e)
The newStringJsonConverter
class replaces theToStringJsonConverter
class, and serializes any .NET type to it's corresponding string representation. ForNameValueCollection
, this means an URL encoded string, but for any other types, the value will be the same as calling theToString
method with an invariant culture. Generally the converter doesn't support deserialization, as most types can't be converted from a string to an object. But specifically, the converter currently supports deserializing to back to aNameValueCollection
instance or any enum type.The
NameValueCollectionJsonConverter
class serializes aNameValueCollection
to a correspondingJObject
, where each key value pair in the value collection is added as properties and in the resultingJObject
. The converter also supports deserializing aJObject
back to a correspondingNameValueCollection
. -
Introduced new
Truncate
utility and extension methods (see 509c92e)
The methods allows truncating a given string to a maximum length. This is possible either via the staticStringUtils.Truncate
utility method, or theStringExtensions.Truncate
extension method. -
Added
MinValue
andMaxValue
fields to theEssentialsDate
class (see ab27666)
Similar toDateTime.MinValue
andDateTime.MaxValue
, theEssentialsDate
now contains aEssentialsDate.MinValue
field and aEssentialsDate.MaxValue
field respectively. This can be useful when comparing instance ofEssentialsDate
. -
Introduced new
GuidUtils
andGuidExtensions
classes (see 990a7d6 and #17)
The two classes contains various logic for working with GUIDs, either as static utility methods or as extension methods. This includes methods for converting GUIDs back and forth between their numeric representations, as as well as extension methods for validating GUIDs. -
Added constructor overload to the
EssentialsPartialDate
class (see 1cdea40 and #14)
The new constructor takes an instance ofEssentialsTime
as it's only parameter.
Skybrud.Essentials v1.1.31
Installation
Changelog
-
Introduced new
GetFlags
enum extension method (see a8fdbd2)
The newGetFlags
method takes a enum value with the[Flags]
attribute and returns each flag individual instances. -
Introduced new utility and extension methods for converting a collection of enums to a given case (see a8fdbd2)
The package already contains methods for converting a single enum value to a textual representation using given case. The new methods takes a collection of enum values, and returns a comma separated string with the textual representation of each enum value in the collection. -
Introduced new
ToHashSet
extension methods (see e6816e3)
The two extension methods allow for method chaining, which may make code more readable - opposed to having to call theHashSet<T>
constructor manually. -
Added new
EnumerableExtensions.GetReverse
extension method for getting the opposite value of aSortOrder
value (see 6b078ee)
Allows turningSortOrder.Ascending
intoSortOrder.Descending
, orSortOrder.Descending
intoSortOrder.Ascending
. -
Introduced new StringUtils.FirstWithValue utility methods (see 0d434c9 and de4e191)
Both overloads return the first value that is not either null, empty or whitespace. -
Introduced new
StringExtensions.Join
extension methods for theSystem.String
class (see 2fb0d42)
Using the extension methods instead of thestring.Join
method allows for method chaining. -
Fixed indices typo for
StringUtils.ToPlural
andStringUtils.ToSingular
methods (see e5f04b1)
The word indices was incorrectly spelled indeces - also in the unit tests, resulting in this issue going unnoticed until now. -
Introduced
StringUtils.ToPlural
method overloads (see d0965fb)
The two new methods allow specifying either a count or a boolean to indicate whether the returned value should be plural or singular.
Skybrud.Essentials v1.1.30
Installation
Changelog
-
Added
DaySuffix
property to theEssentialsDateTime
class (see 7c5ac10)
TheEssentialsTime
class already has a similar property, so might as well add one for theEssentialsDateTime
class. -
Fixed issue with
EssentialsTime.IsWeekend
andEssentialsDateTime.IsWeekend
properties should call the correct utility method (see d6b11ea and #16)
The two properties wrongly called theTimeUtils.IsLeapYear
utility method instead ofTimeUtils.IsWeekend
. Thanks to @enkelmedia for reporting 👍 -
Improved the code base behind
GetBoolean
JSON extension methods (see c8593d0)- Introduced
JsonTokenUtils
to avoid duplicate code throughout the package - Added
GetBoolean
overloads with afallback
parameter - Added new
TryGetBoolean
extension methods - Added unit tests to ensure changes does work as intended
- Introduced
-
Added
GetMd5Guid
methods to theSecurityUtils
class (see ca23b5a)
Sometimes it may be useful to have a MD5 hash formatted as a GUID.
Skybrud.Essentials v1.1.29
Installation
Changelog
-
Introduced new static methods and extension methods for working with enums (see 79a6f6b)
This release introduces theToEnum
andToInt32
extension methods in the EnumExtensions class. -
Introduced new
ToStringArray
extension methods (see f0b1148)
The firstToStringArray
method takes a string and splits it's into an array using a predefined list of separators. The secondToStringArray
method has a second parameter for specifying the separator to be used. -
EnumUtils.TryParseEnum
shouldn't fail if the input isnull
or empty (see 0952e0c and #13)
Passingnull
or an empty string to the method shouldn't trigger an exception, but instead cause to method to returnfalse
; indicating that the parsing failed.
Skybrud.Essentials v1.1.28
Installation
Changelog
-
StripHtml
methods shouldn't break onnull
values (see 3bda45b, e5d6528)
The twoStripHtml
methods in theStringUtils
class would break if passed anull
value. With this release, the two methods will now returnnull
if the input string is anull
value. -
Added
ReplaceLineBreaks
extension method (see 2ad8dd1)
The previous release added aReplaceLineBreaks
method in theStringUtils
class. With this release, a similarReplaceLineBreaks
extension method is now also available via theStringExtensions
class. -
Extended the implementation of the
EssentialsMonth
class (see 2bd860a)
The class has been updated with the following changes:- Introduced new
GetPrevious
member methods for getting the previous month - Introduced new
GetNext
member methods for getting the next month - Introduced new
GetMonths
static methods for getting an array of multiple months
- Introduced new