Is your feature request related to a problem? Please describe.
Some of the extension methods inUnitsMath.cs (e.g. Average) take an Enum unitType argument. Our system uses these extensively, and when copying/pasting code (and changing the quantity type because we're dealing with different sensors every time), I'd like the compiler to remind me I forgot to update the unit.
Describe the solution you'd like
Change
public static TQuantity Average<TQuantity>(
this IEnumerable<TQuantity> source,
Enum unitType)
where TQuantity : IQuantity
into something like:
public static TQuantity Average<TQuantity>(
this IEnumerable<TQuantity> source,
TUnitType unitType)
where TUnitType : Enum
where TQuantity : IQuantity<TUnitType>
Describe alternatives you've considered
We tried implementing type safe methods in our own codebase, but when we use the wrong unit type, our IDE just falls back to the implementation in UnitsMath.
Additional context
- This will break backwards compatibility, but only for people doing really weird things.
- This change might be warranted in a lot of other places that take a
unitType parameter (I haven't checked yet, mostly because they didn't come up in my use-case)
Is your feature request related to a problem? Please describe.
Some of the extension methods in
UnitsMath.cs(e.g.Average) take anEnum unitTypeargument. Our system uses these extensively, and when copying/pasting code (and changing the quantity type because we're dealing with different sensors every time), I'd like the compiler to remind me I forgot to update the unit.Describe the solution you'd like
Change
into something like:
Describe alternatives you've considered
We tried implementing type safe methods in our own codebase, but when we use the wrong unit type, our IDE just falls back to the implementation in
UnitsMath.Additional context
unitTypeparameter (I haven't checked yet, mostly because they didn't come up in my use-case)