-
Notifications
You must be signed in to change notification settings - Fork 391
Add base units to some quantities (first steps) #601
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
Conversation
…an example of a derived quantity
And no, it doesn't work on WRC 😄 I did it quick. Have to pull code and do locally without WRC to see it. |
Probably a good idea to merge in #607 first. |
More of a proof of concept. Not ready to merge :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just took a fresh look at this, been a while since last time. I now finally get how it's supposed to work when specifying say Feet as default Length unit in a UnitSystem. Nice!
From what I can tell, the major things missing is prefix units and derived units/quantities, is there a complication with derived units or is it simply a matter of adding JSON definitions?
UnitsNet/GeneratedCode/Quantities/ApparentPower.NetFramework.g.cs
Outdated
Show resolved
Hide resolved
I can't reply directly to your comments so here we go:
|
Regen
Doc fix
Renaming method to ExistsIn and simplifying. Adding test.
Only use arguments that are not undefined for BaseUnits in UnitInfo.
Showing example BaseUnits for Joule (energy)
Adding BaseUnits for Acceleration units
I'm actually pretty happy with this now if you'd like to take a look! Not all of them are there, but we can work on adding derived quantity base units as we wish. There's a lot... 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Phew, this is a lot to take in. I don't think I grok all of it yet, especially the ExistsIn() logic and how it is used, but I'll let you go through my second impression comments first before I read it again.
UnitsNet/GeneratedCode/Quantities/Capacitance.NetFramework.g.cs
Outdated
Show resolved
Hide resolved
PR suggestions
PR suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more things and this should be ready to go!
UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.NetFramework.g.cs
Outdated
Show resolved
Hide resolved
Only expose quantity constructor for UnitSystem. Move getting of unit for base units to QuantityInfo (easier when working with generic types or static info).
I will add more tests for QuantityInfo.GetUnitInfoForBaseUnitsSubset before merging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might be in the middle of something here, but here are some comments regardless.
UnitsNet/GeneratedCode/Quantities/Acceleration.NetFramework.g.cs
Outdated
Show resolved
Hide resolved
Chop long lines
Rename GetUnitInfoFor
Ok, I think I got through it all! 🎉 |
} | ||
|
||
[Fact] | ||
public void GetUnitInfoFor_GivenBaseUnitsWithMultipleMatches_ThrowsInvalidOperationException() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good test!
I think so too :-) Looks good to me, great job on this one too! |
UnitSystem constructors (#547)