New APIs for "User Defined Compound Assignment Operators" feature
- Dominant language
- C#
- Stars
- 20.7k
- Forks
- 4.3k
- PR merge metrics
- PR metrics pending
Description
## Background and Motivation
Speclet: https://github.com/dotnet/csharplang/blob/main/proposals/user-defined-compound-assignment.md
## Proposed APIs
```diff
namespace Microsoft.CodeAnalysis
{
public static class WellKnownMemberNames
{
+ ///
+ /// The name assigned to the '+=' operator.
+ ///
+ public const string AdditionAssignmentOperatorName = "op_AdditionAssignment";
+
+ ///
+ /// The name assigned to the '-=' operator.
+ ///
+ public const string SubtractionAssignmentOperatorName = "op_SubtractionAssignment";
+
+ ///
+ /// The name assigned to the '*=' operator.
+ ///
+ public const string MultiplicationAssignmentOperatorName = "op_MultiplicationAssignment";
+
+ ///
+ /// The name assigned to the '/=' operator.
+ ///
+ public const string DivisionAssignmentOperatorName = "op_DivisionAssignment";
+
+ ///
+ /// The name assigned to the '%=' operator.
+ ///
+ public const string ModulusAssignmentOperatorName = "op_ModulusAssignment";
+
+ ///
+ /// The name assigned to the '&=' operator.
+ ///
+ public const string BitwiseAndAssignmentOperatorName = "op_BitwiseAndAssignment";
+
+ ///
+ /// The name assigned to the '|=' operator.
+ ///
+ public const string BitwiseOrAssignmentOperatorName = "op_BitwiseOrAssignment";
+
+ ///
+ /// The name assigned to the '^=' operator.
+ ///
+ public const string ExclusiveOrAssignmentOperatorName = "op_ExclusiveOrAssignment";
+
+ ///
+ /// The name assigned to the '<<=' operator.
+ ///
+ public const string LeftShiftAssignmentOperatorName = "op_LeftShiftAssignment";
+
+ ///
+ /// The name assigned to the '>>=' operator.
+ ///
+ public const string RightShiftAssignmentOperatorName = "op_RightShiftAssignment";
+
+ ///
+ /// The name assigned to the '>>>=' operator.
+ ///
+ public const string UnsignedRightShiftAssignmentOperatorName = "op_UnsignedRightShiftAssignment";
+
+ ///
+ /// The name assigned to the checked '+=' operator.
+ ///
+ public const string CheckedAdditionAssignmentOperatorName = "op_CheckedAdditionAssignment";
+
+ ///
+ /// The name assigned to the checked '-=' operator.
+ ///
+ public const string CheckedSubtractionAssignmentOperatorName = "op_CheckedSubtractionAssignment";
+
+ ///
+ /// The name assigned to the checked '*=' operator.
+ ///
+ public const string CheckedMultiplicationAssignmentOperatorName = "op_CheckedMultiplicationAssignment";
+
+ ///
+ /// The name assigned to the checked '/=' operator.
+ ///
+ public const string CheckedDivisionAssignmentOperatorName = "op_CheckedDivisionAssignment";
}
}
namespace Microsoft.CodeAnalysis.CSharp
{
public static partial class SyntaxFacts
{
+ public static bool IsOverloadableCompoundAssignmentOperator(SyntaxKind kind)
}
}
namespace Microsoft.CodeAnalysis.Editing;
{
public enum OperatorKind
{
+ ///
+ /// The name assigned to the AdditionAssignment operator.
+ ///
+ AdditionAssignment,
+
+ ///
+ /// The name assigned to the SubtractionAssignment operator.
+ ///
+ SubtractionAssignment,
+
+ ///
+ /// The name assigned to the MultiplicationAssignment operator.
+ ///
+ MultiplicationAssignment,
+
+ ///
+ /// The name assigned to the DivisionAssignment operator.
+ ///
+ DivisionAssignment,
+
+ ///
+ /// The name assigned to the ModulusAssignment operator.
+ ///
+ ModulusAssignment,
+
+ ///
+ /// The name assigned to the ExclusiveOrAssignment operator.
+ ///
+ ExclusiveOrAssignment,
+
+ ///
+ /// The name assigned to the BitwiseAndAssignment operator.
+ ///
+ BitwiseAndAssignment,
+
+ ///
+ /// The name assigned to the BitwiseOrAssignment operator.
+ ///
+ BitwiseOrAssignment,
+
+ ///
+ /// The name assigned to the LeftShiftAssignment operator.
+ ///
+ LeftShiftAssignment,
+
+ ///
+ /// The name assigned to the RightShiftAssignment operator.
+ ///
+ RightShiftAssignment,
+
+ ///
+ /// The name assigned to the UnsignedRightShiftAssignment operator.
+ ///
+ UnsignedRightShiftAssignment,
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.