@@ -317,10 +317,12 @@ readonly partial struct {{unitTypeName}}
317317 if ( prop . HasArithmeticOperator ( UnitArithmeticOperators . Addition ) )
318318 {
319319 net7Interfaces . Add ( $ "IAdditionOperators<{ unitTypeName } , { unitTypeName } , { unitTypeName } >") ;
320+ net7Interfaces . Add ( $ "IUnaryPlusOperators<{ unitTypeName } , { unitTypeName } >") ;
320321 }
321322 if ( prop . HasArithmeticOperator ( UnitArithmeticOperators . Subtraction ) )
322323 {
323324 net7Interfaces . Add ( $ "ISubtractionOperators<{ unitTypeName } , { unitTypeName } , { unitTypeName } >") ;
325+ net7Interfaces . Add ( $ "IUnaryNegationOperators<{ unitTypeName } , { unitTypeName } >") ;
324326 }
325327 if ( prop . HasArithmeticOperator ( UnitArithmeticOperators . Multiply ) )
326328 {
@@ -330,12 +332,6 @@ readonly partial struct {{unitTypeName}}
330332 {
331333 net7Interfaces . Add ( $ "IDivisionOperators<{ unitTypeName } , { unitTypeName } , { unitTypeName } >") ;
332334 }
333- if ( prop . HasArithmeticOperator ( UnitArithmeticOperators . Multiply ) ||
334- prop . HasArithmeticOperator ( UnitArithmeticOperators . Division ) )
335- {
336- net7Interfaces . Add ( $ "IUnaryPlusOperators<{ unitTypeName } , { unitTypeName } >") ;
337- net7Interfaces . Add ( $ "IUnaryNegationOperators<{ unitTypeName } , { unitTypeName } >") ;
338- }
339335 if ( prop . HasArithmeticOperator ( UnitArithmeticOperators . Increment ) )
340336 {
341337 net7Interfaces . Add ( $ "IIncrementOperators<{ unitTypeName } >") ;
@@ -773,6 +769,9 @@ public static bool TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provid
773769 }
774770 }
775771
772+ """ ) ;
773+ sb . AppendLine ( $$ """
774+ public static {{ unitTypeName }} operator +({{ unitTypeName }} value) => new(({{ innerTypeName }} )(+value.value));
776775""" ) ;
777776 }
778777 if ( prop . HasArithmeticOperator ( UnitArithmeticOperators . Subtraction ) )
@@ -786,17 +785,22 @@ public static bool TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provid
786785 }
787786 }
788787
788+ """ ) ;
789+ string zero = "" ;
790+ if ( innerTypeName == "ulong" )
791+ {
792+ zero = "0UL " ;
793+ }
794+
795+ sb . AppendLine ( $$ """
796+ public static {{ unitTypeName }} operator -({{ unitTypeName }} value) => new(({{ innerTypeName }} )({{ zero }} -value.value));
797+
789798""" ) ;
790799 }
791800
792801 if ( prop . HasArithmeticOperator ( UnitArithmeticOperators . Multiply ) ||
793802 prop . HasArithmeticOperator ( UnitArithmeticOperators . Division ) )
794803 {
795- sb . AppendLine ( $$ """
796- public static {{ unitTypeName }} operator +({{ unitTypeName }} value) => new(({{ innerTypeName }} )(+value.value));
797- public static {{ unitTypeName }} operator -({{ unitTypeName }} value) => new(({{ innerTypeName }} )(-value.value));
798-
799- """ ) ;
800804 if ( prop . HasArithmeticOperator ( UnitArithmeticOperators . Multiply ) )
801805 {
802806 sb . AppendLine ( $$ """
0 commit comments