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

QuantityValue: 16 bytes instead of 40 bytes #1084

Merged
merged 2 commits into from
Jun 3, 2022

Conversation

AndreasLeeb
Copy link
Contributor

@AndreasLeeb AndreasLeeb commented May 13, 2022

Fixes #875

@angularsen
Regarding #875 (reply in thread) a PR draft for #875 (comment)

Size comparison

Before: Marshal.SizeOf<QuantityValue>(): 40 B
After:  Marshal.SizeOf<QuantityValue>(): 16 B

UnderlyingDataType could support up to 256 different enum values, I guess we won't ever need more different underlying types that can fit into this struct 😄

@codecov
Copy link

codecov bot commented May 13, 2022

Codecov Report

Merging #1084 (14fddb7) into release/v5 (6e2f40c) will decrease coverage by 0%.
The diff coverage is 30%.

@@            Coverage Diff             @@
##           release/v5   #1084   +/-   ##
==========================================
- Coverage          83%     83%   -1%     
==========================================
  Files             303     304    +1     
  Lines           42983   43010   +27     
==========================================
+ Hits            35776   35778    +2     
- Misses           7207    7232   +25     
Impacted Files Coverage Δ
UnitsNet/InternalHelpers/BytesUtility.cs 0% <0%> (ø)
UnitsNet/QuantityValue.cs 55% <44%> (-24%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6e2f40c...14fddb7. Read the comment docs.

Copy link
Owner

@angularsen angularsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks great? As long as tests pass, I think this should be ready to go. Just a few minor comments.

UnitsNet/QuantityValue.cs Show resolved Hide resolved
UnitsNet/QuantityValue.cs Outdated Show resolved Hide resolved
UnitsNet/QuantityValue.cs Outdated Show resolved Hide resolved
@AndreasLeeb AndreasLeeb marked this pull request as ready for review June 3, 2022 13:56
@angularsen angularsen changed the title QuantityValue rework: support both double and decimal in 16 bytes instead of 40 bytes QuantityValue: 16 bytes instead of 40 bytes Jun 3, 2022
@angularsen angularsen merged commit 0171225 into angularsen:release/v5 Jun 3, 2022
@angularsen
Copy link
Owner

Thanks a lot!
v5 branch currently has trouble building, #1094 .

When that is resolved, we will publish a new prerelease nuget for v5 branch.

@angularsen
Copy link
Owner

Build is now fixed and nuget UnitsNet/5.0.0-alpha006 should be out shortly.

@angularsen angularsen mentioned this pull request Nov 29, 2022
angularsen added a commit that referenced this pull request 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants