Providing a default implementation for IQuantity<TUnitType>.QuantityInfo#1614
Conversation
…yInfo - removing the explicit implementations for IQuantity and IQuantity<TUnit> (net8+)
|
@angularsen Default interface implementations and structs don't usually play very well together, but I think we should be ok here. Here are some notes:
Here's a typical bad-usage example: public Enum GetUnitEnum<TQuantity>(TQuantity quantity) where TQuantity : IQuantity
{
return quantity.Unit;
} Its probably obvious to everyone that there is going to be boxing when converting the unit to This is obviously not how you would typically access the untyped unit- normally you would only do so if you are forced to use an On the other hand, if you are one that cares about the extra allocations, but for some reason can't have access to the Same goes for the It looks tricky, I know- but I'm pretty sure I've checked all our usages, and there aren't any, that I could find, that still require the use of these properties. The sole usages (here or in the 🐲 PR) are the interface extensions in the |
IQuantity<TUnitType>.QuantityInfoIQuantityandIQuantity<TUnit>(net8+)