UnitsNet: v5: Wishlist for breaking changes
Although there are no immediate plans to do a vNext, this issue serves as a wishlist/reminder of what to consider changing in case we need to bump the major version in the future.
To clarify
These are some things we should figure out before finalizing version 4.
A common denominator for design choices is binary size. The library was nearing the 1MB mark and the majority of that is the large number of methods and properties for all our 700+ units. In particular number extension methods add 8 methods per unit (!). With some clever hacks we brought this back to 600kB without any breaking changes, but we want to keep binary size in mind for any new changes we introduce.
TODO Clean up and organize this brain dump:
- Numeric type for value representation: Keep
double
? Switch todecimal
? Offer both? Separate nugets? What aboutfloat
? - Base types: To make it easier working with quantities generically, accessing value and unit, get units and their abbreviations, parsing and ToString() without know the quantity type in advance.
struct
vsclass
: Weigh all the pros and cons, performance (stack vs heap), inheritance vs interfaceclass
: Can support all number types (float, double, decimal) without increasing binary size N times (discussion)struct
: More suitable for performance and memory constrained applications (what is the impact in practice?), avoids pressure on garbage collector, quantities match the semantics of being a value type
List of breaking changes to make
Removing things
- https://github.com/anjdreas/UnitsNet/commit/7a455f0c12f5beed3790a7f5a1f6a65055f13c32: Remove default
Temperature
arithmetic, it is not correct (made this breaking change already, due to existing behavior not being correct). - Remove
UnitClass
type, replaced byQuantityType
- Remove nullable
From
factory methods causing N additional methods for N units, see comment - Remove
==
!=
andEquals(object)
andEquals<T>(T)
since they don’t take a max error argument and is prone to floating point rounding issues, instead users should useEquals()
methods that take a max error argument - Remove code marked as
[Obsolete]
, such asVolume.Teaspoon
unit that was too ambiguous - Remove static methods on
UnitSystem
, should useUnitSystem.Default
instead - Remove unnecessary overloads on number types (8 overloads for each of the 700+ units) #372
Changing behavior
- Throw exception on NaN values in unit class constructor methods (#176)
- Throw if unit was not specified when constructing quantities https://github.com/angularsen/UnitsNet/pull/389#issuecomment-362811310
- Stricter parsing (see #343 and https://github.com/angularsen/UnitsNet/issues/180#issuecomment-357100824)
Renaming
-
Acceleration
units missing plurals
inMeters
(fixed in #434) - Correct SingularName for some Flow unit definitions (see #360)
Fixing
- Search for any TODO comments in the code to address, remove comment and either fix or create issue
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 16 (14 by maintainers)
Commits related to this issue
- v4.0.0 (#487) # 4.0.0 Release This PR will serve as the list of items to complete and it will be updated to show the progress before finally merged into `master` when completed. We all have busy sch... — committed to angularsen/UnitsNet by angularsen 6 years ago
- v5 Release (#982) Fixes #180 Merging the v5 release branch. It is still in alpha, but it is functional, nugets are published and there are not many planned breaking changes left. By merging, ... — committed to angularsen/UnitsNet by angularsen 2 years ago
Ping @JKSnd @eriove @ferittuncer to subscribe to updates to this thread.
Question: Should we change this
to this
Delta is already covered by the quantity, so it feels redundant. Just noticed this when reviewing https://github.com/angularsen/UnitsNet/pull/324/files#diff-1067499ac8bb37a45676058d184d0547R55
Acceleration units missing plural s in Meters is fixed in #434
I have created a new branch
v4
that we will target the pull requests in this wishlist, and any other changes we want to include in only v4 and not in3.x
versions.It will be a fairly big undertaking to complete all this, but I propose we start on this before the list grows unmanageable and the jump from 3.x to 4.x becomes too great from the consuming side.
I propose making parsing stricter:
Length.Parse("2.3 m")
Length.Parse("2.3 m and 200mm")
FeetInches
.Length.Parse("1ft 5.5in")
andLength.Parse("1\"5.5'")
Length.Parse("1ft and 4in")
This would be more in consistent with framework parsing methods (like
double.Parse
), which are not very lenient. The burden lies with the consumer to provide data that is not ambiguous.See #343 for additional context. Related PRs from originally allowing multiple units: #64 #81 #254
Please add this to wishlist: Correct SingularName for some Flow unit definitions.
see https://github.com/angularsen/UnitsNet/issues/360
Yes, that sounds like a good change. We could add the new function and mark the old one as obsolete immediately. That would make the migration easier