Skip to content

Order of UnitInfos in static constructors does not match enum values in-order. #1226

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

Closed
tmilnthorp opened this issue Mar 13, 2023 · 3 comments

Comments

@tmilnthorp
Copy link
Collaborator

Describe the bug
The order of UnitInfo registration in static constructors does not (always) match enum values in-order. This makes trying to retrieve a UnitInfo by index (of the enum value) impossible.

To Reproduce
Steps to reproduce the behavior (just an example):

  1. Look at static Length()
  2. Megameter (value 41) is the 20th index in the array.

Expected behavior
How can we retrieve a UnitInfo based on a unit enum value? We may need to move to a Dictionary.

Additional context
This is especially applicable as I work through #1210, trying to get the abbreviations based on an enum value.

@tmilnthorp tmilnthorp added the bug label Mar 13, 2023
@tmilnthorp
Copy link
Collaborator Author

Ah. I just found Quantity.GetUnitInfo.

Kinda hidden. TODO: Improve discoverability.

@tmilnthorp
Copy link
Collaborator Author

Also a todo: this loads all quantity infos as one. We can do lazily if we use methods rather than exposing the raw array storage.

@stale
Copy link

stale bot commented Jun 18, 2023

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 Jun 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants