Skip to content

Commit 1cce777

Browse files
AndreasLeebangularsen
authored andcommitted
IParsable + codegen
1 parent 96bd42d commit 1cce777

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ namespace UnitsNet
7171
Writer.WLIfText(1, GetObsoleteAttributeOrNull(_quantity));
7272
Writer.W(@$"
7373
[DataContract]
74-
public readonly partial struct {_quantity.Name} : {(_quantity.GenerateArithmetic ? "IArithmeticQuantity" : "IComparableQuantity")}<{_quantity.Name}, {_unitEnumName}, {_quantity.ValueType}>, ");
74+
public readonly partial struct {_quantity.Name} : {(_quantity.GenerateArithmetic ? "IArithmeticQuantity" : "IQuantity")}<{_quantity.Name}, {_unitEnumName}, {_quantity.ValueType}>, ");
7575
if (_quantity.ValueType == "decimal")
7676
{
7777
Writer.W("IDecimalQuantity, ");

UnitsNet/GeneratedCode/Quantities/Temperature.g.cs

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet/IQuantity.cs

+6-5
Original file line numberDiff line numberDiff line change
@@ -116,29 +116,30 @@ public interface IQuantity<TUnitType> : IQuantity where TUnitType : Enum
116116
}
117117

118118
/// <summary>
119-
/// An <see cref="IQuantity{TUnitType}"/> that (in .NET 7+) implements generic math interfaces for equality and comparison.
119+
/// An <see cref="IQuantity{TUnitType}"/> that (in .NET 7+) implements generic math interfaces for equality, comparison and parsing.
120120
/// </summary>
121121
/// <typeparam name="TSelf">The type itself, for the CRT pattern.</typeparam>
122122
/// <typeparam name="TUnitType">The underlying unit enum type.</typeparam>
123123
/// <typeparam name="TValueType">The underlying value type for internal representation.</typeparam>
124-
public interface IComparableQuantity<TSelf, TUnitType, TValueType> : IQuantity<TUnitType>
124+
public interface IQuantity<TSelf, TUnitType, TValueType> : IQuantity<TUnitType>
125125
#if NET7_0_OR_GREATER
126126
, IEqualityOperators<TSelf, TSelf, bool>
127127
, IComparisonOperators<TSelf, TSelf, bool>
128+
, IParsable<TSelf>
128129
#endif
129-
where TSelf : IComparableQuantity<TSelf, TUnitType, TValueType>
130+
where TSelf : IQuantity<TSelf, TUnitType, TValueType>
130131
where TUnitType : Enum
131132
where TValueType : struct
132133
{
133134
}
134135

135136
/// <summary>
136-
/// An <see cref="IComparableQuantity{TSelf, TUnitType, TValueType}"/> that (in .NET 7+) implements generic math interfaces for arithmetic operations.
137+
/// An <see cref="IQuantity{TSelf, TUnitType, TValueType}"/> that (in .NET 7+) implements generic math interfaces for arithmetic operations.
137138
/// </summary>
138139
/// <typeparam name="TSelf">The type itself, for the CRT pattern.</typeparam>
139140
/// <typeparam name="TUnitType">The underlying unit enum type.</typeparam>
140141
/// <typeparam name="TValueType">The underlying value type for internal representation.</typeparam>
141-
public interface IArithmeticQuantity<TSelf, TUnitType, TValueType> : IComparableQuantity<TSelf, TUnitType, TValueType>
142+
public interface IArithmeticQuantity<TSelf, TUnitType, TValueType> : IQuantity<TSelf, TUnitType, TValueType>
142143
#if NET7_0_OR_GREATER
143144
, IAdditionOperators<TSelf, TSelf, TSelf>
144145
, IAdditiveIdentity<TSelf, TSelf>

0 commit comments

Comments
 (0)