-
Notifications
You must be signed in to change notification settings - Fork 393
QuantityType is not extensible #858
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
Comments
Hi and thanks for the detailed description. Custom units is the least mature part of this library, and as you found out the enum is not extensible. If you are interested in attempting a pull request then I'd be happy to assist! |
I'd like to, but do not have the time currently. I need to dive in it for a day or so to have a good PR. It'd be good to discuss the design upfront, that may save some effort when prototyping/implementing. I see the To represent QuantityType, I'd use an interface. Then have a class implement it with static instances. Do you avoid trying to instantiate static instances for performance? I do not see performance listed as a specific feature. If it is not a feature, why not simply merge |
No, it just seemed like a good idea at the time. We had a bunch of
I'm not 100% sure I follow, could you please take some example quantities like Length and Mass and some units like centimeter and kilogram and write a bit of pseudo code for the new classes and interfaces you propose to add as well as some example usages to illustrate your idea? I understand you propose replacing enum Best, |
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. |
I'm currently adding some quantities with units for a specific domain. I miss a few things which I ideally like to see, most of these are convenience features which I can happily work around.
I have added
.json
files with specification into my own project. In there, I have defined quantities. I then wrote a script to copy these json files to theCommon/UnitDefinitions
folder of UnitsNet project. I subsequently ran the CodeGen assembly.Changes made to the UnitsNet project make mostly sense.
One thing which does not make sense to me is the use of QuantityType as enum. I can't just add a QuantityType member - enums are not extensible. Note that the guide refers to HowMuch quantity which returns undefined.
An alternative would be to make
QuantityType
an interfaceIQuantityType
with static instances.QuantityType.Undefined
likeHowMuch
?The text was updated successfully, but these errors were encountered: