Thi is a big and long-awaited release with a focus on performance.
A lot of was around the Currency type: should it be a class or a struct? We choose to keep Currency a struct, so Money type only exist of structs (Decimal and Currency), but it was too big to be a struct, so we trimmed it down to its essence. The rest we moved to a new type CurrencyInfo, which is a record class.
This and the new features in .NET resulted into overall performance improvement on:
- creation of currency (32x faster) and money (20x faster)
- smaller footprint and memory allocation (30x less allocations)
- faster operations, formatting, and parsing
Added
- ISO 4217 Amendment Number 170 VED/926
- ISO 4217 Amendment Number 171 SLE/925 SLL/694
- ISO 4217 Amendment Number 172 SLL/694
- ISO 4217 Amendment Number 174 HRK/191
- ISO 4217 Amendment Number 176 ANG/532 XCG/532
- ISO 4217 Amendment Number 178 CUC/931 CUP/192
- System.Text.Json serialization support
- Added CurrencyInfo to provide information about a currency and acts as an IFormatProvider. It implicitly cast
to Currency. - Support for .NET 9.0, .NET 8.0, .NET Standard 2.0 and .NET Standard 2.1
- Support for OLE Automation Currency conversion using ToOACurrency() and FromOACurrency()
- Add support for Generic Math
- Add Parsing for
ReadOnlySpan<char>
- Formatting added format L for currency format using full english name (was format F)
- Added InternationalSymbol to CurrencyInfo (Symbol:
$
, InternationalSymbol:US$
) - Added AlternativeSymbols to CurrencyInfo
- Added NumericCode to CurrencyInfo. This is a three-digit code number as string (like '034')
- Added MinimalAmount to CurrencyInfo. This is the minimal amount the currency can be increased or decreased.
Changed
- JSON Serialization format is changed from
{ "Cost": {"Amount":1.23,"Currency":"USD"} }
to{ "Cost":"USD 1.23" }
. This is a breaking change for JSON serialization, but deserialization of the old format is supported for migration purposes (only for System.Text.Json, not Newtonsoft.Json!). - XML Serialization format is change from
<Money Amount="765.43" Currency="USD" />
to<Money Currency="USD">765.43</Money>
. This is a breaking change for XML serialization, but deserialization of the old format is supported for migration purposes. - Currency is now a 2byte struct and only contains basic information. Other info is moved to CurrencyInfo.
- Namespaces are replaced by IsIso4217 (yes/no). Codes need now to be unique overall.
- Formatting format G is now Currency format with currency code instead of currency symbol
- Formatting format C is Currency format with currency symbol, but if there is none, currency code will be used.
- Changed Number on CurrencyInfo from
string
toshort
- Changed DecimalDigits on CurrencyInfo from
decimal
toint
- Changed MinorUnit on CurrencyInfo to
MinorUnit
type
Removed
- Removed support for JavaScriptSerializer in ASP.NET (NodaMoney.Serialization.AspNet)
- Removed support .NET Core 3.1, .NET 4.0 and .NET 4.5 (implicitly supported by .NET Standard 2.0)
- CurrencyBuilder is removed (use CurrencyInfo to Create, Register and Unregister).
- Formatting format I is removed (replaced by format G)
- Formatting format O is removed (replaced by format R)
- Formatting format F is removed (replaced by format L)
- Removed MajorUnit from CurrencyInfo