angularsen / UnitsNet

Makes life working with units of measurement just a little bit better.
https://www.nuget.org/packages/UnitsNet/
MIT No Attribution
2.17k stars 376 forks source link

v6 Wishlist #1200

Open angularsen opened 1 year ago

angularsen commented 1 year ago

This issue serves as a place to discuss what to include in this version, since major version bumps allow us to make breaking changes we think are necessary or worth it.

The wishlist keeps track of the items to include, but items may be added or removed at any time.

As changes are completed, they are added to https://github.com/angularsen/UnitsNet/wiki/Upgrading-from-5.x-to-6.x

Wishlist

maxreb commented 1 year ago

Add System.Text.Json support https://github.com/angularsen/UnitsNet/pull/966

angularsen commented 1 year ago

Decide on a naming and abbreviation convention for imperial/UK units and US units; like gallon, ounces, cup etc.

It is a bit of a mess right now: image image

image

LINQPad sample ```cs void ListUnits(string withPartialName) { Quantity.Infos .SelectMany(i => i.UnitInfos .Where(n => n.Name.Contains(withPartialName)) .Select(u => new { u.Name, Abbrev = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(u.Value.GetType(), Convert.ToInt32(u.Value)) })) .Dump(withPartialName); } ListUnits("Uk"); ListUnits("Imperial"); ListUnits("Us"); ```

I personally like "UK", since it is shorter and better matches "US". Wolfram also uses US gallon and UK gallon.

Some conventions for imperial gallons: https://en.wikipedia.org/wiki/Gallon#:~:text=the%20imperial%20gallon%20(imp%20gal,American%20and%20Caribbean%20countries%3B%20and

Today the abbreviation convention is gal (U.S.) and gal (imp.). Depending on landing on UK or imperial naming, we could go with one of these pairs:

We can support multiple of these plus the old ones, but the primary form should be standardized across the different units.

ebfortin commented 1 year ago

Do not throw ArgumentException on NaN, Inf+ or Inf- or give a way to configure the behavior globally.

Context: https://github.com/angularsen/UnitsNet/issues/1268#issuecomment-1630856242

MisinformedDNA commented 11 months ago

I think UnitsNet should be more extensible. Perhaps there could be a base package, but separate NuGet packages for US measurements, Imperial, UK, etc. Alternatively, customizable abbreviations could be a solution. I would never expect me or my users to see "gal (US)" instead of "gal". This would also help the debate here.

UPDATE:

Custom abbreviations already exist: UnitAbbreviationsCache.Default.MapUnitToDefaultAbbreviation(HowMuchUnit.Some, "sm");

angularsen commented 11 months ago

I think UnitsNet should be more extensible.

Conceptually, I agree.

Customizable abbreviations is already supported as you found, and we support custom quantities and units with some limited functionality: https://github.com/angularsen/UnitsNet/wiki/Extending-with-Custom-Units

Splitting up in packages is not so easy though. Things like Torque = Force * Length becomes problematic when types exist in different packages and they can't have circular dependencies. Imperial is even worse, splitting some units of a quantity to different packages. The main problem is static typing, which is also one of the main features of UnitsNet.

One benefit of splitting up in packages is smaller binary size to only bring in what you need. Some prototyping here: #1181

Markussp256 commented 9 months ago

I was requested to give a list of units with the wrong plural form (see #1330 )

I checked the .json-file with the speed units and only MetersPerMinute has a wrong plural form, all other Speed units seem to have the correct plural form.

angularsen commented 8 months ago

@Markussp256

I was requested to give a list of units with the wrong plural form (see #1330 )

I checked the .json-file with the speed units and only MetersPerMinute has a wrong plural form, all other Speed units seem to have the correct plural form.

Some more fixes were made recently in

1351