Simplify interfaces#1662
Conversation
|
@claude Review idea in PR description and current code change |
|
Claude finished @angularsen's task in 4m 56s —— View job PR Review: Simplify interfaces
Design IdeaThe PR has two goals:
Both goals are reasonable. The first is clearly useful. The second reduces redundancy in the generated code significantly. What ChangedHierarchy restructure (non-generated files):
Generated quantities: Before (per-quantity flat list): public readonly partial struct Length :
IArithmeticQuantity<Length, LengthUnit>,
#if NET7_0_OR_GREATER
IDivisionOperators<Length, Length, double>,
IMultiplyOperators<Length, Length, Area>,
IComparisonOperators<Length, Length, bool>,
IParsable<Length>,
#endif
IComparable, IComparable<Length>, IEquatable<Length>, IFormattableAfter (clean hierarchy): public readonly partial struct Length : IQuantity<Length, LengthUnit>, ILinearQuantity<Length>
#if NET7_0_OR_GREATER
, IMultiplyOperators<Length, Length, Area>
...
#endifIssues1. Breaking:
|
4a7a992 to
bd39d28
Compare
In my use of UnitsNet, I find the recently added
IQuantityOfType<TQuantity>very useful. I wanted to do a comparison between some, but could not without addingIComparisonOperators<TQuantity, TQuantity, bool>to the constraints of my method. I then realized this can be added to the base interface instead of the quantity itself.While doing this I found a way to simplify some other interfaces in the inheritance chain, like reusing
IArithmeticQuantityfor bothILinearQuantityandILogarithmicQuantityand removing one level of inheritance.@lipchev Are these improvements in your opinion?