Skip to content

Conversation

@lipchev
Copy link
Collaborator

@lipchev lipchev commented Aug 3, 2025

  • cleaned up some commented-out bits from QuantityInfo and IQuantityInfo
  • making the IQuantityInfo interface internal for net8+
  • extended the test for XXX_QuantityInfo_ReturnsQuantityInfoDescribingQuantity with the checks for the explicit interface implementations
  • simplified the test for Ctor_SIUnitSystem_ReturnsQuantityWithSIUnits

…ityInfo

- extended the test for XXX_QuantityInfo_ReturnsQuantityInfoDescribingQuantity with the checks for the explicit interface implementations
Copy link
Collaborator Author

@lipchev lipchev Aug 3, 2025

Choose a reason for hiding this comment

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

In an earlier version of the QuantityInfo, I used to rely heavily on this interface- so I had it split-up the same way as the implementation, with every single property and overload possible. As things started to mature (and members got dropped from the IQuantity interface) this was no longer required. In fact this interface is now only used by netstandard, so I don't see any reason not to make it internal for net8+.

If you want to, we could exclude it completely from the build for net8+, but then we'd have to duplicate the comments in the implementation, as there wouldn't be anything for the <inheritdoc/>.

Copy link
Owner

Choose a reason for hiding this comment

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

Why do we need IQuantityInfo for netstandard2.0 though?
Can't we just use the abstract QuantityInfo and it's number of generic typed descendants?

As for inheritdoc, you can use <inheritdoc cref="" /> syntax to inherit from any type/member so I wouldn't keep it around just for that. Also, duplication of xmldoc is not a big deal.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why do we need IQuantityInfo for netstandard2.0 though?

We need it because of the IQuantityOfType and the IQantityInstanceInfo relationship:
In net8+ we can simply define the Create/From methods on the interface (as static functions).

Since in netstandard we only have instance interface functions, I had to rephrase this slightly by saying that the IQuantityOfType<TQuantity> has a QuantityInfo<TQuantity> that can itself create instances.
The problem is that there is no QuantityInfo<TQuantity> - our QuantityInfo hierarchy goes from QuantityInfo to QuantityInfo<TUnit> and as of v6 there is an extra level: QuantityInfo<TQuantity, TUnit>.
And since there is no way for both QuantityInfo<TQuantity> and QuantityInfo<TUnit> to exist as class I had to introduce the interface...

Now, for the needs of the factory methods, I could have probably gotten away with just the IQauntityInstanceInfo part of the interface, but by re-declaring QuantityInfo in IQuantityOfType we hide the definition from IQuantity- and I didn't want to add another property to the IQuantityOfType interface (what would we call it- QuantityFactory?) , so I just kept the properties of the upstream QuantityInfo accessible via the interface definition.

If you can figure out a better way to do this, without making sacrifices in net8 because of netstandard- that'd be great, but am pretty much out of ideas for the moment.

@angularsen angularsen merged commit d50aab2 into angularsen:master Aug 9, 2025
1 check passed
@angularsen
Copy link
Owner

I'll merge this, but the let's still address IQuantityInfo
#1592 (comment)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants