Skip to content

✨Configure unit conversions via IQuantityInfo - #1578

Closed
angularsen wants to merge 1 commit into
masterfrom
agl/unitconversion-in-quantityinfo
Closed

✨Configure unit conversions via IQuantityInfo#1578
angularsen wants to merge 1 commit into
masterfrom
agl/unitconversion-in-quantityinfo

Conversation

@angularsen

Copy link
Copy Markdown
Owner
  • Add IQuantityInfo.RegisterUnitConversions callback to configure unit conversions
  • Change UnitConverter to configure unit conversions from a list of IQuantityInfo
  • Change UnitsNetSetup to pass the default quantity infos into its default UnitConverter
  • Add sample conversions for HowMuch

- Add `IQuantityInfo.RegisterUnitConversions` callback to configure unit conversions
- Change `UnitConverter` to configure unit conversions from a list of `IQuantityInfo`
- Change `UnitsNetSetup` to pass the default quantity infos into its default `UnitConverter`
- Add sample conversions for `HowMuch`
@angularsen
angularsen requested a review from lipchevJuly 25, 2025 22:03
@angularsen

Copy link
Copy Markdown
OwnerAuthor

Maybe you already have done something like this in your dragon PR, but while reviewing it seemed natural to add something like this.

foreach (QuantityInfo quantityInfo in quantityInfos)
{
var registerMethod = quantity.QuantityType.GetMethod(nameof(Length.RegisterDefaultConversions), BindingFlags.NonPublic | BindingFlags.Static);
registerMethod?.Invoke(null, new object[]{unitConverter});

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

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

Good riddance to this reflection stuff

@lipchev

lipchev commented Jul 25, 2025

Copy link
Copy Markdown
Collaborator

Yes, these are already covered by introducing the ConversionFromBase and ConversionToBase properties (of type ConversionExpression) in the UnitInfo.

@codecov

codecovBot commented Jul 25, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93%. Comparing base (d21e526) to head (f7cc6d3).
⚠️ Report is 49 commits behind head on master.

Additional details and impacted files
@@ Coverage Diff @@## master #1578 +/- ##
======================================
Coverage 93% 93% ======================================
Files 311 311 Lines 28781 28780 -1 ======================================
Hits 26864 26864 + Misses 1917 1916 -1 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions

Copy link
Copy Markdown
Contributor

This PR was automatically closed due to inactivity.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@angularsen@lipchev