-
Notifications
You must be signed in to change notification settings - Fork 386
Changelog
Breaking changes and old history is described below. For latest changes, see the Releases page.
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.
These are the usecases we expect most consumers to have to deal with when upgrading.
Either create your own or use From factory methods.
Length m = 1.Meters(); // No longer possible
Length m = Length.FromMeters(1); // Use this instead
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
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
To change the default culture used by ToString()
in quantities:
GlobalConfiguration.DefaultCulture = new CultureInfo("en-US"); // instead of UnitSystem.DefaultCulture
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);
- UnitSystem with a different meaning, now defines the base units for a unit system (#524)
- Replace netstandard1.0 target with netstandard2.0, to avoid the extra dependencies (#477)
- Remove code marked as
[Obsolete]
, such asVolumeUnit.Teaspoon
(#490) - Remove nullable
From
factory methods (#483) - Remove all number extension methods (#497, #483)
- Remove
Length2d
, replaced byArea
or provide your own (#501) - Remove static methods on
UnitSystem
, should useUnitSystem.Default
instead (#496) - Remove unit parameter from
ToString()
methods (#546)
- Throw exception on NaN values in static constructor methods, like
FromMeters()
(#502, see https://github.com/angularsen/UnitsNet/issues/176#issuecomment-240434320) - Throw if unit was not specified when constructing quantities, (#499 - https://github.com/angularsen/UnitsNet/pull/389#issuecomment-362811310)
- Stricter parsing (#343 and https://github.com/angularsen/UnitsNet/issues/180#issuecomment-357100824)
- Remove unit parameter from
ToString()
methods (#546) - Change Temperature arithmetic back to use base unit Kelvin (#550, see #518)
- Correct SingularName for some Flow unit definitions (#494, see #360)
- Split UnitSystem into UnitParser, GlobalConfiguration, UnitAbbreviationsCache (#511)
- 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)
Date: 2014-07-23
- Add information units for bit, byte, kilobit, kilobyte, kibibit, kibibyte and so on up to exabyte
- 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()
- Fall back to US English culture when parsing/getting abbreviations
- Fall back to custom string if no abbreviation defined for unit
- 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
Date: 2014-02-09
- 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.