QuantityValue implemented as a fractional number 🐲 #1544
QuantityValue implemented as a fractional number 🐲 #1544lipchev wants to merge 80 commits intoangularsen:masterfrom
Conversation
- IQuantity interfaces optimized (some methods refactored as extensions) - QuantityInfo/UnitInfo hierachy re-implemented (same properties, different constructors) - QuantityInfoLookup is now public - UntAbbreviationsCache, UnitParser, QuantityParser optimized - UnitConverter: re-implemented (multiple versions) - removed the IConvertible interface - updated the JsonNet converters - introducing the SystemTextJson project - added a new UnitsNetConfiguration to the Samples project showcasing the new configuration options - many more tests and benchmarks (perhaps too many)
|
@angularsen Clearly, I don't expect this to get merged in the Gitty up! fashion, but at least we have the whole picture, with sources that I can reference. If you want, send me an e-mail, we could do a quick walk-through / discussion. |
…lection constructors with IEnumerable - `UnitAbbreviationsCacheInitializationBenchmarks`: replaced some obsolete usages
I tried to create this PR twice before (many months ago), while the changes to the unit definitions were still not merged- and the web interface was giving me an error when trying to browse the files changed.. Something like "Too many files to display" 😄 |
|
Ok, I'm not going to get through a review of this many files anytime soon. On the surface though, it seems like this could be split up into chunks. I know it's tedious and extra work, but it will be way faster to review. Do you see any chunks of changes to easily split off into separate PRs? |
Sofia (GMT+3), but time zones are not relevant to my sleep schedule - so basically any time you want.
Yes, I do have some ideas:
Hopefully by the time we get to 5) you'd be up to speed (and fed up with PRs) and we can turn back to reviewing / working on the rest of it as a whole 😄 |
|
Ok, sounds good. Just send PRs my way and I'll try to get to them. I have a little bit of extra time this weekend. |
…ions into their own folder
- UnitAbbreviationsCache: removing the obsolete overload - adding a few more tests
|
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. |
|
This PR was automatically closed due to inactivity. |
…ramework (net8.0) with 9.0 on the QuantityInfoBenchmarks
- updating all packages to their latest versions - UnitsNet version bumped to 6.0.0-pre100
…Sharper debugger failure Move the configuration lookup out of the QuantityDebugProxy constructor into the Configuration property getter in UnitsNet/CustomCode/Debug/QuantityDebugProxy.cs so the ReSharper inline evaluator no longer shows "Cannot evaluate expression" when expanding the proxy in the debugger. Also replace debug-formatting static fields with properties (DefaultFormatSpecifier, DefaultFormatProvider) and tidy namespaces/XML docs. Mitigates ReSharper issues RSRP-499956 and RSRP-502262.
…constructor logic and improving the xml comments regarding the equality contract
|
@angularsen I expected the build would fail, but regardless went on and pushed the target framework to I ran a couple of the benchmarks - not everything is faster, but there is a good amount of improvement around the Parse/Format stuff. Anyway, I've already updated the package references in my own solutions (multi targeting PS I'm still experiencing issues with the resharper extension not being able to properly evaluate some expressions in the debugger (no issues with the native VS tooltips)- I've got 2 issues open on their tracker, please check that the debug-proxies are all still working fine for you in raider. |
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>net9.0</TargetFramework> | ||
| <TargetFramework>net10.0</TargetFramework> |
There was a problem hiding this comment.
We might potentially want to keep the generator at net9.0 for a while longer, until VS2026 becomes more widely adopted (I haven't actually tried it but I think VS2022 should still be able to build this with Use previews of the .NET SDK option enabled).
There was a problem hiding this comment.
Let's do net10.0 as a separate PR, but we'll definitely bump
There was a problem hiding this comment.
Yes, I was kinda hoping you would bump the build images before, or at the same time as the PR is created (targeting the main branch).
|
Just to give a life sign, I'm still very busy with work and I expect this to continue well into the next year. However, I'm motivated to get this PR merged in the upcoming Christmas season, bump v6 to beta and start stabilizing and collecting feedback on the rather big changes for a little while before we fully release it. I see some of my comments haven't been addressed yet, so I assume you are still working on this? I realize I'm becoming a bottleneck in this project, we should discuss options to improve that. Maybe onboard more contributors, and I think you should have more autonomy to make decisions without having to wait on me. I'm open to ideas here. |
- added AoT compatibility to the NumberExtensions.CS14 project
…ineQuantity`, `ClassOfLinearQuantity`, and `ClassOfLogarithmicQuantity`, implementing the respective interface defition (as a class). - Completed the coverage of the `LinearQuantityExtensions`, `LogarithmicQuantityExtensions`, `AffineQuantityExtensions` (calling the concrete `Equals` overload with a null reference type) - Completed the coverage of the `UnitMath` extensions (`Min`, `Max`) - Cleaned up the legacy code in `IQuantityTests.cs`.
…PerKilogram * BrakeSpecificFuelConsumption.KilogramPerJoule expression (`double` - > `QuantityValue`) - CodeGen: replaced all mentions of the `double` type
|
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. |
|
This PR was automatically closed due to inactivity. |
|
Just a heads up that I have taken small steps to resume review of this PR, I have a local review with the help of AI that I'll be iterating on a little before I post it here. |
|
Alright, it's a bit rough and straight from the AI still but here are some new inputs on hopefully the latest changes. I haven't double checked if maybe some of these are already addressed. The big one is the implicit conversion, I really do think we need to reduce the blast radius of this breaking change and not require everyone to explicitly cast to double, or to deal with QuantityValue in their codebase. PR #1544 Review: QuantityValue as Fractional NumberReview date: 2026-03-09 | Branch: Changes Required Before MergeP0 — Must do
P1 — Should do
Deferred (Post-Merge)Before stable release
Low priority
Won't do
Reference: Breaking Changes Summary
|
|
@angularsen I'm sorry, but P0 is a no-go. I have been very explicit about it since the very beginning (even before this PR). |
|
I see, I'll try and change it locally to get a better feel for why adding implicit cast is challenging. |

QuantityValueimplemented as a fractional numberIQuantityinterfaces optimized (some methods refactored as extensions)UnitInfo: introduced two new properties:ConversionFromBaseandConversionToBasewhich are used instead of theswitch(Unit)conversionUnitsNetSetup: introduced helper methods for adding external quantities, or re-configuring one or more of the existing onesUntAbbreviationsCache: introduced additional factory methods (using a configuration delegate)UnitParser: introduced additional factory methods (using a configuration delegate)UnitConverter: re-implemented (multiple versions)Inverserelationship mapping implemented as a type of implicit conversion