@@ -968,6 +968,70 @@ public void TestOperatorDeclaration()
968968 "explicit operator bool (global::System.Int32 p0, global::System.String p1)\r \n {\r \n }" ) ;
969969 }
970970
971+ [ Fact ]
972+ public void TestInstanceOperatorsDeclaration ( )
973+ {
974+ var returnType = Generator . TypeExpression ( SpecialType . System_Void ) ;
975+
976+ VerifySyntax < OperatorDeclarationSyntax > (
977+ Generator . OperatorDeclaration ( OperatorKind . Increment , [ ] , returnType ) ,
978+ "void operator ++()\r \n {\r \n }" ) ;
979+
980+ VerifySyntax < OperatorDeclarationSyntax > (
981+ Generator . OperatorDeclaration ( OperatorKind . Decrement , [ ] , returnType ) ,
982+ "void operator --()\r \n {\r \n }" ) ;
983+
984+ var parameterTypes = new [ ]
985+ {
986+ _emptyCompilation . GetSpecialType ( SpecialType . System_Int32 )
987+ } ;
988+ var parameters = parameterTypes . Select ( ( t , i ) => Generator . ParameterDeclaration ( "p" + i , Generator . TypeExpression ( t ) ) ) . ToList ( ) ;
989+
990+ VerifySyntax < OperatorDeclarationSyntax > (
991+ Generator . OperatorDeclaration ( OperatorKind . AdditionAssignment , parameters , returnType ) ,
992+ "void operator +=(global::System.Int32 p0)\r \n {\r \n }" ) ;
993+
994+ VerifySyntax < OperatorDeclarationSyntax > (
995+ Generator . OperatorDeclaration ( OperatorKind . SubtractionAssignment , parameters , returnType ) ,
996+ "void operator -=(global::System.Int32 p0)\r \n {\r \n }" ) ;
997+
998+ VerifySyntax < OperatorDeclarationSyntax > (
999+ Generator . OperatorDeclaration ( OperatorKind . MultiplicationAssignment , parameters , returnType ) ,
1000+ "void operator *=(global::System.Int32 p0)\r \n {\r \n }" ) ;
1001+
1002+ VerifySyntax < OperatorDeclarationSyntax > (
1003+ Generator . OperatorDeclaration ( OperatorKind . DivisionAssignment , parameters , returnType ) ,
1004+ "void operator /=(global::System.Int32 p0)\r \n {\r \n }" ) ;
1005+
1006+ VerifySyntax < OperatorDeclarationSyntax > (
1007+ Generator . OperatorDeclaration ( OperatorKind . ModulusAssignment , parameters , returnType ) ,
1008+ "void operator %=(global::System.Int32 p0)\r \n {\r \n }" ) ;
1009+
1010+ VerifySyntax < OperatorDeclarationSyntax > (
1011+ Generator . OperatorDeclaration ( OperatorKind . ExclusiveOrAssignment , parameters , returnType ) ,
1012+ "void operator ^=(global::System.Int32 p0)\r \n {\r \n }" ) ;
1013+
1014+ VerifySyntax < OperatorDeclarationSyntax > (
1015+ Generator . OperatorDeclaration ( OperatorKind . BitwiseAndAssignment , parameters , returnType ) ,
1016+ "void operator &=(global::System.Int32 p0)\r \n {\r \n }" ) ;
1017+
1018+ VerifySyntax < OperatorDeclarationSyntax > (
1019+ Generator . OperatorDeclaration ( OperatorKind . BitwiseOrAssignment , parameters , returnType ) ,
1020+ "void operator |=(global::System.Int32 p0)\r \n {\r \n }" ) ;
1021+
1022+ VerifySyntax < OperatorDeclarationSyntax > (
1023+ Generator . OperatorDeclaration ( OperatorKind . LeftShiftAssignment , parameters , returnType ) ,
1024+ "void operator <<=(global::System.Int32 p0)\r \n {\r \n }" ) ;
1025+
1026+ VerifySyntax < OperatorDeclarationSyntax > (
1027+ Generator . OperatorDeclaration ( OperatorKind . RightShiftAssignment , parameters , returnType ) ,
1028+ "void operator >>=(global::System.Int32 p0)\r \n {\r \n }" ) ;
1029+
1030+ VerifySyntax < OperatorDeclarationSyntax > (
1031+ Generator . OperatorDeclaration ( OperatorKind . UnsignedRightShiftAssignment , parameters , returnType ) ,
1032+ "void operator >>>=(global::System.Int32 p0)\r \n {\r \n }" ) ;
1033+ }
1034+
9711035 [ Fact , WorkItem ( 63410 , "https://github.com/dotnet/roslyn/issues/63410" ) ]
9721036 public void TestCheckedOperator ( )
9731037 {
0 commit comments