Skip to content

Upgrading from 4.x to 5.x

Andreas Gullberg Larsen edited this page Feb 17, 2023 · 12 revisions

Most of the removed code was marked as obsolete for a long time in v4 before removed in v5 with details on what to replace the usage with.

💥 Breaking changes

  1. Localization is based on CultureInfo.CurrentCulture instead of CurrentUICulture (#795, #986)
  2. IQuantity returns QuantityValue instead of double (#1074)
  3. Decimal based quantities return decimal instead of double (Power, BitRate and Information) (#1074)
  4. Equality changed to strict equality so BOTH unit and value must match exactly. 100 cm != 1 m. Read more on why. Fix: Use Equals(other, tolerance, comparisonType).

✨ New

  1. QuantityValue: Implement IEquality, IComparable, IFormattable
  2. QuantityValue: 16 bytes instead of 40 bytes (#1084)
  3. Add [DataContract] annotations (#972)

🔥 Removed

  1. Remove targets: net40, net47, Windows Runtime Component. Fix: Use netstandard2.0.
  2. Remove Undefined enum value for all unit enum types. Fix: Use null.
  3. Remove QuantityType enum. Fix: Use strings.
  4. Remove IQuantity.Units and .UnitNames. Fix: Use QuantityInfo.
  5. Remove GlobalConfiguration. Fix: Change CultureInfo.CurrentCulture.
  6. Remove Molarity ctor and operator overloads. Fix: Use MassConcentration.FromMolarity(), ToMolarity().
  7. Remove MinValue, MaxValue per quantity due to ambiguity. Fix: Define your own min/max quantity values.
  8. Remove string format specifiers: "v", "s". Fix: Use Value property and standard .NET numeric format strings.
  9. json: Remove UnitsNetJsonConverter. Fix: Use UnitsNetIQuantityJsonConverter or AbbreviatedUnitsConverter.

📝 JSON unit definition schema changes

Rename BaseType to ValueType, for values "double" and "decimal". Rename XmlDoc to XmlDocSummary.