84 references to ERR_BadUnaryOp
Microsoft.CodeAnalysis.CSharp (10)
Binder\Binder_Expressions.cs (7)
6562
diagnostics.Add(ErrorCode.
ERR_BadUnaryOp
, operatorToken.GetLocation(), SyntaxFacts.GetText(operatorToken.Kind()), leftType);
6579
diagnostics.Add(ErrorCode.
ERR_BadUnaryOp
, node.Location, SyntaxFacts.GetText(operatorToken.Kind()), msgId.Localize());
6655
Error(diagnostics, ErrorCode.
ERR_BadUnaryOp
, node, operatorToken.Text, boundLeft.Display);
9514
DiagnosticInfo diagnosticInfo = new CSDiagnosticInfo(ErrorCode.
ERR_BadUnaryOp
, SyntaxFacts.GetText(operatorToken.Kind()), msgId.Localize());
9524
Error(diagnostics, ErrorCode.
ERR_BadUnaryOp
, operatorToken.GetLocation(), operatorToken.Text, receiver.Display);
9531
Error(diagnostics, ErrorCode.
ERR_BadUnaryOp
, operatorToken.GetLocation(), operatorToken.Text, receiverType);
9538
Error(diagnostics, ErrorCode.
ERR_BadUnaryOp
, operatorToken.GetLocation(), operatorToken.Text, receiverType);
Binder\Binder_Operators.cs (2)
777
ErrorCode.
ERR_BadUnaryOp
; // Operator '{0}' cannot be applied to operand of type '{1}'
3134
Error(diagnostics, ErrorCode.
ERR_BadUnaryOp
, node, SyntaxFacts.GetText(SyntaxKind.IsKeyword), operand.Display);
Errors\ErrorFacts.cs (1)
595
case ErrorCode.
ERR_BadUnaryOp
:
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (4)
CodeGen\CodeGenConditionalOperatorTests.cs (1)
3346
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "?").WithArguments("?", "T").WithLocation(16, 23)
CodeGen\CodeGenFunctionPointersTests.cs (2)
5317
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, $"{op}ptr").WithArguments(op, "delegate*<void>").WithLocation(6, 13)
5338
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, $"ptr{op}").WithArguments(op, "delegate*<void>").WithLocation(6, 13)
CodeGen\CodeGenTupleEqualityTests.cs (1)
785
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "!t1").WithArguments("!", "(int, int)").WithLocation(10, 13)
Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests (12)
Diagnostics\OperationAnalyzerTests.cs (4)
1612
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "-x", new object[] { "-", "A" }).WithLocation(31, 13))
1668
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "null.Length").WithArguments(".", "<null>").WithLocation(8, 17),
1707
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "-f").WithArguments("-", "string").WithLocation(11, 16),
1708
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "f++").WithArguments("++", "string").WithLocation(16, 9))
Emit\NumericIntPtrTests.cs (4)
6019
diagnostic = Diagnostic(ErrorCode.
ERR_BadUnaryOp
, $"{op}operand").WithArguments(op, AsNative(opType));
6245
diagnostic = Diagnostic(ErrorCode.
ERR_BadUnaryOp
, isPrefix ? op + "operand" : "operand" + op).WithArguments(op, opType);
6619
diagnostic = Diagnostic(ErrorCode.
ERR_BadUnaryOp
, op + "operand").WithArguments(op, opType);
8859
static DiagnosticDescription[] getBadUnaryOpDiagnostics(string opType, string op, string operand) => new[] { Diagnostic(ErrorCode.
ERR_BadUnaryOp
, operand).WithArguments(op, AsNative(opType)) };
Semantics\PatternMatchingTests.cs (4)
3616
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "(1, object.Equals) is()").WithArguments("is", "(int, method group)").WithLocation(8, 17)
3656
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "(1, null) is 4").WithArguments("is", "(int, <null>)").WithLocation(9, 13),
3671
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "(1, null) is var x4").WithArguments("is", "(int, <null>)").WithLocation(13, 13)
3692
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "(1, null) is Program").WithArguments("is", "(int, <null>)").WithLocation(6, 13)
Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests (3)
IOperation\IOperationTests_IConditionalAccessExpression.cs (2)
1584
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "?").WithArguments("?", "int").WithLocation(6, 16)
1674
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "?").WithArguments("?", "int").WithLocation(6, 16)
IOperation\IOperationTests_InvalidExpression.cs (1)
282
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "++x").WithArguments("++", "Program").WithLocation(9, 33)
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (49)
Semantics\BindingTests.cs (2)
257
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "!a.E").WithArguments("!", "method group").WithLocation(16, 17),
497
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "null.M").WithArguments(".", "<null>"),
Semantics\ConstantTests.cs (2)
1719
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "-9223372036854775808UL").WithArguments("-", "ulong").WithLocation(8, 28),
1722
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "-9223372036854775808ul").WithArguments("-", "ulong").WithLocation(9, 28),
Semantics\DelegateTypeTests.cs (1)
2066
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "(() => { }).GetType").WithArguments(".", "lambda expression").WithLocation(6, 27)
Semantics\FunctionPointerTests.cs (1)
3145
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "?").WithArguments("?", "delegate*<void>").WithLocation(7, 12),
Semantics\NativeIntegerTests.cs (8)
5153
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "-F1").WithArguments("-", "System.IntPtr").WithLocation(10, 14),
5156
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "+F2").WithArguments("+", "System.UIntPtr").WithLocation(11, 14),
5159
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "-F3").WithArguments("-", "System.IntPtr?").WithLocation(12, 14),
5162
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "+F4").WithArguments("+", "System.UIntPtr?").WithLocation(13, 14),
9510
diagnostic = Diagnostic(ErrorCode.
ERR_BadUnaryOp
, $"{op}operand").WithArguments(op, opType);
9731
diagnostic = Diagnostic(ErrorCode.
ERR_BadUnaryOp
, isPrefix ? op + "operand" : "operand" + op).WithArguments(op, opType);
10106
diagnostic = Diagnostic(ErrorCode.
ERR_BadUnaryOp
, op + "operand").WithArguments(op, opType);
13118
static DiagnosticDescription[] getBadUnaryOpDiagnostics(string opType, string op, string operand) => new[] { Diagnostic(ErrorCode.
ERR_BadUnaryOp
, operand).WithArguments(op, opType) };
Semantics\NullableReferenceTypesTests.cs (8)
1660
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "null!.field").WithArguments(".", "<null>").WithLocation(8, 17),
2007
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "!(a.E!)").WithArguments("!", "method group").WithLocation(14, 17),
2025
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "!(a.F!)").WithArguments("!", "method group").WithLocation(22, 17),
3487
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "(arg => { arg = 2; return arg; } !).ToString").WithArguments(".", "lambda expression").WithLocation(6, 35),
3490
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "(delegate { } !).ToString").WithArguments(".", "anonymous method").WithLocation(8, 17)
3510
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "(()=> { return 1; } !) ?.ToString()").WithArguments("?", "lambda expression").WithLocation(6, 18),
3513
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "(()=> { return 1; } !) ?.ToString()").WithArguments("?", "lambda expression").WithLocation(6, 18)
3630
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "(null, null)! is object").WithArguments("is", "(<null>, <null>)").WithLocation(8, 13),
Semantics\OperatorTests.cs (4)
2973
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "!1").WithArguments("!", "int").WithLocation(7, 12),
2976
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "b++").WithArguments("++", "bool").WithLocation(8, 9),
11479
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "+s1").WithArguments("+", "S1?").WithLocation(3, 10)
11500
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "+s1").WithArguments("+", "S1?").WithLocation(3, 10)
Semantics\RefExtensionMethodsTests.cs (2)
335
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "?").WithArguments("?", "TestType").WithLocation(10, 25));
358
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "?").WithArguments("?", "TestType").WithLocation(10, 25));
Semantics\SemanticErrorTests.cs (17)
1077
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "!q").WithArguments("!", "object").WithLocation(9, 17),
1089
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "obj++").WithArguments("++", "object").WithLocation(16, 13),
1092
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "--obj").WithArguments("--", "object").WithLocation(17, 13),
1156
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "+M").WithArguments("+", "method group"),
1158
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "+(() => { })").WithArguments("+", "lambda expression"));
1175
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, ".").WithArguments(".", "void"));
1192
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, ".").WithArguments(".", "void"));
1209
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "null.Length").WithArguments(".", "<null>"));
1228
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "arg => { arg = 2; return arg; }.ToString").WithArguments(".", "lambda expression"),
1229
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "delegate { }.ToString").WithArguments(".", "anonymous method"));
23894
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "?").WithArguments("?", "int").WithLocation(13, 21),
23900
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "?").WithArguments("?", "void").WithLocation(17, 24),
23906
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "()=> { return 1; } ?.ToString()").WithArguments("?", "lambda expression").WithLocation(19, 18)
24004
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "?").WithArguments("?", "int").WithLocation(16, 21),
24010
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "?").WithArguments("?", "void").WithLocation(20, 24),
24016
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "()=> { return 1; } ?[1,2]").WithArguments("?", "lambda expression").WithLocation(22, 18),
24019
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "?").WithArguments("?", "<null>").WithLocation(24, 22)
Semantics\TargetTypedDefaultTests.cs (1)
2112
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "!Main").WithArguments("!", "method group").WithLocation(6, 13),
Semantics\UnsafeTests.cs (1)
9071
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "i1.ToString").WithArguments(".", "int*"));
Semantics\Utf8StringsLiteralsTests.cs (2)
4181
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "x++").WithArguments("++", "System.ReadOnlySpan<byte>").WithLocation(13, 9),
4184
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "y++").WithArguments("++", "System.ReadOnlySpan<byte>").WithLocation(14, 9),
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (5)
Symbols\CheckedUserDefinedOperatorsTests.cs (1)
3775
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, op + "x").WithArguments(op, "C0").WithLocation(11, 26)
Symbols\DefaultInterfaceImplementationTests.cs (1)
47078
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "-x").WithArguments("-", "Test2").WithLocation(8, 16)
Symbols\EnumTests.cs (1)
148
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "~e").WithArguments("~", "E"));
Symbols\ExtensionMethodTests.cs (1)
1158
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "!o.E").WithArguments("!", "method group").WithLocation(10, 17),
Symbols\Source\EventTests.cs (1)
1185
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, "E++").WithArguments("++", "System.Action"),
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (1)
Diagnostics\DiagnosticTest.cs (1)
207
Diagnostic(ErrorCode.
ERR_BadUnaryOp
, @"null.Length").WithArguments(".", "<null>"));