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

XP One nuget per quantity #1181

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

XP One nuget per quantity #1181

wants to merge 2 commits into from

Conversation

angularsen
Copy link
Owner

@angularsen angularsen commented Jan 7, 2023

Related to #372, #1180

Experiment with splitting up UnitsNet nuget into:

  • UnitsNet.Core (common types and abstractions)
  • UnitsNet.Length
  • UnitsNet.Mass
  • etc..

This is already done for UnitsNet.nanoFramework nugets:
https://www.nuget.org/packages?q=unitsnet.nanoframework

We might also provide meta nuget packages that bring in multiple nugets in a single package:

  • UnitsNet (all nugets, like today)
  • UnitsNet.Meta.SI (all SI and SI derived nugets, such as Length, Force, Mass, Area, Speed etc)
  • UnitsNet.Meta.Main (the most widely used nugets, striving for 80/20 rule)

Benefits

  • Smaller size, only bring the quantities you need. The UnitsNet.dll is ~2MB as of 2023-01-07.
  • More extensible, it forces a design where plugging in 3rd party quantities is simpler.

Problems

  • QuantityType enum must be replaced by strings and using QuantityInfo instead
  • UnitSystem and BaseUnits rely on the 7 SI quantities Length, Mass, etc.
  • Arithmetic across quantities may not be feasible for the library to provide, such as Speed = Length / Duration and Mass.FromGravitationalForce(Force f). We might be able to provide this with meta nuget packages that bring in the most common quantities and arithmetic/conversions between them.

Design proposal

  • Use reflection to look up all quantities in loaded assemblies at startup instead of hard coding it, to allow plugging in 3rd party quantities. Need to provide some configuration for assemblies to search or quantities to load.
  • Make use of QuantityInfo to fully describe a quantity, instead of relying on generated code for known quantities spread over various types.
    • Unit abbreviations for different cultures, currently loaded by UnitAbbreviationsCache.LoadGeneratedAbbreviations() based on generated code.
    • Unit conversion functions, currently defined by generated code in Acceleration.RegisterDefaultConversions and similar for other quantities.

TEMP Remove all but 7 SI quantities

Add Duration and Length projects

TEMP Remove non-SI unit definitions

Add UnitsNet.SI, move SI stuff there

Include the 8 quantity projects in solution
@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
@angularsen angularsen added the pinned Issues that should not be auto-closed due to inactivity. label Jul 14, 2023
@stale stale bot removed the wontfix label Jul 14, 2023
@angularsen
Copy link
Owner Author

test comment

@angularsen
Copy link
Owner Author

test 2

@angularsen
Copy link
Owner Author

test 3

@angularsen angularsen added pending-response Waiting for response from author of PR/issue. and removed wait-for-author labels Jul 16, 2023
@angularsen
Copy link
Owner Author

test 4

@angularsen
Copy link
Owner Author

test 5

@github-actions github-actions bot removed the pending-response Waiting for response from author of PR/issue. label Jul 16, 2023
@angularsen angularsen mentioned this pull request Sep 16, 2023
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pinned Issues that should not be auto-closed due to inactivity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant