Skip to content

Commit ed27b33

Browse files
committed
IQuantity: Change IDivisionOperators, add Zero property
- Add `Zero` static abstract property, already implemented by all quantities. - Remove redundant `IEqualityOperators` constraint, covered by `IComparisonOperators`. - Change `IDivisionOperators` to divide by number instead of TSelf, needed for average calculation. Got error trying to keep both IDivisionOperators declarations: ``` Interface 'UnitsNet.IArithmeticQuantity<TSelf,TUnitType,TValueType>' cannot implement both 'System.Numerics.IDivisionOperators<TSelf,TValueType,TSelf>' and 'System.Numerics.IDivisionOperators<TSelf,TSelf,TValueType>' because they may unify for some type parameter substitutions ```
1 parent b343f79 commit ed27b33

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

UnitsNet/IQuantity.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
using System;
55
using System.Globalization;
6+
#if NET7_0_OR_GREATER
67
using System.Numerics;
8+
#endif
79
using UnitsNet.Units;
810

911
namespace UnitsNet
@@ -123,7 +125,6 @@ public interface IQuantity<TUnitType> : IQuantity where TUnitType : Enum
123125
/// <typeparam name="TValueType">The underlying value type for internal representation.</typeparam>
124126
public interface IQuantity<TSelf, TUnitType, TValueType> : IQuantity<TUnitType>
125127
#if NET7_0_OR_GREATER
126-
, IEqualityOperators<TSelf, TSelf, bool>
127128
, IComparisonOperators<TSelf, TSelf, bool>
128129
, IParsable<TSelf>
129130
#endif
@@ -145,12 +146,21 @@ public interface IArithmeticQuantity<TSelf, TUnitType, TValueType> : IQuantity<T
145146
, IAdditiveIdentity<TSelf, TSelf>
146147
, ISubtractionOperators<TSelf, TSelf, TSelf>
147148
, IMultiplyOperators<TSelf, TValueType, TSelf>
148-
, IDivisionOperators<TSelf, TSelf, TValueType>
149+
, IDivisionOperators<TSelf, TValueType, TSelf>
149150
, IUnaryNegationOperators<TSelf, TSelf>
150151
#endif
151152
where TSelf : IArithmeticQuantity<TSelf, TUnitType, TValueType>
152153
where TUnitType : Enum
153154
where TValueType : struct
155+
#if NET7_0_OR_GREATER
156+
, INumber<TValueType>
157+
#endif
154158
{
159+
#if NET7_0_OR_GREATER
160+
/// <summary>
161+
/// The zero value of this quantity.
162+
/// </summary>
163+
static abstract TSelf Zero { get; }
164+
#endif
155165
}
156166
}

0 commit comments

Comments
 (0)