File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -52,6 +52,13 @@ public static string GetName(this ISymbol symbol, bool useMetadataName = false)
5252 { "op_False" , "false" }
5353 } ) ;
5454
55+ /// <summary>
56+ /// The operatorname for user-defined increment and decrement operators are "op_IncrementAssignment" and
57+ /// "op_DecrementAssignment" respectively.
58+ /// Thus we need to handle this explicitly to avoid postfixing them with an "=".
59+ /// </summary>
60+ private static bool isIncrementOrDecrement ( string operatorName ) => operatorName == "++" || operatorName == "--" ;
61+
5562 /// <summary>
5663 /// Convert an operator method name in to a symbolic name.
5764 /// A return value indicates whether the conversion succeeded.
@@ -72,7 +79,7 @@ public static bool TryGetOperatorSymbol(this ISymbol symbol, out string operator
7279 if ( match . Success && methodToOperator . TryGetValue ( $ "op_{ match . Groups [ 2 ] } ", out var rawOperatorName ) )
7380 {
7481 var prefix = match . Groups [ 1 ] . Success ? "checked " : "" ;
75- var postfix = match . Groups [ 3 ] . Success ? "=" : "" ;
82+ var postfix = match . Groups [ 3 ] . Success && ! isIncrementOrDecrement ( rawOperatorName ) ? "=" : "" ;
7683 operatorName = $ "{ prefix } { rawOperatorName } { postfix } ";
7784 return true ;
7885 }
You can’t perform that action at this time.
0 commit comments