Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map and look up unit abbreviations by strings instead of enums #1067

Open
angularsen opened this issue Mar 20, 2022 · 1 comment
Open

Map and look up unit abbreviations by strings instead of enums #1067

angularsen opened this issue Mar 20, 2022 · 1 comment
Labels
enhancement pinned Issues that should not be auto-closed due to inactivity.
Milestone

Comments

@angularsen
Copy link
Owner

angularsen commented Mar 20, 2022

Blocks #1181

QuantityType enum is already deprecated and will be removed in #982 in order to better support third-party quantities and units.

The same could be done for the 100+ unit enums, like LengthUnit

Instead of

string abbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unitInfo.GetType(), (int)unitInfo);

We could support, without breaking change:

string abbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation("Length", "Millimeter");

Optionally, we could deprecate the enum-based overloads and remove them in #982 or future major version bump.

Related to discussion:
#1062 (comment)

@angularsen angularsen added this to the 5.0 milestone Mar 20, 2022
@angularsen angularsen mentioned this issue Mar 20, 2022
@stale
Copy link

stale bot commented Aug 13, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Aug 13, 2022
@angularsen angularsen added the pinned Issues that should not be auto-closed due to inactivity. label Aug 14, 2022
@stale stale bot removed the wontfix label Aug 14, 2022
angularsen added a commit that referenced this issue Nov 29, 2022
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, all efforts moving forward are targeting v5 and this reduces friction:

- No more merge conflicts trying to forward port all changes to v5, instead cherry pick new units and fixes to v4 until v5 is fully stable.
- Contributors are having trouble building v4 locally due to `net40`, `net47` and Windows Runtime Component targets.


## 💥 Breaking changes
Default number format should be CultureInfo.CurrentCulture, not CurrentUICulture (#795)
Use CurrentCulture rather than CurrentUICulture (#986)
Return `QuantityValue` in `IQuantity` properties instead of `double` (#1074)
Return `decimal` in properties of `Power`, `BitRate` and `Information` quantities (#1074)
Fix singular name VolumeFlow.MillionUsGallonsPerDay

## 🔥 Removed 
Remove targets: net40, net47, Windows Runtime Component.
Remove `Undefined` enum value for all unit enum types
Remove QuantityType enum
Remove IQuantity.Units and .UnitNames
Remove IQuantity.ToString() overloads
Remove IEquatable<T> and equality operators/methods 
Remove GlobalConfiguration
Remove obsolete and deprecated code.
Remove Molarity ctor and operator overloads
Remove MinValue, MaxValue per quantity due to ambiguity
Remove string format specifiers: "v", "s"
json: Remove UnitsNetJsonConverter

## ✨ New
QuantityValue: Implement IEquality, IComparable, IFormattable
QuantityValue: 16 bytes instead of 40 bytes (#1084)
Add `[DataContract]` annotations (#972)

## ♻️ Improvements
Upgrade CodeGen, tests and sample apps to net6.0.

## 📝 JSON unit definition schema changes
Rename `BaseType` to `ValueType`, for values "double" and "decimal".
Rename `XmlDoc` to `XmlDocSummary`.

## TODO
Add back `IEquatable<T>`, but implement as strict equality with tuple of quantity name + unit + value.
#1017 (comment)

## Postponed for later
#1067
@angularsen angularsen modified the milestones: 5.0, vNext Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement pinned Issues that should not be auto-closed due to inactivity.
Projects
None yet
Development

No branches or pull requests

1 participant