Releases: skybrud/Skybrud.Essentials
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.ToHexStringutility methods (see 4f35fda)
TheToHexStringmethods 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.LowerCaseorHexFormat.UpperCasefor the second parameter. -
Introduced new
StringExtensions.ToHexStringextension methods (see 4f35fda)
Similar to the staticStringUtils.ToHexStringutility methods, theStringExtensions.ToHexStringoffer the same functionality but as extension methods. -
Introduced new
SecurityUtils.GetHmacSha1Hashmethods (see b20f76b)
This introduces four new method signatures for getting the HMACSHA1 hash of a given key and value. -
Introduced new
SecurityUtils.GetHmacSha256Hashmethods (see b20f76b)
This introduces four new method signatures for getting the HMACSHA256 hash of a given key and value. -
Introduced new
SecurityUtils.GetHmacSha512Hashmethods (see b20f76b)
This introduces four new method signatures for getting the HMACSHA512 hash of a given key and value. -
Added new
SecurityUtils.GetMd5Hashmethod overloads (see b20f76b)
This introduces two new method overloads with aHexFormatparameter for controlling the case of the returned hash. -
Added new
SecurityUtils.GetSha1Hashmethod overloads (see b20f76b)
This introduces two new method overloads with aHexFormatparameter for controlling the case of the returned hash. -
Added new
SecurityUtils.GetSha256Hashmethod overloads (see b20f76b)
This introduces two new method overloads with aHexFormatparameter for controlling the case of the returned hash. -
Added new
SecurityUtils.Get512Hashmethod overloads (see b20f76b)
This introduces two new method overloads with aHexFormatparameter 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.Joinmethods (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.ToBooleanmethod overload (see d78f58d)
The class already has theParseBooleanmethod, but this being an extension method, the name should instead ofToBoolean. To ensure backwards compatibility, theParseBooleanmethod is now marked as obsolete, and a newToBooleanwith the same implementation is added instead. -
Introduced new
StringExtensions.IfNullOrWhiteSpaceextension methods (see 3ff3b92)
For the first method, if it's passed a value that is eithernull, empty or white space, the specifiedfallbackvalue is returned instead.The second method works in a similar way, but supports a
fallbackfunction instead. This is useful if the fallback value requires expensive lookups, as the function is only invoked when needed. -
Introduced new
StringExtensions.NullIfWhiteSpaceextension 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.IsWeekendcalling 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
IsTomorrowandIsYesterdayproperties to theEssentialsDateclass (see aa23c9a)
TheEssentialsTimeclass already has similar properties, so makes sense to add matching properties for theEssentialsDateclass. -
Introduced new
ToHtmlStringextension method (see ee365ec)
This release adds aToHtmlStringextension method which can be used for turning astringinto anIHtmlString, which is in particular useful for method chaining. -
Added missing
thiskeyword 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 thethiskeyword. -
Added logic for converting a
NameValueCollectionto an URL encoded string and back again (see 41b9338)
TheStringUtilsclass now contains a staticToUrlEncocedStringutility method for convertingNameValueCollectioninstances to an URL encoded string.In a similar way, the
StringExtensionsclass now contains aToUrlEncodedStringextension method for converting to an URL encoded string, and aToNameValueCollectionextension method for converting an URL encoded string back to aNameValueCollectioninstance. -
Introduced new
StringJsonConverterandNameValueCollectionJsonConverterclasses (see c7fb51e)
The newStringJsonConverterclass replaces theToStringJsonConverterclass, 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 theToStringmethod 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 aNameValueCollectioninstance or any enum type.The
NameValueCollectionJsonConverterclass serializes aNameValueCollectionto a correspondingJObject, where each key value pair in the value collection is added as properties and in the resultingJObject. The converter also supports deserializing aJObjectback to a correspondingNameValueCollection. -
Introduced new
Truncateutility and extension methods (see 509c92e)
The methods allows truncating a given string to a maximum length. This is possible either via the staticStringUtils.Truncateutility method, or theStringExtensions.Truncateextension method. -
Added
MinValueandMaxValuefields to theEssentialsDateclass (see ab27666)
Similar toDateTime.MinValueandDateTime.MaxValue, theEssentialsDatenow contains aEssentialsDate.MinValuefield and aEssentialsDate.MaxValuefield respectively. This can be useful when comparing instance ofEssentialsDate. -
Introduced new
GuidUtilsandGuidExtensionsclasses (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
EssentialsPartialDateclass (see 1cdea40 and #14)
The new constructor takes an instance ofEssentialsTimeas it's only parameter.
Skybrud.Essentials v1.1.31
Installation
Changelog
-
Introduced new
GetFlagsenum extension method (see a8fdbd2)
The newGetFlagsmethod 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
ToHashSetextension 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.GetReverseextension method for getting the opposite value of aSortOrdervalue (see 6b078ee)
Allows turningSortOrder.AscendingintoSortOrder.Descending, orSortOrder.DescendingintoSortOrder.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.Joinextension methods for theSystem.Stringclass (see 2fb0d42)
Using the extension methods instead of thestring.Joinmethod allows for method chaining. -
Fixed indices typo for
StringUtils.ToPluralandStringUtils.ToSingularmethods (see e5f04b1)
The word indices was incorrectly spelled indeces - also in the unit tests, resulting in this issue going unnoticed until now. -
Introduced
StringUtils.ToPluralmethod 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
DaySuffixproperty to theEssentialsDateTimeclass (see 7c5ac10)
TheEssentialsTimeclass already has a similar property, so might as well add one for theEssentialsDateTimeclass. -
Fixed issue with
EssentialsTime.IsWeekendandEssentialsDateTime.IsWeekendproperties should call the correct utility method (see d6b11ea and #16)
The two properties wrongly called theTimeUtils.IsLeapYearutility method instead ofTimeUtils.IsWeekend. Thanks to @enkelmedia for reporting 👍 -
Improved the code base behind
GetBooleanJSON extension methods (see c8593d0)- Introduced
JsonTokenUtilsto avoid duplicate code throughout the package - Added
GetBooleanoverloads with afallbackparameter - Added new
TryGetBooleanextension methods - Added unit tests to ensure changes does work as intended
- Introduced
-
Added
GetMd5Guidmethods to theSecurityUtilsclass (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 theToEnumandToInt32extension methods in the EnumExtensions class. -
Introduced new
ToStringArrayextension methods (see f0b1148)
The firstToStringArraymethod takes a string and splits it's into an array using a predefined list of separators. The secondToStringArraymethod has a second parameter for specifying the separator to be used. -
EnumUtils.TryParseEnumshouldn't fail if the input isnullor empty (see 0952e0c and #13)
Passingnullor 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
-
StripHtmlmethods shouldn't break onnullvalues (see 3bda45b, e5d6528)
The twoStripHtmlmethods in theStringUtilsclass would break if passed anullvalue. With this release, the two methods will now returnnullif the input string is anullvalue. -
Added
ReplaceLineBreaksextension method (see 2ad8dd1)
The previous release added aReplaceLineBreaksmethod in theStringUtilsclass. With this release, a similarReplaceLineBreaksextension method is now also available via theStringExtensionsclass. -
Extended the implementation of the
EssentialsMonthclass (see 2bd860a)
The class has been updated with the following changes:- Introduced new
GetPreviousmember methods for getting the previous month - Introduced new
GetNextmember methods for getting the next month - Introduced new
GetMonthsstatic methods for getting an array of multiple months
- Introduced new
Skybrud.Essentials v1.1.27
Installation
Changelog
-
Introduced the
StringUtils.ReplaceLineBreaksmethod (see 50deea5)
The method replaces carriage return and new line characters (\r\n,\r, and\n) with HTML line breaks<br />. -
Added more method overloads for
ReflectionUtilsandReflectionExtensions(see 18c9c0c, 0f93924 and ddce8ae)
With this release, more overloads of theHasCustomAttribute,HasCustomAttributes,GetCustomAttribute,GetCustomAttributeandIsObsoletemethods are now available.
Skybrud.Essentials v1.1.26
Installation
Changelog
-
Added support for Swatch Internet Time (see 32c1483, aeccd83, e3a177d, 00820d3)
While holding little use today, Swatch Internet Time is an alternative way to describe the time of day using beats - a whole day being 1000 beats. A single beat equals 86.4 seconds. -
Introduced new
Iso8601UtilsandIso8601Constantsclasses (b018ee6, 9dee41d)
The new classes separate ISO 8601 related logic into it's own namespace and classes, hopefully making the classes easier to understand. Similar ISO 8601 related methods in theTimeUtilsclass have now been marked as obsolete. -
Introduced new
Rfc822Utilsclass (see 9dee41d)
The new class separates a lot of the RFC 822 related logic into it's own class. The methods in theTimeUtilsclass still exist, but are now marked as obsolete in favor of the methods in the new class. -
Introduced new
Rfc2822Utilsclass (see 9dee41d)
The new class separates a lot of the RFC 2822 related logic into it's own class. The methods in theTimeUtilsclass still exist, but are now marked as obsolete in favor of the methods in the new class. -
Introduced new
UnixTimeUtilsclass (see 83af7a4)
The new class separates a lot of the Unix time related logic into it's own class. The methods in theTimeUtilsclass still exist, but are now marked as obsolete in favor of the methods in the new class. -
Introduced new
EssentialsPeriodclass (see 3267181, a29d1b4)
The new class describes a period of time, identified by two instances ofEssentialsTimefor the start date and end date respectively. -
Introduced static
FromTicksmethods in theEssentialsTimeclass (see c172e85)
TheEssentialsTimeclass now support creating a new instance from a specified amount of ticks - similar to theFromTicksmethods inDateTimeandDateTimeOffsetclasses. -
The
EssentialsDateTimeclass is now marked as obsolete (see 9dee41d)
The class has been around in this package for quite some time, but was superseded by theEssentialsTimeclass a while back, as the latter wraps an instance ofDateTimeOffsetinstead ofDateTime.It's still possible to use the
EssentialsDateTime, but it's recommended to use theEssentialsTimeclass instead. -
Introduced
EssentialsMonthclass (see 15351ca)
Inheriting from theEssentialsPeriodclass,EssentialsMonthcan be used to represent a specific month, and provides some additional month-specific properties compared to the properties found in the base class. -
Introduced
EssentialsYearclass (see db3cd86)
Inheriting from theEssentialsPeriodclass,EssentialsYearcan be used to represent a specific year, and provides some additional year-specific properties compared to the properties found in the base class. -
EssentialsTimeoperator overloads from Unix timestamp should be avoided (see b06f9ab)
The operators seem to lead to more confusion than they do good, so they have now been marked as obsolete, and will be removed in a future release. -
Introduced new
JObjectExtensions.GetGuidArrayextension method (see 0a4c5c9)
The new extension method allows getting an array ofGuid's from aJObjectproperty. The method works similar to the other extension methods in the same class, but contains a bit more error handling.