Skip to content

Changelog

Andreas Gullberg Larsen edited this page Nov 8, 2018 · 11 revisions

Breaking changes and old history is described below. For latest changes, see the Releases page.

4.0 - Reduce binary size and a address a long wishlist of breaking changes

Date: Scheduled for December 17, 2018

In two years UnitsNet has grown from 280 kB to 1.4 MB. A lot of it is due to unnecessary syntactic sugar for various number types and nullable types - for every of our 800+ units! It simply adds up to a big total.

This release brings the binary size back down to 585 kB and addresses a long wishlist #180 of breaking changes accumulated over the years.

Upgrading from 3.x

These are the usecases we expect most consumers to have to deal with when upgrading.

Number extension methods removed

Either create your own or use From factory methods.

Length m = 1.Meters(); // No longer possible
Length m = Length.FromMeters(1); // Use this instead

UnitSystem abbreviations => UnitAbbreviationsCache

For looking up or mapping custom unit abbreviations, instead of UnitSystem use UnitAbbreviationsCache.

var abbreviations = UnitAbbreviationsCache.Default;
abbreviations.GetAllUnitAbbreviationsForQuantity(typeof(LengthUnit)); // ["cm", "dm",...]
abbreviations.GetUnitAbbreviations(typeof(LengthUnit), 6); // ["ft", "'", "`"]
abbreviations.GetDefaultAbbreviation(typeof(LengthUnit), 1); // "cm"
abbreviations.MapUnitToAbbreviation(typeof(LengthUnit), 1, new CultureInfo("en-US"), "foo"); // add custom abbreviation for centimeter

UnitSystem parsing => UnitParser

All parsing of unit abbreviations are now done by UnitParser:

var parser = UnitParser.Default;
parser.Parse("cm", typeof(LengthUnit)); // 1
parser.TryParse("cm", typeof(LengthUnit), out object val); // returns true, val = 1

UnitSystem.DefaultCulture => GlobalConfiguration.DefaultCulture

To change the default culture used by ToString() in quantities:

GlobalConfiguration.DefaultCulture = new CultureInfo("en-US"); // instead of UnitSystem.DefaultCulture

Nullable From-methods removed

int? val = null;

// Instead of this
Length? l = Length.FromMeters(val);

// Do this, or create your own convenience factory method
Length? l = val == null ? (Length?)null : Length.FromMeters(val.Value);

Added

  • UnitSystem with a different meaning, now defines the base units for a unit system (#524)

Removed

  • Replace netstandard1.0 target with netstandard2.0, to avoid the extra dependencies (#477)
  • Remove code marked as [Obsolete], such as VolumeUnit.Teaspoon (#490)
  • Remove nullable From factory methods (#483)
  • Remove all number extension methods (#497, #483)
  • Remove Length2d, replaced by Area or provide your own (#501)
  • Remove static methods on UnitSystem, should use UnitSystem.Default instead (#496)
  • Remove unit parameter from ToString() methods (#546)

Changed

Renamed

  • Correct SingularName for some Flow unit definitions (#494, see #360)
  • Split UnitSystem into UnitParser, GlobalConfiguration, UnitAbbreviationsCache (#511)

Fixed

  • Search for any TODO comments in the code to address, remove comment and either fix or create issue (5d24432a)
  • Update README with v4 changes #498
  • Do not try/catch in UnitConverter.Try-methods (#506)
  • Do not try/catch in Length.TryParse() and for other quantities (#507)

3.0 - Clean up naming of units

Date: 2014-07-23

New

  • Add information units for bit, byte, kilobit, kilobyte, kibibit, kibibyte and so on up to exabyte

Breaking changes

  • Delete OtherUnit.Piece
  • Move OtherUnit.Table/Teaspoon to Volume
  • Rename Month30Days Year365Days units to Month and Year
  • Fix plural naming of Pressure.KilogramsForcePerSquareCentimeterInOnePascal
  • Fix plural naming of Ratio.PartsPer-units
  • Custom units added manually via UnitSystem.MapUnitToAbbreviation()

Fixes

  • Fall back to US English culture when parsing/getting abbreviations
  • Fall back to custom string if no abbreviation defined for unit

Behind the scenes

  • Replace T4 templates with PowerShell + JSON templates
  • Support custom tolerance per unit in tests
  • Support decimal and long base unit types (decimal used in Information unit)
  • Move code more consistently into Custom/GeneratedCode folders
  • Fix misc R# warnings
  • Match R# cleanup profile in generated code

2.0 - Add support for custom units. Add ratio unit.

Date: 2014-02-09

Breaking changes

  • Merge UnitValue and UnitConverter into unit classes.

v1.13: Add mass unit (pound) (thanks @strvmarv).

v1.12: Add speed units (km/h, m/s, ft/s, knots, mph). Add mass units (microgram, nanogram).

v1.11: Fix bugs in Flow and RotationalSpeed units after refactoring to T4 templates (thanks George Zhuikov). Add Temperature units.

v1.10:

  • Add missing localization to units for US English and Russian cultures (thanks George Zhuikov).
  • Add RotationalSpeed and Flow unit classes (thanks George Zhuikov).
  • Add mils and microinches length units (thanks Georgios).
  • Refactor to generate unit classes with T4 templates, a lot less work to add new units.

v1.9: Improve precision of PoundForce unit (thanks Jim Selikoff).

v1.8:

  • Add angle units of measurement (thanks Georgios).
  • Add tests and fix bug in NewtonPerSquareCentimeter and NewtonPerSquareMillimeter.

v1.7: Add imperial and US units for volume and area.

v1.6: Add area units. Fix exception in TryConvert for volume units.

v1.5: Add volume units of measurement (thanks @vitasimek). Add missing operator overloads.

v1.4: Add ShortTon and LongTon mass units (thanks Cameron MacFarland). Add TryConvert methods.

v1.3: Add pressure units. Add dynamic conversion via UnitConverter and UnitValue

v1.2: Add force, torque, pressure, mass, voltage, length and length2d units of measurement.