Binder\Binder.cs (10)
534internal static void Error(BindingDiagnosticBag diagnostics, ErrorCode code, CSharpSyntaxNode syntax)
539internal static void Error(BindingDiagnosticBag diagnostics, ErrorCode code, CSharpSyntaxNode syntax, params object[] args)
544internal static void Error(BindingDiagnosticBag diagnostics, ErrorCode code, SyntaxToken token)
549internal static void Error(BindingDiagnosticBag diagnostics, ErrorCode code, SyntaxToken token, params object[] args)
554internal static void Error(BindingDiagnosticBag diagnostics, ErrorCode code, SyntaxNodeOrToken syntax)
561internal static void Error(BindingDiagnosticBag diagnostics, ErrorCode code, SyntaxNodeOrToken syntax, params object[] args)
568internal static void Error(BindingDiagnosticBag diagnostics, ErrorCode code, Location location)
573internal static void Error(BindingDiagnosticBag diagnostics, ErrorCode code, Location location, params object[] args)
753? ErrorCode.ERR_UnmanagedCallersOnlyMethodsCannotBeConvertedToDelegate
754: ErrorCode.ERR_UnmanagedCallersOnlyMethodsCannotBeCalledDirectly,
Binder\Binder.ValueChecks.cs (142)
566Error(diagnostics, ErrorCode.ERR_BadSKknown, node, ns.NamespaceSymbol, MessageID.IDS_SK_NAMESPACE.Localize(), MessageID.IDS_SK_VARIABLE.Localize());
571Error(diagnostics, ErrorCode.ERR_BadSKknown, node, type.Type, MessageID.IDS_SK_TYPE.Localize(), MessageID.IDS_SK_VARIABLE.Localize());
600var errorCode = GetRangeLvalueError(valueKind);
601if (errorCode is ErrorCode.ERR_InvalidAddrOp or ErrorCode.ERR_RefLocalOrParamExpected)
617Error(diagnostics, ErrorCode.ERR_UnboxNotLValue, node);
637Error(diagnostics, ErrorCode.ERR_RefLocalOrParamExpected, node);
649Error(diagnostics, ErrorCode.ERR_RefLocalOrParamExpected, node);
674Error(diagnostics, ErrorCode.ERR_RefLocalOrParamExpected, node);
772Error(diagnostics, ErrorCode.ERR_RefLocalOrParamExpected, node);
792var errorCode = GetThisLvalueError(valueKind, isValueType, isPrimaryConstructorParameter);
793if (errorCode is ErrorCode.ERR_InvalidAddrOp or ErrorCode.ERR_IncrementLvalueExpected or ErrorCode.ERR_RefReturnThis or ErrorCode.ERR_RefLocalOrParamExpected or ErrorCode.ERR_RefLvalueExpected)
808Error(diagnostics, ErrorCode.ERR_BadSKknown, expr.Syntax, ((BoundNamespaceExpression)expr).NamespaceSymbol, MessageID.IDS_SK_NAMESPACE.Localize(), MessageID.IDS_SK_VARIABLE.Localize());
811Error(diagnostics, ErrorCode.ERR_BadSKunknown, expr.Syntax, expr.Type, MessageID.IDS_SK_TYPE.Localize());
822Error(diagnostics, ErrorCode.WRN_AddressOfInAsync, node);
834diagnostics.Add(ErrorCode.WRN_AssignmentToLockOrDispose, local.Syntax.Location, localSymbol);
850diagnostics.Add(ErrorCode.ERR_RefLocalOrParamExpected, node.Location);
884Error(diagnostics, inUnsafeRegion ? ErrorCode.WRN_RefReturnLocal2 : ErrorCode.ERR_RefReturnLocal2, local.Syntax, localSymbol);
888Error(diagnostics, inUnsafeRegion ? ErrorCode.WRN_RefReturnLocal : ErrorCode.ERR_RefReturnLocal, node, localSymbol);
895Error(diagnostics, inUnsafeRegion ? ErrorCode.WRN_RefReturnNonreturnableLocal2 : ErrorCode.ERR_RefReturnNonreturnableLocal2, local.Syntax, localSymbol);
899Error(diagnostics, inUnsafeRegion ? ErrorCode.WRN_RefReturnNonreturnableLocal : ErrorCode.ERR_RefReturnNonreturnableLocal, node, localSymbol);
904Error(diagnostics, inUnsafeRegion ? ErrorCode.WRN_EscapeVariable : ErrorCode.ERR_EscapeVariable, node, localSymbol);
916Error(diagnostics, ErrorCode.WRN_AddressOfInAsync, node);
930Error(diagnostics, ErrorCode.ERR_RefLocalOrParamExpected, node);
970diagnostics.Add(ErrorCode.WRN_AssignmentToLockOrDispose, parameter.Syntax.Location, parameterSymbol.Name);
984ErrorCode errorCode;
988errorCode = ErrorCode.ERR_RefReturnReadonlyPrimaryConstructorParameter2;
992errorCode = ErrorCode.ERR_RefReadonlyPrimaryConstructorParameter2;
996errorCode = ErrorCode.ERR_AssgReadonlyPrimaryConstructorParameter2;
1003ErrorCode errorCode;
1007errorCode = ErrorCode.ERR_RefReturnReadonlyPrimaryConstructorParameter;
1011errorCode = ErrorCode.ERR_RefReadonlyPrimaryConstructorParameter;
1015errorCode = ErrorCode.ERR_AssgReadonlyPrimaryConstructorParameter;
1067Error(diagnostics, _inUnsafeRegion ? ErrorCode.WRN_EscapeVariable : ErrorCode.ERR_EscapeVariable, node, parameter);
1090Error(diagnostics, inUnsafeRegion ? ErrorCode.WRN_RefReturnStructThis : ErrorCode.ERR_RefReturnStructThis, node);
1097(checkingReceiver: true, isRefScoped: true, inUnsafeRegion: false, _) => (ErrorCode.ERR_RefReturnScopedParameter2, parameter.Syntax),
1098(checkingReceiver: true, isRefScoped: true, inUnsafeRegion: true, _) => (ErrorCode.WRN_RefReturnScopedParameter2, parameter.Syntax),
1099(checkingReceiver: true, isRefScoped: false, inUnsafeRegion: false, ReturnOnlyScope) => (ErrorCode.ERR_RefReturnOnlyParameter2, parameter.Syntax),
1100(checkingReceiver: true, isRefScoped: false, inUnsafeRegion: true, ReturnOnlyScope) => (ErrorCode.WRN_RefReturnOnlyParameter2, parameter.Syntax),
1101(checkingReceiver: true, isRefScoped: false, inUnsafeRegion: false, _) => (ErrorCode.ERR_RefReturnParameter2, parameter.Syntax),
1102(checkingReceiver: true, isRefScoped: false, inUnsafeRegion: true, _) => (ErrorCode.WRN_RefReturnParameter2, parameter.Syntax),
1103(checkingReceiver: false, isRefScoped: true, inUnsafeRegion: false, _) => (ErrorCode.ERR_RefReturnScopedParameter, node),
1104(checkingReceiver: false, isRefScoped: true, inUnsafeRegion: true, _) => (ErrorCode.WRN_RefReturnScopedParameter, node),
1105(checkingReceiver: false, isRefScoped: false, inUnsafeRegion: false, ReturnOnlyScope) => (ErrorCode.ERR_RefReturnOnlyParameter, node),
1106(checkingReceiver: false, isRefScoped: false, inUnsafeRegion: true, ReturnOnlyScope) => (ErrorCode.WRN_RefReturnOnlyParameter, node),
1107(checkingReceiver: false, isRefScoped: false, inUnsafeRegion: false, _) => (ErrorCode.ERR_RefReturnParameter, node),
1108(checkingReceiver: false, isRefScoped: false, inUnsafeRegion: true, _) => (ErrorCode.WRN_RefReturnParameter, node)
1173Error(diagnostics, ErrorCode.ERR_RefLocalOrParamExpected, node);
1376Error(diagnostics, ErrorCode.ERR_WinRtEventPassedByRef, eventSyntax);
1440Error(diagnostics, ErrorCode.ERR_ReturnNotLValue, callSyntaxOpt, methodSymbol);
1458Error(diagnostics, ErrorCode.ERR_RefLocalOrParamExpected, node);
1491Error(diagnostics, ErrorCode.ERR_ReturnNotLValue, expr.Syntax, propertySymbol);
1495Error(diagnostics, ErrorCode.ERR_RefProperty, node);
1522Error(diagnostics, ErrorCode.ERR_AssgReadonlyProp, node, propertySymbol);
1532Error(diagnostics, ErrorCode.ERR_AssignmentInitOnly, node, propertySymbol);
1553Error(diagnostics, ErrorCode.ERR_BadProtectedAccess, node, propertySymbol, accessThroughType, this.ContainingType);
1557Error(diagnostics, ErrorCode.ERR_InaccessibleSetter, node, propertySymbol);
1587Error(diagnostics, ErrorCode.ERR_PropertyLacksGet, node, propertySymbol);
1602Error(diagnostics, ErrorCode.ERR_BadProtectedAccess, node, propertySymbol, accessThroughType, this.ContainingType);
1606Error(diagnostics, ErrorCode.ERR_InaccessibleGetter, node, propertySymbol);
1626Error(diagnostics, ErrorCode.ERR_RefLocalOrParamExpected, node);
1697Error(diagnostics, ErrorCode.ERR_AbstractBaseCall, node, propertyOrEventSymbolOpt ?? member);
2371ErrorCode errorCode = GetStandardCallEscapeError(checkingReceiver);
2497Error(diagnostics, ErrorCode.ERR_CallArgMixing, syntax, symbol, parameterName);
2568Error(diagnostics, ErrorCode.ERR_CallArgMixing, syntax, symbol, parameterName);
2651private static ErrorCode GetStandardCallEscapeError(bool checkingReceiver)
2653return checkingReceiver ? ErrorCode.ERR_EscapeCall2 : ErrorCode.ERR_EscapeCall;
2683ErrorCode[] ReadOnlyLocalErrors =
2685ErrorCode.ERR_RefReadonlyLocalCause,
2686ErrorCode.ERR_AssgReadonlyLocalCause,
2688ErrorCode.ERR_RefReadonlyLocal2Cause,
2689ErrorCode.ERR_AssgReadonlyLocal2Cause
2697private static ErrorCode GetThisLvalueError(BindValueKind kind, bool isValueType, bool isPrimaryConstructorParameter)
2703return ErrorCode.ERR_AssgReadonlyLocal;
2706return ErrorCode.ERR_RefReadonlyLocal;
2709return ErrorCode.ERR_InvalidAddrOp;
2712return isValueType ? ErrorCode.ERR_AssgReadonlyLocal : ErrorCode.ERR_IncrementLvalueExpected;
2716return isPrimaryConstructorParameter ? ErrorCode.ERR_RefReturnPrimaryConstructorParameter : ErrorCode.ERR_RefReturnThis;
2719return ErrorCode.ERR_RefLocalOrParamExpected;
2724return ErrorCode.ERR_RefLvalueExpected;
2730private static ErrorCode GetRangeLvalueError(BindValueKind kind)
2737return ErrorCode.ERR_QueryRangeVariableReadOnly;
2740return ErrorCode.ERR_InvalidAddrOp;
2744return ErrorCode.ERR_RefReturnRangeVariable;
2747return ErrorCode.ERR_RefLocalOrParamExpected;
2752return ErrorCode.ERR_QueryOutRefRangeVariable;
2758private static ErrorCode GetMethodGroupOrFunctionPointerLvalueError(BindValueKind valueKind)
2762return ErrorCode.ERR_RefReadonlyLocalCause;
2766return ErrorCode.ERR_AssgReadonlyLocalCause;
2769private static ErrorCode GetStandardLvalueError(BindValueKind kind)
2775return ErrorCode.ERR_AssgLvalueExpected;
2778return ErrorCode.ERR_InvalidAddrOp;
2781return ErrorCode.ERR_IncrementLvalueExpected;
2784return ErrorCode.ERR_FixedNeedsLvalue;
2788return ErrorCode.ERR_RefReturnLvalueExpected;
2791return ErrorCode.ERR_RefLocalOrParamExpected;
2796return ErrorCode.ERR_RefLvalueExpected;
2805private static ErrorCode GetStandardRValueRefEscapeError(uint escapeTo)
2809return ErrorCode.ERR_RefReturnLvalueExpected;
2812return ErrorCode.ERR_EscapeOther;
2828ErrorCode[] ReadOnlyErrors =
2830ErrorCode.ERR_RefReturnReadonly,
2831ErrorCode.ERR_RefReadonly,
2832ErrorCode.ERR_AssgReadonly,
2833ErrorCode.ERR_RefReturnReadonlyStatic,
2834ErrorCode.ERR_RefReadonlyStatic,
2835ErrorCode.ERR_AssgReadonlyStatic,
2836ErrorCode.ERR_RefReturnReadonly2,
2837ErrorCode.ERR_RefReadonly2,
2838ErrorCode.ERR_AssgReadonly2,
2839ErrorCode.ERR_RefReturnReadonlyStatic2,
2840ErrorCode.ERR_RefReadonlyStatic2,
2841ErrorCode.ERR_AssgReadonlyStatic2
2863Error(diagnostics, ErrorCode.ERR_InvalidAddrOp, node);
2869ErrorCode[] ReadOnlyErrors =
2871ErrorCode.ERR_RefReturnReadonlyNotField,
2872ErrorCode.ERR_RefReadonlyNotField,
2873ErrorCode.ERR_AssignReadonlyNotField,
2874ErrorCode.ERR_RefReturnReadonlyNotField2,
2875ErrorCode.ERR_RefReadonlyNotField2,
2876ErrorCode.ERR_AssignReadonlyNotField2,
3934Error(diagnostics, inUnsafeRegion ? ErrorCode.WRN_EscapeVariable : ErrorCode.ERR_EscapeVariable, node, expr.Syntax);
3943Error(diagnostics, inUnsafeRegion ? ErrorCode.WRN_EscapeVariable : ErrorCode.ERR_EscapeVariable, node, localSymbol);
3957Error(diagnostics, inUnsafeRegion ? ErrorCode.WRN_EscapeStackAlloc : ErrorCode.ERR_EscapeStackAlloc, node, expr.Type);
4290diagnostics.Add(ErrorCode.ERR_InternalError, node.Location);
Binder\Binder_Attributes.cs (9)
241Error(diagnostics, ErrorCode.ERR_AttributeCtorInParameter, node, attributeConstructor.ToDisplayString(SymbolDisplayFormat.CSharpErrorMessageFormat));
394Error(diagnostics, ErrorCode.ERR_BadAttributeParamType, syntax, parameter.Name, paramType.Type);
462diagnostics.Add(ErrorCode.ERR_NamedArgumentExpected, argument.Expression.GetLocation());
490Error(diagnostics, ErrorCode.ERR_DuplicateNamedAttributeArgument, argument, argumentName);
644diagnostics.Add(ErrorCode.ERR_BadNamedAttributeArgument,
657diagnostics.Add(ErrorCode.ERR_BadNamedAttributeArgumentType,
735diagnostics.Add(ErrorCode.ERR_BadAttributeArgument, syntax.Location);
1027Binder.Error(diagnostics, ErrorCode.ERR_AttrArgWithTypeVars, node.Syntax, typeOfArgument.ToDisplayString(SymbolDisplayFormat.CSharpErrorMessageFormat));
1111Binder.Error(diagnostics, ErrorCode.ERR_BadAttributeArgument, node.Syntax);
Binder\Binder_Await.cs (22)
161info = new CSDiagnosticInfo(ErrorCode.ERR_BadAwaitInStaticVariableInitializer);
179new CSDiagnosticInfo(ErrorCode.ERR_BadAwaitInQuery) :
180new CSDiagnosticInfo(ErrorCode.ERR_BadAwaitWithoutAsyncLambda, ((LambdaSymbol)method).MessageID.Localize());
185new CSDiagnosticInfo(ErrorCode.ERR_BadAwaitWithoutVoidAsyncMethod) :
186new CSDiagnosticInfo(ErrorCode.ERR_BadAwaitWithoutAsyncMethod, method.ReturnType);
193info = new CSDiagnosticInfo(ErrorCode.ERR_BadAwaitWithoutAsync);
207Error(diagnostics, ErrorCode.ERR_AwaitInUnsafeContext, location);
212Error(diagnostics, ErrorCode.ERR_BadAwaitInLock, location);
217Error(diagnostics, ErrorCode.ERR_BadAwaitInCatchFilter, location);
223Error(diagnostics, ErrorCode.ERR_BadAwaitInFinally, location);
229Error(diagnostics, ErrorCode.ERR_BadAwaitInCatch, location);
305Error(diagnostics, ErrorCode.ERR_BadAwaitArgIntrinsic, node, expression.Display);
328Error(diagnostics, ErrorCode.ERR_BadAwaitArgVoidCall, node);
342Error(diagnostics, ErrorCode.ERR_BadAwaitArg, node, expression.Type);
352Error(diagnostics, ErrorCode.ERR_BadAwaitArg, node, expression.Type);
380Error(diagnostics, ErrorCode.ERR_NoSuchMember, node, awaiterType, WellKnownMemberNames.IsCompleted);
388Error(diagnostics, ErrorCode.ERR_PropertyLacksGet, node, isCompletedProperty);
395Error(diagnostics, ErrorCode.ERR_BadAwaiterPattern, node, awaiterType, awaitedExpressionType);
419Error(diagnostics, ErrorCode.ERR_DoesntImplementAwaitInterface, node, awaiterType, INotifyCompletion);
448Error(diagnostics, ErrorCode.ERR_NoSuchMember, node, awaiterType, WellKnownMemberNames.GetResult);
457Error(diagnostics, ErrorCode.ERR_NoSuchMember, node, awaiterType, WellKnownMemberNames.GetResult);
465Error(diagnostics, ErrorCode.ERR_BadAwaiterPattern, node, awaiterType, awaitedExpressionType);
Binder\Binder_Constraints.cs (21)
77diagnostics.Add(ErrorCode.ERR_DuplicateConstraintClause, clause.Name.Location, name);
89diagnostics.Add(ErrorCode.ERR_TyVarNotFoundInConstraint, clause.Name.Location, name, containingSymbol.ConstructedFrom());
201diagnostics.Add(ErrorCode.ERR_NewBoundWithVal, syntax.GetFirstToken().GetLocation());
205diagnostics.Add(ErrorCode.ERR_NewBoundWithUnmanaged, syntax.GetFirstToken().GetLocation());
210diagnostics.Add(ErrorCode.ERR_NewBoundMustBeLast, syntax.GetFirstToken().GetLocation());
220diagnostics.Add(ErrorCode.ERR_DefaultConstraintOverrideOnly, syntax.GetLocation());
312diagnostics.Add(ErrorCode.ERR_OverrideWithConstraints, syntax.GetLocation());
319diagnostics.Add(ErrorCode.ERR_TypeConstraintsMustBeUniqueAndFirst, syntax.GetLocation());
414diagnostics.Add(ErrorCode.ERR_BadVisBound, location, containingSymbol, constraintType.Type);
430diagnostics.Add(ErrorCode.ERR_FileTypeDisallowedInSignature, location, constraintType.Type, containingSymbol);
458Error(diagnostics, ErrorCode.ERR_DuplicateBound, syntax, type.Type.SetUnknownNullabilityForReferenceTypes(), typeParameter.Name);
472Error(diagnostics, ErrorCode.ERR_ClassBoundNotFirst, syntax, type.Type);
487Error(diagnostics, ErrorCode.ERR_RefValBoundWithClass, syntax, type.Type);
496Error(diagnostics, ErrorCode.ERR_RefValBoundWithClass, syntax, type.Type);
502Error(diagnostics, ErrorCode.ERR_UnmanagedBoundWithClass, syntax, type.Type);
537Error(diagnostics, ErrorCode.ERR_SpecialTypeAsBound, syntax, type);
552Error(diagnostics, ErrorCode.ERR_DynamicTypeAsBound, syntax);
563Error(diagnostics, ErrorCode.ERR_ConstraintIsStaticClass, syntax, type);
572Error(diagnostics, ErrorCode.ERR_BadBoundType, syntax, type);
579Error(diagnostics, ErrorCode.ERR_BadConstraintType, syntax.GetLocation());
592Error(diagnostics, ErrorCode.ERR_ConstructedDynamicTypeAsBound, syntax, type);
Binder\Binder_Conversions.cs (36)
328Error(diagnostics, ErrorCode.ERR_RuntimeDoesNotSupportStaticAbstractMembersInInterfaces, syntax);
393Error(diagnostics, ErrorCode.ERR_ImplicitObjectCreationIllegalTargetType, syntax, type);
397Error(diagnostics, ErrorCode.ERR_UnsafeTypeInObjectCreation, syntax, type);
436ErrorCode.ERR_NoImplicitConvTargetTypedConditional,
686Error(diagnostics, ErrorCode.WRN_MethGrpToNonDel, syntax, ((BoundMethodGroup)source).Name, destination);
765ErrorCode.ERR_ScopedMismatchInParameterOfTarget :
766ErrorCode.WRN_ScopedMismatchInParameterOfTarget,
839Error(diagnostics, ErrorCode.WRN_OptionalParamValueMismatch, lambdaParameter.Locations[0], p + 1, lambdaParamDefault, delegateParamDefault ?? ((object)MessageID.IDS_Missing.Localize()));
846Error(diagnostics, ErrorCode.WRN_ParamsArrayInLambdaOnly, lambdaParameter.Locations[0], p + 1);
1148diagnostics.Add(ErrorCode.ERR_QueryNoProvider, node.Location, receiverOpt.Type, memberSymbol.Name);
1153diagnostics.Add(ErrorCode.ERR_ObjectRequired, node.Location, memberSymbol);
1162diagnostics.Add(ErrorCode.ERR_InitializerAddHasWrongSignature, node.Location, memberSymbol);
1167diagnostics.Add(ErrorCode.ERR_BadAwaitArg, node.Location, receiverOpt.Type);
1171diagnostics.Add(ErrorCode.ERR_ObjectProhibited, node.Location, memberSymbol);
1178diagnostics.Add(ErrorCode.ERR_ObjectRequired, node.Location, memberSymbol);
1191ErrorCode code = InFieldInitializer ? ErrorCode.ERR_FieldInitRefNonstatic : ErrorCode.ERR_ObjectRequired;
1200Error(diagnostics, ErrorCode.ERR_ObjectRequired, node, memberSymbol);
1220Error(diagnostics, ErrorCode.ERR_BadAccess, node, memberSymbol);
1354Error(diagnostics, ErrorCode.ERR_BadRetType, errorLocation, method, method.ReturnType);
1363Error(diagnostics, ErrorCode.ERR_CannotUseReducedExtensionMethodInAddressOf, errorLocation);
1374Error(diagnostics, ErrorCode.ERR_FuncPtrMethMustBeStatic, errorLocation, method);
1406static ErrorCode getMethodMismatchErrorCode(TypeKind type)
1409TypeKind.Delegate => ErrorCode.ERR_MethDelegateMismatch,
1410TypeKind.FunctionPointer => ErrorCode.ERR_MethFuncPtrMismatch,
1414static ErrorCode getRefMismatchErrorCode(TypeKind type)
1417TypeKind.Delegate => ErrorCode.ERR_DelegateRefMismatch,
1418TypeKind.FunctionPointer => ErrorCode.ERR_FuncPtrRefMismatch,
1460Error(diagnostics, ErrorCode.ERR_DelegateOnConditional, location, selectedMethod);
1468Error(diagnostics, ErrorCode.ERR_PartialMethodToDelegate, location, selectedMethod);
1517diagnostics.Add(ErrorCode.ERR_MethDelegateMismatch, delegateMismatchLocation, boundMethodGroup.Name, delegateType);
1664Error(diagnostics, ErrorCode.ERR_ConstOutOfRange, syntax, sourceValue.Value + "M", destination!);
1672Error(diagnostics, ErrorCode.ERR_ConstOutOfRange, syntax, sourceValue.Value!, destination!);
1683Error(diagnostics, ErrorCode.WRN_ConstOutOfRangeChecked, syntax, sourceValue.Value!, destination!);
1688Error(diagnostics, ErrorCode.ERR_ConstOutOfRangeChecked, syntax, sourceValue.Value!, destination!);
Binder\Binder_Crefs.cs (13)
54diagnostics.Add(ErrorCode.WRN_BadXMLRef, syntax.Location, noTrivia.ToFullString());
107diagnostics.Add(ErrorCode.WRN_BadXMLRef, crefSyntax.Location, noTrivia.ToFullString());
136diagnostics.Add(ErrorCode.WRN_BadXMLRef, crefSyntax.Location, noTrivia.ToFullString());
543diagnostics.Add(ErrorCode.WRN_UnqualifiedNestedTypeInCref, parameterListSyntax.Parameters[i].Location);
706diagnostics.Add(ErrorCode.WRN_BadXMLRefTypeVar, crefSyntax.Location, crefSyntax.ToString());
712diagnostics.Add(ErrorCode.WRN_AmbiguousXMLReference, crefSyntax.Location, crefSyntax.ToString(), symbol, symbols[otherIndex]);
721diagnostics.Add(ErrorCode.WRN_BadXMLRefTypeVar, crefSyntax.Location, crefSyntax.ToString());
868diagnostics.Add(ErrorCode.WRN_AmbiguousXMLReference, crefSyntax.Location, crefSyntax.ToString(), ambiguityWinner, viable[1]);
979diagnostics.Add(ErrorCode.WRN_BadXMLRefReturnType, typeSyntax.Location);
983diagnostics.Add(ErrorCode.WRN_BadXMLRefParamType, typeSyntax.Location, typeSyntax.ToString(), crefSyntax.ToString());
1003switch ((ErrorCode)diag.Code)
1005case ErrorCode.ERR_DeprecatedSymbolStr:
1006case ErrorCode.ERR_DeprecatedCollectionInitAddStr:
Binder\Binder_Deconstruct.cs (18)
60Error(diagnostics, ErrorCode.ERR_DeclarationExpressionNotPermitted, declaration);
64Error(diagnostics, ErrorCode.ERR_DeclarationExpressionNotPermitted, declaration);
228Error(diagnostics, ErrorCode.ERR_DeconstructRequiresExpression, boundRHS.Syntax);
264Error(diagnostics, ErrorCode.ERR_DeconstructWrongCardinality, syntax, tupleOrDeconstructedTypes.Length, variables.Count);
272Error(diagnostics, ErrorCode.ERR_DeconstructTooFewElements, syntax);
414Error(diagnostics, ErrorCode.ERR_TypeInferenceFailedForImplicitlyTypedDeconstructionVariable, pending.Syntax, "_");
496Error(diagnostics, ErrorCode.ERR_DeconstructRequiresExpression, element.Syntax);
514Error(diagnostics, ErrorCode.ERR_DeconstructRequiresExpression, element.Syntax);
624Error(diagnostics, ErrorCode.ERR_CannotDeconstructDynamic, rightSyntax);
719Error(diagnostics, ErrorCode.ERR_MissingDeconstruct, rightSyntax, receiver.Type!, numParameters);
758Error(diagnostics, ErrorCode.ERR_DeconstructionVarFormDisallowsSpecificType, component.Designation);
781Error(diagnostics, ErrorCode.ERR_TupleElementNamesInDeconstruction, arg.NameColon);
824diagnostics.Add(ErrorCode.ERR_ScopedDiscard, scopedType.ScopedKeyword.GetLocation());
830diagnostics.Add(ErrorCode.ERR_DeconstructVariableCannotBeByRef, refType.RefKeyword.GetLocation());
888diagnostics.Add(ErrorCode.ERR_DeconstructVariableCannotBeByRef, refType.RefKeyword.GetLocation());
899diagnostics.Add(ErrorCode.ERR_ScopedRefAndRefStructOnly, typeSyntax.Location);
932diagnostics.Add(ErrorCode.ERR_UnexpectedToken, scopedType.ScopedKeyword.GetLocation(), scopedType.ScopedKeyword.ValueText);
938diagnostics.Add(ErrorCode.ERR_UnexpectedToken, refType.RefKeyword.GetLocation(), refType.RefKeyword.ValueText);
Binder\Binder_Expressions.cs (183)
294diagnostics.Add(ErrorCode.ERR_SwitchExpressionNoBestType, exprSyntax.SwitchKeyword.GetLocation());
312if (op.NoCommonTypeError == ErrorCode.ERR_InvalidQM && trueArg is Symbol trueSymbol && falseArg is Symbol falseSymbol)
350diagnostics.Add(ErrorCode.ERR_DefaultLiteralNoTargetType, defaultExpr.Syntax.GetLocation());
373diagnostics.Add(ErrorCode.ERR_ImplicitObjectCreationNoTargetType, expr.Syntax.GetLocation(), expr.Display);
410diagnostics.Add(ErrorCode.ERR_CannotInferDelegateType, syntax.GetLocation());
523Error(diagnostics, ErrorCode.ERR_IllegalArglist, node);
574return BindUnexpectedArrayInitializer((InitializerExpressionSyntax)node, diagnostics, ErrorCode.ERR_ArrayInitInBadPlace);
801diagnostics.Add(ErrorCode.ERR_InternalError, node.Location);
816diagnostics.Add(ErrorCode.ERR_UnexpectedToken, firstToken.GetLocation(), firstToken.ValueText);
825diagnostics.Add(ErrorCode.ERR_UnexpectedToken, firstToken.GetLocation(), firstToken.ValueText);
832diagnostics.Add(ErrorCode.ERR_UnexpectedToken, firstToken.GetLocation(), firstToken.ValueText);
843diagnostics.Add(ErrorCode.ERR_ThrowMisplaced, node.ThrowKeyword.GetLocation());
896Error(diagnostics, ErrorCode.ERR_DeclarationExpressionNotPermitted, node);
1003diagnostics.Add(ErrorCode.ERR_VoidInTuple, argumentSyntax.Location);
1213Error(diagnostics, ErrorCode.ERR_MethodArgCantBeRefAny, node, argument.Type);
1283Error(diagnostics, ErrorCode.ERR_ArgsInvalid, node);
1297Error(diagnostics, ErrorCode.ERR_SpecialByRefInLambda, node, runtimeArgumentHandleType);
1346diagnostics.Add(ErrorCode.ERR_BadDynamicTypeof, node.Location);
1352diagnostics.Add(ErrorCode.ERR_BadNullableTypeof, node.Location);
1372diagnostics.Add(ErrorCode.ERR_AttrDependentTypeNotAllowed, errorLocation, type);
1378diagnostics.Add(ErrorCode.ERR_AttrTypeArgCannotBeTypeVar, errorLocation, type);
1420diagnostics.Add(ErrorCode.ERR_ManagedAddr, location, type);
1424diagnostics.Add(ErrorCode.WRN_ManagedAddr, location, type);
1589Error(diagnostics, ErrorCode.ERR_QueryOuterKey, node, name);
1593Error(diagnostics, ErrorCode.ERR_QueryInnerKey, node, name);
1597Error(diagnostics, ErrorCode.ERR_NameNotInContext, node, name);
1868Error(diagnostics, ErrorCode.ERR_VariableUsedBeforeDeclarationAndHidesField, node, node, possibleField);
1872Error(diagnostics, ErrorCode.ERR_VariableUsedBeforeDeclaration, node, node);
1902Error(diagnostics, ErrorCode.ERR_AnonDelegateCantUseLocal, node, localSymbol);
1921Error(diagnostics, ErrorCode.ERR_InvalidPrimaryConstructorParameterReference, node, parameter);
1934Error(diagnostics, parameter.Type.IsRefLikeType ? ErrorCode.ERR_AnonDelegateCantUseRefLike : ErrorCode.ERR_AnonDelegateCantUse, node, parameter.Name);
1945Error(diagnostics, parameter.Type.IsRefLikeType ? ErrorCode.ERR_UnsupportedPrimaryConstructorParameterCapturingRefLike : ErrorCode.ERR_UnsupportedPrimaryConstructorParameterCapturingRef, node, parameter.Name);
1956Error(diagnostics, ErrorCode.ERR_AnonDelegateCantUseStructPrimaryConstructorParameterInMember, node);
1960Error(diagnostics, ErrorCode.ERR_AnonDelegateCantUseStructPrimaryConstructorParameterCaptured, node);
2046Error(diagnostics, ErrorCode.ERR_SimpleProgramLocalIsReferencedOutsideOfTopLevelStatement, node, node);
2083Error(diagnostics, ErrorCode.ERR_FieldInitRefNonstatic, node, member);
2089Error(diagnostics, ErrorCode.ERR_ObjectRequired, node, member);
2102Error(diagnostics, ErrorCode.ERR_ObjectRequired, node, member);
2208Error(diagnostics, ErrorCode.ERR_LabelNotFound, node, labelName);
2264Error(diagnostics, inStaticContext ? ErrorCode.ERR_ThisInStaticMeth : ErrorCode.ERR_ThisInBadContext, node);
2286Error(diagnostics, ErrorCode.ERR_ThisStructNotInAnonMeth, thisOrBaseToken);
2302Error(diagnostics, inStaticContext ? ErrorCode.ERR_BaseInStaticMeth : ErrorCode.ERR_BaseInBadContext, node.Token);
2307Error(diagnostics, ErrorCode.ERR_NoBaseClass, node);
2312Error(diagnostics, ErrorCode.ERR_BaseIllegal, node.Token);
2363Error(diagnostics, ErrorCode.ERR_ValConstraintNotSatisfied, node, nullableType, nullableType.TypeParameters.Single(), indexType);
2443Error(diagnostics, ErrorCode.ERR_ValConstraintNotSatisfied, node, nullableType, nullableType.TypeParameters.Single(), rangeType);
2470Error(diagnostics, ErrorCode.ERR_ValConstraintNotSatisfied, operand, nullableType, nullableType.TypeParameters.Single(), indexType);
2531diagnostics.Add(ErrorCode.ERR_ConvertToStaticClass, syntax.Location, targetType);
2537diagnostics.Add(ErrorCode.ERR_ValueCantBeNull, syntax.Location, targetType);
2548diagnostics.Add(ErrorCode.ERR_AmbigUDConv, syntax.Location, originalUserDefinedConversions[0], originalUserDefinedConversions[1], operand.Display, targetType);
2555diagnostics.Add(ErrorCode.ERR_NoExplicitConv, syntax.Location, distinguisher1.First, distinguisher1.Second);
2568diagnostics.Add(ErrorCode.ERR_NoExplicitConv, syntax.Location, MessageID.IDS_SK_METHOD.Localize(), targetType);
2590Error(diagnostics, ErrorCode.ERR_ConversionNotTupleCompatible, syntax, tuple.Arguments.Length, targetType);
2600Error(diagnostics, ErrorCode.ERR_StackAllocConversionNotPossible, syntax, stackAllocExpression.ElementType, targetType);
2611var errorCode = targetType.TypeKind switch
2613TypeKind.FunctionPointer => ErrorCode.ERR_MethFuncPtrMismatch,
2614TypeKind.Delegate => ErrorCode.ERR_CannotConvertAddressOfToDelegate,
2615_ => ErrorCode.ERR_AddressOfToNonFunctionPointer
2625diagnostics.Add(ErrorCode.ERR_NoExplicitConv, syntax.Location, distinguisher.First, distinguisher.Second);
2899diagnostics.Add(ErrorCode.ERR_ScopedDiscard, scopedType.ScopedKeyword.GetLocation());
2905diagnostics.Add(ErrorCode.ERR_OutVariableCannotBeByRef, refType.Location);
2947diagnostics.Add(ErrorCode.ERR_OutVariableCannotBeByRef, refType.Location);
2972diagnostics.Add(ErrorCode.ERR_ScopedRefAndRefStructOnly, typeSyntax.Location);
2992diagnostics.Add(ErrorCode.ERR_UnexpectedToken, scopedType.ScopedKeyword.GetLocation(), scopedType.ScopedKeyword.ValueText);
2998diagnostics.Add(ErrorCode.ERR_UnexpectedToken, refType.RefKeyword.GetLocation(), refType.RefKeyword.ValueText);
3032Error(diagnostics, forUsingExpression ? ErrorCode.ERR_BadSpecialByRefUsing : ErrorCode.ERR_BadSpecialByRefLocal, syntax, type);
3118Error(diagnostics, ErrorCode.ERR_NamedArgumentSpecificationBeforeFixedArgument, argumentSyntax,
3348Error(diagnostics, ErrorCode.ERR_MissingArraySize, firstRankSpecifier);
3363Error(diagnostics, ErrorCode.ERR_InvalidArray, arg);
3389Error(diagnostics, ErrorCode.ERR_NegativeArraySize, dimension);
3419Error(diagnostics, ErrorCode.ERR_ImplicitlyTypedArrayNoBestType, node);
3426Error(diagnostics, ErrorCode.ERR_ArrayElementCantBeRefAny, node, bestType);
3446Error(diagnostics, ErrorCode.ERR_ImplicitlyTypedArrayNoBestType, node);
3521Error(diagnostics, ErrorCode.ERR_ArrayInitializerExpected, expression);
3624Error(diagnostics, ErrorCode.ERR_ArrayInitializerIncorrectLength, node, knownSizeOpt.Value);
3658ErrorCode errorCode,
3738Error(diagnostics, ErrorCode.ERR_ConstantExpected, size.Syntax);
3772Error(diagnostics, ErrorCode.ERR_BadIndexCount, nonNullSyntax, type.Rank);
3792Error(diagnostics, ErrorCode.ERR_BadStackAllocExpr, typeSyntax);
3819Error(diagnostics, ErrorCode.ERR_BadStackAllocExpr, typeSyntax);
3849Error(diagnostics, ErrorCode.ERR_NegativeStackAllocSize, countSyntax);
3855Error(diagnostics, ErrorCode.ERR_MissingArraySize, rankSpecifiers[0]);
3884Error(diagnostics, ErrorCode.ERR_StackallocInCatchFinally, node);
3975Error(diagnostics, ErrorCode.ERR_ConstantExpected, sizeOpt.Syntax);
3980Error(diagnostics, ErrorCode.ERR_ArrayInitializerIncorrectLength, node, constantSizeOpt.Value);
4165diagnostics.Add(ErrorCode.ERR_ObjectCallingBaseConstructor, constructor.Locations[0], containingType);
4176diagnostics.Add(ErrorCode.ERR_StructWithBaseConstructorCall, constructor.Locations[0], containingType);
4218diagnostics.Add(ErrorCode.ERR_NoDynamicPhantomOnBaseCtor, errorLocation);
4255diagnostics.Add(ErrorCode.ERR_RecursiveConstructorCall,
4316diagnostics.Add(ErrorCode.WRN_CapturedPrimaryConstructorParameterPassedToBase, boundParameter.Syntax.Location, parameter);
4330diagnostics.Add(ErrorCode.ERR_ChainingToSetsRequiredMembersRequiresSetsRequiredMembers, errorLocation);
4380diagnostics.Add(ErrorCode.ERR_CopyConstructorMustInvokeBaseCopyConstructor, errorLocation);
4389diagnostics.Add(ErrorCode.ERR_CopyConstructorMustInvokeBaseCopyConstructor, errorLocation);
4437diagnostics.Add(ErrorCode.ERR_AnnotationDisallowedInObjectCreation, node.Location);
4464diagnostics.Add(ErrorCode.ERR_UnsafeTypeInObjectCreation, node.Location, type));
4472diagnostics.Add(ErrorCode.ERR_InvalidObjectCreation, node.Type.Location));
4501diagnostics.Add(ErrorCode.ERR_BadCtorArgCount, node.Location, type, 0);
4514diagnostics.Add(ErrorCode.ERR_MethodNameExpected, loc);
4520Error(diagnostics, ErrorCode.ERR_ObjectOrCollectionInitializerWithDelegateCreation, node);
4590diagnostics.Add(ErrorCode.ERR_MethodNameExpected, argument.Syntax.Location);
4625diagnostics.Add(ErrorCode.ERR_MethDelegateMismatch, node.Location,
4651diagnostics.Add(ErrorCode.ERR_MethodNameExpected, argument.Syntax.Location);
4672diagnostics.Add(ErrorCode.ERR_InstantiatingStaticClass, node.Location, type);
4677diagnostics.Add(ErrorCode.ERR_NewWithTupleTypeSyntax, node.Type.GetLocation());
4710diagnostics.Add(ErrorCode.ERR_InstantiatingStaticClass, node.Location, type);
4905Error(diagnostics, ErrorCode.ERR_InvalidInitializerElementInitializer, memberInitializer);
5020Error(diagnostics, ErrorCode.ERR_ReadonlyValueTypeInObjectInitializer, leftSyntax, fieldSymbol, fieldSymbol.Type);
5060diagnostics.Add(ErrorCode.ERR_InterpolatedStringsReferencingInstanceCannotBeInObjectInitializers, argument.Syntax.Location);
5130Error(diagnostics, ErrorCode.ERR_ValueTypePropertyInObjectInitializer, memberNameSyntax, propertySymbol, propertySymbol.Type);
5164Error(diagnostics, ErrorCode.ERR_NoSuchMember, memberNameSyntax, implicitReceiver.Type, member);
5173Error(diagnostics, ErrorCode.ERR_MemberCannotBeInitialized, memberNameSyntax, member);
5203Error(diagnostics, ErrorCode.ERR_MemberAlreadyInitialized, memberNameSyntax, memberName);
5280diagnostics.Add(ErrorCode.ERR_RequiredMembersMustBeAssignedValue, initializerExpression.Syntax.Location, requiredMember);
5299diagnostics.Add(ErrorCode.ERR_RequiredMemberMustBeSet, location, member);
5335Error(diagnostics, ErrorCode.ERR_CollectionInitRequiresIEnumerable, initializerSyntax, initializerType);
5417Error(diagnostics, ErrorCode.ERR_InvalidInitializerElementInitializer, elementInitializer);
5462Error(diagnostics, ErrorCode.ERR_EmptyElementInitializer, elementInitializer);
5647diagnostics.Add(ErrorCode.ERR_NoNewAbstract, node.Location, type);
5834diagnostics.Add(ErrorCode.ERR_NoNewAbstract, node.Location, type);
5848Error(diagnostics, ErrorCode.ERR_MissingCoClass, node, coClassType, interfaceType);
5866Error(diagnostics, ErrorCode.ERR_BadCoClassSig, node, coClassType, interfaceType);
5892Error(diagnostics, ErrorCode.ERR_NoExplicitConv, node, distinguisher.First, distinguisher.Second);
5946diagnostics.Add(ErrorCode.ERR_BadCtorArgCount, typeNode.Location, interfaceType, analyzedArguments.Arguments.Count);
5976diagnostics.Add(ErrorCode.ERR_NoNewTyvar, node.Location, typeParameter);
5980diagnostics.Add(ErrorCode.ERR_NewTyvarWithArgs, node.Location, typeParameter);
6118diagnostics.Add(ErrorCode.ERR_BadAccess, errorLocation, result.ValidResult.Member);
6142if ((ErrorCode)diagnostic.Code == ErrorCode.ERR_RequiredMembersInvalid)
6230diagnostics.Add(new CSDiagnosticInfo(ErrorCode.WRN_LowercaseEllSuffix), Location.Create(node.SyntaxTree, new TextSpan(token.Span.End - 1, 1)));
6234diagnostics.Add(new CSDiagnosticInfo(ErrorCode.WRN_LowercaseEllSuffix), Location.Create(node.SyntaxTree, new TextSpan(token.Span.End - 2, 1)));
6484Error(diagnostics, ErrorCode.ERR_TypeArgsNotAllowed, right, right.Identifier.Text, SymbolKind.Property.Localize());
6496Error(diagnostics, ErrorCode.ERR_BadTypeArgument, typeArgumentsSyntax[i], typeArgument.Type);
6562diagnostics.Add(ErrorCode.ERR_BadUnaryOp, operatorToken.GetLocation(), SyntaxFacts.GetText(operatorToken.Kind()), leftType);
6569DiagnosticInfo diagnosticInfo = new CSDiagnosticInfo(ErrorCode.ERR_BadOpOnNullOrDefaultOrNew, SyntaxFacts.GetText(operatorToken.Kind()), boundLeft.Display);
6579diagnostics.Add(ErrorCode.ERR_BadUnaryOp, node.Location, SyntaxFacts.GetText(operatorToken.Kind()), msgId.Localize());
6655Error(diagnostics, ErrorCode.ERR_BadUnaryOp, node, operatorToken.Text, boundLeft.Display);
6782Error(diagnostics, ErrorCode.ERR_LookupInTypeVariable, boundLeft.Syntax, leftType);
6811Error(diagnostics, ErrorCode.WRN_DotOnDefault, node, boundLeft.Type);
6838Error(diagnostics, ErrorCode.ERR_BadSKunknown, methodGroup.NameSyntax, method, MessageID.IDS_SK_METHOD.Localize());
6920Error(diagnostics, ErrorCode.ERR_OmittedTypeArgument, node);
6990Error(diagnostics, ErrorCode.ERR_NoSuchMember, name, boundLeft.Display, plainName);
6996Error(diagnostics, ErrorCode.ERR_NoSuchMember, name, boundLeft.Type, plainName);
7000Error(diagnostics, ErrorCode.ERR_NoSuchMemberOrExtensionNeedUsing, name, boundLeft.Type, plainName, "System");
7004Error(diagnostics, ErrorCode.ERR_NoSuchMemberOrExtension, name, boundLeft.Type, plainName);
7218Error(diagnostics, ErrorCode.ERR_BadTypeReference, right, plainName, symbol);
7443Error(diagnostics, ErrorCode.ERR_BindToBogus, node, fieldSymbol);
7483Error(diagnostics, isFixedStatementExpression ? ErrorCode.ERR_FixedNotNeeded : ErrorCode.ERR_FixedBufferNotFixed, node);
7528diagnostics.Add(ErrorCode.ERR_RuntimeDoesNotSupportRefFields, node.Location);
7624Error(diagnostics, ErrorCode.ERR_BadAbstractStaticMemberAccess, node);
7630Error(diagnostics, ErrorCode.ERR_RuntimeDoesNotSupportStaticAbstractMembersInInterfaces, node);
7640Error(diagnostics, ErrorCode.ERR_RuntimeDoesNotSupportDefaultInterfaceImplementation, node);
7650Error(diagnostics, ErrorCode.ERR_RuntimeDoesNotSupportProtectedAccessForInterfaceMember, node);
7717ErrorCode errorCode = this.Flags.Includes(BinderFlags.ObjectInitializerMember) ?
7718ErrorCode.ERR_StaticMemberInObjectInitializer :
7719ErrorCode.ERR_ObjectProhibited;
7729Error(diagnostics, ErrorCode.ERR_ObjectRequired, node, symbol);
7925diagnostics.Add(errorOpt ?? new CSDiagnosticInfo(ErrorCode.ERR_BadIndexLHS, expr.Display), node.Location);
7982Error(diagnostics, ErrorCode.ERR_NamedArgumentForArray, node);
7997Error(diagnostics, ErrorCode.ERR_BadIndexCount, node, rank);
8019Error(diagnostics, ErrorCode.WRN_NegativeArrayIndex, index.Syntax);
8191Error(diagnostics, ErrorCode.ERR_NamedArgumentForArray, node);
8206Error(diagnostics, ErrorCode.ERR_PtrIndexSingle, node);
8214Error(diagnostics, ErrorCode.ERR_VoidError, expr.Syntax);
8232Error(diagnostics, ErrorCode.ERR_BadArgExtraRef, analyzedArguments.Argument(i).Syntax, i + 1, refKind.ToArgumentDisplayString());
8320mustHaveAllOptionalParameters ? ErrorCode.ERR_IndexedPropertyMustHaveAllOptionalParams : ErrorCode.ERR_IndexedPropertyRequiresParams,
8365Error(diagnostics, ErrorCode.ERR_NoDynamicPhantomOnBaseIndexer, syntax);
8588? ErrorCode.ERR_ImplicitIndexIndexerWithName
8589: ErrorCode.ERR_ImplicitRangeIndexerWithName,
9307diagnostics.Add(new CSDiagnosticInfo(ErrorCode.ERR_InvalidDelegateType, possibleDelegateType), location ?? node.Location);
9325if (diagnosticInfo.Code == (int)ErrorCode.ERR_InvalidDelegateType)
9327diagnostics.Add(new CSDiagnostic(new CSDiagnosticInfo(ErrorCode.ERR_InvalidDelegateType, possibleDelegateType), location));
9435DiagnosticInfo diagnosticInfo = new CSDiagnosticInfo(ErrorCode.ERR_CannotBeMadeNullable, access.Display);
9514DiagnosticInfo diagnosticInfo = new CSDiagnosticInfo(ErrorCode.ERR_BadUnaryOp, SyntaxFacts.GetText(operatorToken.Kind()), msgId.Localize());
9524Error(diagnostics, ErrorCode.ERR_BadUnaryOp, operatorToken.GetLocation(), operatorToken.Text, receiver.Display);
9531Error(diagnostics, ErrorCode.ERR_BadUnaryOp, operatorToken.GetLocation(), operatorToken.Text, receiverType);
9538Error(diagnostics, ErrorCode.ERR_BadUnaryOp, operatorToken.GetLocation(), operatorToken.Text, receiverType);
Binder\Binder_InterpolatedString.cs (16)
35ErrorCode.ERR_AltInterpolatedVerbatimStringsNotAvailable,
83ErrorCode.ERR_NewlinesAreNotAllowedInsideANonVerbatimInterpolatedString,
112diagnostics.Add(ErrorCode.WRN_AlignmentMagnitude, alignment.Syntax.Location, alignmentConstant.Int32Value, magnitudeLimit);
117diagnostics.Add(ErrorCode.ERR_ConstantExpected, interpolation.AlignmentClause.Value.Location);
128diagnostics.Add(ErrorCode.ERR_EmptyFormatSpecifier, interpolation.FormatClause.Location);
133diagnostics.Add(ErrorCode.ERR_TrailingWhitespaceInFormatSpecifier, interpolation.FormatClause.Location);
617var nonOutConstructorHasArityError = nonOutConstructorDiagnostics.DiagnosticBag?.AsEnumerableWithoutResolution().Any(d => (ErrorCode)d.Code == ErrorCode.ERR_BadCtorArgCount) ?? false;
618var outConstructorHasArityError = outConstructorDiagnostics.DiagnosticBag?.AsEnumerableWithoutResolution().Any(d => (ErrorCode)d.Code == ErrorCode.ERR_BadCtorArgCount) ?? false;
658diagnostics.Add(ErrorCode.ERR_InterpolatedStringHandlerCreationCannotUseDynamic, syntax.Location, interpolatedStringHandlerType.Name);
821diagnostics.Add(ErrorCode.ERR_InterpolatedStringHandlerMethodReturnMalformed, part.Syntax.Location, method);
831diagnostics.Add(ErrorCode.ERR_InterpolatedStringHandlerMethodReturnInconsistent, part.Syntax.Location, method, expected);
874diagnostics.Add(ErrorCode.ERR_InterpolatedStringHandlerArgumentAttributeMalformed, unconvertedString.Syntax.Location, interpolatedStringParameter, interpolatedStringParameter.Type);
974ErrorCode.ERR_InterpolatedStringHandlerArgumentOptionalNotSpecified,
993ErrorCode.ERR_InterpolatedStringHandlerArgumentLocatedAfterInterpolatedString,
Binder\Binder_Invocation.cs (32)
114ErrorCode.ERR_BadSKknown,
218Error(diagnostics, ErrorCode.ERR_CantUseVoidInArglist, argument.Syntax);
233Error(diagnostics, ErrorCode.ERR_CantUseInOrOutInArglist, argument.Syntax);
293diagnostics.Add(new CSDiagnosticInfo(ErrorCode.ERR_MethodNameExpected), expression.Location);
326Error(diagnostics, ErrorCode.ERR_NoDynamicPhantomOnBase, node, methodGroup.Name);
419Error(diagnostics, ErrorCode.ERR_NamedArgumentSpecificationBeforeFixedArgumentInDynamicInvocation, arguments.Arguments[i].Syntax);
459Error(diagnostics, ErrorCode.ERR_InDynamicMethodArg, arguments[argIndex].Syntax);
472Error(diagnostics, ErrorCode.ERR_BadDynamicQuery, node);
480Error(diagnostics, ErrorCode.ERR_BadDynamicMethodArgLambda, arg.Syntax);
486Error(diagnostics, ErrorCode.ERR_BadDynamicMethodArgMemgrp, arg.Syntax);
494Error(diagnostics, ErrorCode.ERR_BadDynamicMethodArg, arg.Syntax, "__arglist");
503Error(diagnostics, ErrorCode.ERR_BadDynamicMethodArg, arg.Syntax, arg.Type);
659Error(diagnostics, ErrorCode.ERR_BadArgTypeDynamicExtension, syntax, methodGroup.InstanceOpt.Type, methodGroup.Name);
668Error(diagnostics, ErrorCode.WRN_DynamicDispatchToConditionalMethod, syntax, methodGroup.Name);
757ErrorCode.ERR_DynamicLocalFunctionParamsParameter,
784ErrorCode.ERR_DynamicLocalFunctionTypeParameter,
889Error(diagnostics, ErrorCode.ERR_NoImplicitConv, call.ReceiverOpt.Syntax, distinguisher.First, distinguisher.Second);
895Error(diagnostics, ErrorCode.ERR_NoImplicitConv, call.ReceiverOpt.Syntax, distinguisher.First, distinguisher.Second);
909Error(diagnostics, ErrorCode.ERR_BadDynamicMethodArg, dynInvoke.Expression.Syntax, dynInvoke.Expression.Type);
1120ErrorCode code = hasBaseReceiver
1121? ErrorCode.ERR_CallingBaseFinalizeDeprecated
1122: ErrorCode.ERR_CallingFinalizeDeprecated;
1185diagnostics.Add(ErrorCode.ERR_BadAttributeParamDefaultArgument, syntax.Location, parameter.Name);
1359diagnostics.Add(ErrorCode.ERR_BadAttributeArgument, syntax.Location);
1424diagnostics.Add(ErrorCode.ERR_NotNullRefDefaultParameter, syntax.Location, parameter.Name, parameterType);
1484Error(diagnostics, ErrorCode.WRN_ImplicitCopyInReadOnlyMember, receiver.Syntax, method, ThisParameterSymbol.SymbolName);
1897diagnostics.Add(ErrorCode.ERR_NameofMethodGroupWithTypeParameters, argument.Location);
1923diagnostics.Add(ErrorCode.ERR_NameofExtensionMethod, methodGroup.Syntax.Location);
1968diagnostics.Add(ErrorCode.ERR_AliasQualifiedNameNotAnExpression, argument.Location);
1982var code = top ? ErrorCode.ERR_ExpressionHasNoName : ErrorCode.ERR_SubexpressionNotInNameof;
Binder\Binder_Lambda.cs (9)
154Error(diagnostics, ErrorCode.ERR_DefaultValueNotAllowed, p.Default.EqualsToken);
164Error(diagnostics, ErrorCode.ERR_IllegalVarArgs, p);
275Error(diagnostics, syntax.Kind() == SyntaxKind.SimpleLambdaExpression ? ErrorCode.ERR_AttributesRequireParenthesizedLambdaExpression : ErrorCode.ERR_AttributesNotAllowed, attributeList);
290diagnostics.Add(ErrorCode.ERR_LambdaExplicitReturnTypeVar, syntax.Location);
302diagnostics.Add(ErrorCode.ERR_MethodReturnCantBeRefAny, syntax.Location, type);
329diagnostics.Add(ErrorCode.ERR_InconsistentLambdaParameterUsage,
342diagnostics.Add(ErrorCode.ERR_ImplicitlyTypedDefaultParameter,
416diagnostics.Add(ErrorCode.ERR_DuplicateParamName, lambda.ParameterLocation(i), name);
Binder\Binder_Lookup.cs (20)
305CSDiagnosticInfo diagInfo = new CSDiagnosticInfo(ErrorCode.ERR_ConflictingAliasAndDefinition, name, existingDefinition.GetKindText());
704diagInfo = diagnose ? new CSDiagnosticInfo(ErrorCode.ERR_AbstractAttributeClass, symbol) : null;
735diagInfo = diagnose ? new CSDiagnosticInfo(ErrorCode.ERR_NotAnAttributeClass, symbol) : null;
839var diagInfo = new CSDiagnosticInfo(ErrorCode.ERR_CircularBase, type, other);
1427diagInfo = diagnose ? new CSDiagnosticInfo(ErrorCode.ERR_CantCallSpecialMethod, unwrappedSymbol) : null;
1442diagInfo = diagnose ? new CSDiagnosticInfo(ErrorCode.ERR_BadAccess, new[] { unwrappedSymbol }, unwrappedSymbols, additionalLocations: ImmutableArray<Location>.Empty) : null;
1458diagInfo = new CSDiagnosticInfo(ErrorCode.ERR_BadProtectedAccess, unwrappedSymbol, accessThroughType, this.ContainingType);
1462diagInfo = new CSDiagnosticInfo(ErrorCode.ERR_FriendRefNotEqualToThis, unwrappedSymbol.ContainingAssembly.Identity.ToString(), AssemblyIdentity.PublicKeyToString(this.Compilation.Assembly.PublicKey));
1466diagInfo = new CSDiagnosticInfo(ErrorCode.ERR_BadAccess, new[] { unwrappedSymbol }, ImmutableArray.Create<Symbol>(unwrappedSymbol), additionalLocations: ImmutableArray<Location>.Empty);
1478diagInfo = diagnose ? new CSDiagnosticInfo(ErrorCode.ERR_ObjectRequired, unwrappedSymbol) : null;
1483diagInfo = diagnose ? new CSDiagnosticInfo(ErrorCode.ERR_ObjectProhibited, unwrappedSymbol) : null;
1488diagInfo = diagnose ? new CSDiagnosticInfo(ErrorCode.ERR_BadSKunknown, unwrappedSymbol, unwrappedSymbol.GetKindText()) : null;
1493diagInfo = diagnose ? new CSDiagnosticInfo(ErrorCode.ERR_LabelNotFound, unwrappedSymbol.Name) : null;
1568new CSDiagnosticInfo(ErrorCode.ERR_BindToBogusProp2, symbol, method1, method2) :
1569new CSDiagnosticInfo(ErrorCode.ERR_BindToBogusProp1, symbol, method1 ?? method2);
1780diagInfo = diagnose ? new CSDiagnosticInfo(ErrorCode.ERR_HasNoTypeVars, namedType, MessageID.IDS_SK_TYPE.Localize()) : null;
1785diagInfo = diagnose ? new CSDiagnosticInfo(ErrorCode.ERR_BadArity, namedType, MessageID.IDS_SK_TYPE.Localize(), namedType.Arity) : null;
1801diagInfo = diagnose ? new CSDiagnosticInfo(ErrorCode.ERR_HasNoTypeVars, method, MessageID.IDS_SK_METHOD.Localize()) : null;
1806diagInfo = diagnose ? new CSDiagnosticInfo(ErrorCode.ERR_BadArity, method, MessageID.IDS_SK_METHOD.Localize(), method.Arity) : null;
1816diagInfo = diagnose ? new CSDiagnosticInfo(ErrorCode.ERR_TypeArgsNotAllowed, symbol, symbol.Kind.Localize()) : null;
Binder\Binder_Operators.cs (78)
89Error(diagnostics, ErrorCode.ERR_BadBinaryOps, node, node.OperatorToken.Text, left.Display, right.Display);
235Error(diagnostics, ErrorCode.ERR_VoidError, node);
295Error(diagnostics, ErrorCode.ERR_MissingPredefinedMember, node, delegateType, SourceEventSymbol.GetAccessorName(eventSymbol.Name, isAddition));
305Error(diagnostics, ErrorCode.ERR_BadAccess, node, method);
384Error(diagnostics, ErrorCode.ERR_BadBinaryOps, node, node.OperatorToken.Text, left.Display, right.Display);
399Error(diagnostics, ErrorCode.ERR_InvalidDynamicCondition, node.Left, left.Type, kind == BinaryOperatorKind.LogicalAnd ? "false" : "true");
477Error(diagnostics, ErrorCode.ERR_PossibleBadNegCast, node);
486Error(diagnostics, ErrorCode.ERR_PossibleBadNegCast, node);
609Error(diagnostics, ErrorCode.WRN_DoNotCompareFunctionPointers, node.OperatorToken);
617Error(diagnostics, ErrorCode.ERR_VoidError, node);
775ErrorCode errorCode = resultKind == LookupResultKind.Ambiguous ?
776ErrorCode.ERR_AmbigUnaryOp : // Operator '{0}' is ambiguous on an operand of type '{1}'
777ErrorCode.ERR_BadUnaryOp; // Operator '{0}' cannot be applied to operand of type '{1}'
808Error(diagnostics, ErrorCode.ERR_BadOpOnNullOrDefaultOrNew, node, operatorToken.Text, "default");
811Error(diagnostics, ErrorCode.ERR_AmbigBinaryOpsOnDefault, node, operatorToken.Text, left.Display, right.Display);
815Error(diagnostics, ErrorCode.ERR_AmbigBinaryOpsOnUnconstrainedDefault, node, operatorToken.Text, right.Type);
819Error(diagnostics, ErrorCode.ERR_AmbigBinaryOpsOnUnconstrainedDefault, node, operatorToken.Text, left.Type);
822Error(diagnostics, ErrorCode.ERR_BadOpOnNullOrDefaultOrNew, node, operatorToken.Text, left.Display);
825Error(diagnostics, ErrorCode.ERR_BadOpOnNullOrDefaultOrNew, node, operatorToken.Text, right.Display);
830ErrorCode errorCode;
835errorCode = ErrorCode.ERR_AmbigBinaryOps; // Operator '{0}' is ambiguous on operands of type '{1}' and '{2}'
839errorCode = ErrorCode.ERR_BadBinaryReadOnlySpanConcatenation; // Operator '{0}' cannot be applied to operands of type '{1}' and '{2}' that are not UTF-8 byte representations
843errorCode = ErrorCode.ERR_BadBinaryOps; // Operator '{0}' cannot be applied to operands of type '{1}' and '{2}'
1137Error(diagnostics, ErrorCode.ERR_BadBoolOp, syntax, signature.Method);
1162Error(diagnostics, ErrorCode.ERR_MustHaveOpTF, syntax, signature.Method, t);
1794Error(diagnostics, ErrorCode.ERR_IntDivByZero, syntax);
1818Error(diagnostics, ErrorCode.ERR_ConstantStringTooLong, right.Syntax);
1833Error(diagnostics, ErrorCode.ERR_DecConstError, syntax);
1850Error(diagnostics, ErrorCode.WRN_CompileTimeCheckedOverflow, syntax, resultTypeSymbol);
1869Error(diagnostics, ErrorCode.ERR_CheckedOverflow, syntax);
2322Error(diagnostics, ErrorCode.ERR_VoidError, node);
2359Error(diagnostics, ErrorCode.ERR_BadAbstractStaticMemberAccess, node);
2369Error(diagnostics, ErrorCode.ERR_RuntimeDoesNotSupportStaticAbstractMembersInInterfaces, node);
2417Error(diagnostics, ErrorCode.ERR_IllegalSuppression, expr.Syntax);
2423Error(diagnostics, ErrorCode.ERR_DuplicateNullSuppression, expr.Syntax);
2457Error(diagnostics, ErrorCode.ERR_PtrExpected, node);
2471Error(diagnostics, ErrorCode.ERR_VoidError, node);
2517Error(diagnostics, isFixedStatementAddressOfExpression ? ErrorCode.ERR_FixedNotNeeded : ErrorCode.ERR_FixedNeeded, node);
2675Error(diagnostics, ErrorCode.ERR_IllegalSuppression, expr.Syntax);
2689Error(diagnostics, ErrorCode.ERR_BadOpOnNullOrDefaultOrNew, node, operatorText, operand.Display);
2840Error(diagnostics, ErrorCode.WRN_CompileTimeCheckedOverflow, syntax, resultTypeSymbol);
2859Error(diagnostics, ErrorCode.ERR_CheckedOverflow, syntax);
3122Error(diagnostics, ErrorCode.ERR_LambdaInIsAs, node);
3134Error(diagnostics, ErrorCode.ERR_BadUnaryOp, node, SyntaxFacts.GetText(SyntaxKind.IsKeyword), operand.Display);
3158Error(diagnostics, ErrorCode.WRN_StaticInAsOrIs, node, targetType);
3164Error(diagnostics, ErrorCode.ERR_PointerInAsOrIs, node);
3192isPatternDiagnostics.Add(ErrorCode.ERR_BadPatternExpression, node.Left.Location, operand.Display);
3221Error(diagnostics, ErrorCode.ERR_IsNullableType, node.Right, targetType);
3233diagnostics.Add(ErrorCode.WRN_IsTypeNamedUnderscore, node.Right.Location, typeExpression.AliasOpt ?? (Symbol)targetType);
3262Error(diagnostics, ErrorCode.WRN_IsAlwaysFalse, node, targetType);
3271Error(diagnostics, ErrorCode.WRN_IsDynamicIsConfusing,
3323Error(diagnostics, ErrorCode.ERR_BadBinaryOps, syntax, "is", operandType, targetType);
3329ErrorCode errorCode = constantValue == ConstantValue.True ? ErrorCode.WRN_IsAlwaysTrue : ErrorCode.WRN_IsAlwaysFalse;
3641Error(diagnostics, ErrorCode.ERR_LambdaInIsAs, node);
3650Error(diagnostics, ErrorCode.ERR_TypelessTupleInAs, node);
3664Error(diagnostics, ErrorCode.ERR_AsNullableType, node.Right, targetType);
3674Error(diagnostics, ErrorCode.ERR_AsWithTypeVar, node, targetType);
3678Error(diagnostics, ErrorCode.ERR_PointerInAsOrIs, node);
3682Error(diagnostics, ErrorCode.ERR_AsMustHaveReferenceType, node, targetType);
3699Error(diagnostics, ErrorCode.WRN_StaticInAsOrIs, node, targetType);
3733Error(diagnostics, ErrorCode.ERR_PointerInAsOrIs, node);
3820Error(diagnostics, ErrorCode.ERR_NoExplicitBuiltinConv, node, distinguisher.First, distinguisher.Second);
3853Error(diagnostics, ErrorCode.ERR_BadBinaryOps, node, "as", operandType, targetType);
3858Error(diagnostics, ErrorCode.WRN_AlwaysNull, node, targetType);
3895Error(diagnostics, ErrorCode.ERR_BadBinaryOps, node, SyntaxFacts.GetText(node.OperatorToken.Kind()), leftOperand.Display, rightOperand.Display);
3921Error(diagnostics, ErrorCode.ERR_BadOpOnNullOrDefaultOrNew, node, node.OperatorToken.Text, "default");
4153Error(diagnostics, ErrorCode.ERR_BadBinaryOps, node, SyntaxFacts.GetText(node.OperatorToken.Kind()), leftOperand.Display, rightOperand.Display);
4203diagnostics.Add(ErrorCode.ERR_RefConditionalNeedsTwoRefs, whenFalse.GetFirstToken().GetLocation());
4208diagnostics.Add(ErrorCode.ERR_RefConditionalNeedsTwoRefs, whenTrue.GetFirstToken().GetLocation());
4232ErrorCode noCommonTypeError = hadMultipleCandidates ? ErrorCode.ERR_AmbigQM : ErrorCode.ERR_InvalidQM;
4279diagnostics.Add(ErrorCode.ERR_RefConditionalDifferentTypes, falseExpr.Syntax.Location, trueType);
4319diagnostics.Add(_inUnsafeRegion ? ErrorCode.WRN_MismatchedRefEscapeInTernary : ErrorCode.ERR_MismatchedRefEscapeInTernary, node.Location);
Binder\Binder_Patterns.cs (44)
30diagnostics.Add(ErrorCode.ERR_BadPatternExpression, node.Expression.Location, expression.Display);
66diagnostics.Add(ErrorCode.ERR_IsPatternImpossible, node.Location, expression.Type);
83diagnostics.Add(ErrorCode.WRN_IsPatternAlways, node.Location, expression.Type);
103diagnostics.Add(ErrorCode.WRN_GivenExpressionNeverMatchesPattern, node.Location);
110diagnostics.Add(ErrorCode.WRN_GivenExpressionAlwaysMatchesConstant, node.Location);
117diagnostics.Add(ErrorCode.WRN_GivenExpressionAlwaysMatchesPattern, node.Location);
211diagnostics.Add(ErrorCode.ERR_MisplacedSlicePattern, node.Location);
306Error(diagnostics, ErrorCode.ERR_UnsupportedTypeForListPattern, node, inputType);
378Error(diagnostics, ErrorCode.ERR_ListPatternRequiresLength, node, inputType);
436diagnostics.Add(ErrorCode.ERR_CannotMatchOnINumberBase, node.Location, inputType);
476diagnostics.Add(ErrorCode.ERR_DefaultPattern, e.Location);
483diagnostics.Add(ErrorCode.ERR_IllegalSuppression, e.Location);
560diagnostics.Add(ErrorCode.ERR_ConstantExpected, patternExpression.Location);
604diagnostics.Add(ErrorCode.ERR_ValueCantBeNull, expression.Syntax.Location, inputType);
614diagnostics.Add(ErrorCode.ERR_PatternWrongType, expression.Syntax.Location, inputType, expression.Display);
625diagnostics.Add(ErrorCode.ERR_ConstantPatternVsOpenType,
664diagnostics.Add(ErrorCode.ERR_PatternSpanCharCannotBeStringNull, convertedExpression.Syntax.Location, inputType);
728diagnostics.Add(ErrorCode.ERR_PointerTypeInPatternMatching, typeSyntax.Location);
734Error(diagnostics, ErrorCode.ERR_PatternNullableType, typeSyntax, patternType.GetNullableUnderlyingType());
739Error(diagnostics, ErrorCode.ERR_PatternNullableType, typeSyntax, patternType);
744Error(diagnostics, ErrorCode.ERR_VarDeclIsStaticClass, typeSyntax, patternType);
751Error(diagnostics, ErrorCode.ERR_PatternDynamicType, typeSyntax);
767Error(diagnostics, ErrorCode.ERR_PatternWrongGenericTypeInVersion, typeSyntax,
777Error(diagnostics, ErrorCode.ERR_PatternWrongType, typeSyntax, inputType, patternType);
873diagnostics.Add(ErrorCode.ERR_DesignatorBeneathPatternCombinator, identifier.GetLocation());
958diagnostics.Add(ErrorCode.ERR_PointerTypeInPatternMatching, node.Location);
1076diagnostics.Add(ErrorCode.ERR_DeconstructParameterNameMismatch, subPattern.NameColon.Name.Location, name, parameterName);
1084diagnostics.Add(ErrorCode.ERR_IdentifierExpected, subPattern.ExpressionColon.Expression.Location);
1111diagnostics.Add(ErrorCode.ERR_ArgumentNameInITuplePattern, subpatternSyntax.NameColon.Location);
1115diagnostics.Add(ErrorCode.ERR_IdentifierExpected, subpatternSyntax.ExpressionColon.Expression.Location);
1155diagnostics.Add(ErrorCode.ERR_WrongNumberOfSubpatterns, node.Location, declType, elementTypesWithAnnotations.Length, node.Subpatterns.Count);
1174diagnostics.Add(ErrorCode.ERR_IdentifierExpected, subpatternSyntax.ExpressionColon.Expression.Location);
1301diagnostics.Add(ErrorCode.ERR_TupleElementNameMismatch, node.Location, name, $"Item{tupleIndex + 1}");
1317diagnostics.Add(ErrorCode.ERR_PointerTypeInPatternMatching, node.Location);
1326diagnostics.Add(ErrorCode.ERR_VarMayNotBindToType, node.VarKeyword.GetLocation(), foundSymbol.ToDisplayString());
1428diagnostics.Add(ErrorCode.ERR_WrongNumberOfSubpatterns, tupleDesignation.Location,
1470diagnostics.Add(ErrorCode.ERR_PropertyPatternNameMissing, pattern.Location, pattern);
1515Error(diagnostics, ErrorCode.ERR_InvalidNameInSubpattern, expr);
1575Error(diagnostics, ErrorCode.ERR_NoSuchMember, memberName, implicitReceiver.Type, name);
1584Error(diagnostics, ErrorCode.ERR_PropertyLacksGet, memberName, name);
1628diagnostics.Add(ErrorCode.ERR_InvalidExprTerm, node.OperatorToken.GetLocation(), node.OperatorToken.Text);
1639diagnostics.Add(ErrorCode.ERR_RelationalPatternWithNaN, node.Expression.Location);
1648diagnostics.Add(ErrorCode.ERR_UnsupportedTypeForRelationalPattern, node.Location, value.Type.ToDisplayString());
1663diagnostics.Add(ErrorCode.ERR_CannotMatchOnINumberBase, node.Location, inputType);
Binder\Binder_Query.cs (12)
35diagnostics.Add(ErrorCode.ERR_BadDynamicQuery, fromClause.Expression.Location);
386diagnostics.Add(ErrorCode.ERR_BadDynamicQuery, join.InExpression.Location);
734Error(d, ErrorCode.ERR_QueryRangeVariableAssignedBadValue, errorLocation, yExpression.Display);
739Error(d, ErrorCode.ERR_QueryRangeVariableAssignedBadValue, errorLocation, yExpression.Type!);
936diagnostics.Add(ErrorCode.ERR_NullNotValid, node.Location);
940diagnostics.Add(ErrorCode.ERR_DefaultLiteralNotValid, node.Location);
944diagnostics.Add(ErrorCode.ERR_ImplicitObjectCreationNotValid, node.Location);
948diagnostics.Add(ErrorCode.ERR_BadSKunknown, ultimateReceiver.Syntax.Location, ((BoundNamespaceExpression)ultimateReceiver).NamespaceSymbol, MessageID.IDS_SK_NAMESPACE.Localize());
953diagnostics.Add(ErrorCode.ERR_QueryNoProvider, node.Location, MessageID.IDS_AnonMethod.Localize(), methodName);
969diagnostics.Add(ErrorCode.ERR_QueryNoProvider, node.Location, MessageID.IDS_SK_METHOD.Localize(), methodName);
981Error(diagnostics, ErrorCode.ERR_BadSKunknown, ultimateReceiver.Syntax, ultimateReceiver.Type, MessageID.IDS_SK_TYVAR.Localize());
993diagnostics.Add(ErrorCode.ERR_QueryNoProvider, node.Location, "void", methodName);
Binder\Binder_Statements.cs (133)
54Error(diagnostics, ErrorCode.ERR_AttributesNotAllowed, attributeList);
175Error(diagnostics, ErrorCode.ERR_IllegalUnsafe, node.UnsafeKeyword);
181Error(diagnostics, ErrorCode.ERR_IllegalInnerUnsafe, node.UnsafeKeyword);
257Error(diagnostics, ErrorCode.ERR_BadYieldInFinally, node.YieldKeyword);
261Error(diagnostics, ErrorCode.ERR_BadYieldInTryOfCatch, node.YieldKeyword);
265Error(diagnostics, ErrorCode.ERR_BadYieldInCatch, node.YieldKeyword);
269Error(diagnostics, ErrorCode.ERR_YieldNotAllowedInScript, node.YieldKeyword);
280Error(diagnostics, ErrorCode.ERR_BadYieldInFinally, node.YieldKeyword);
284Error(diagnostics, ErrorCode.ERR_YieldNotAllowedInScript, node.YieldKeyword);
324diagnostics.Add(ErrorCode.ERR_BadEmbeddedStmt, node.GetLocation());
342diagnostics.Add(ErrorCode.ERR_BadEmbeddedStmt, node.GetLocation());
377diagnostics.Add(ErrorCode.WRN_PossibleMistakenNullStatement, node.GetLocation());
412diagnostics.Add(ErrorCode.ERR_BadExceptionType, exprSyntax.Location);
443diagnostics.Add(ErrorCode.ERR_BadEmptyThrow, node.ThrowKeyword.GetLocation());
454diagnostics.Add(ErrorCode.ERR_BadEmptyThrowInFinally, node.ThrowKeyword.GetLocation());
483Error(diagnostics, ErrorCode.ERR_DuplicateLabel, node.Identifier, node.Identifier.ValueText);
495Error(diagnostics, ErrorCode.ERR_LabelShadow, node.Identifier, node.Identifier.ValueText);
531Error(diagnostics, ErrorCode.ERR_InvalidGotoCase, node);
579diagnostics.Add(ErrorCode.ERR_LocalFunctionMissingBody, localSymbol.Locations[0], localSymbol);
585diagnostics.Add(ErrorCode.ERR_ExternHasBody, localSymbol.Locations[0], localSymbol);
625blockDiagnostics.Add(ErrorCode.ERR_ReturnExpected, localSymbol.Locations[0], localSymbol);
654Error(diagnostics, ErrorCode.ERR_IllegalStatement, syntax);
679Error(diagnostics, ErrorCode.WRN_UnobservedAwaitableExpression, expression.Syntax);
777diagnostics.Add(ErrorCode.WRN_PatternBadSignature, syntaxNode.Location, expr.Type, MessageID.IDS_Disposable.Localize(), disposeMethod);
810Error(diagnostics, ErrorCode.ERR_ImplicitlyTypedVariableCannotBeConst, declarationNode);
834Error(diagnostics, ErrorCode.ERR_ImplicitlyTypedVariableMultipleDeclarator, declarationNode);
850Error(diagnostics, ErrorCode.ERR_VarDeclIsStaticClass, typeSyntax, declType.Type);
855Error(diagnostics, ErrorCode.ERR_BadConstType, typeSyntax, declType.Type);
880Error(diagnostics, ErrorCode.ERR_ImplicitlyTypedVariableWithNoInitializer, errorSyntax);
889diagnostics, ErrorCode.ERR_ImplicitlyTypedVariableAssignedArrayInitializer, errorSyntax);
904Error(diagnostics, ErrorCode.ERR_ImplicitlyTypedVariableAssignedBadValue, errorSyntax, expression.Display);
925Error(diagnostics, ErrorCode.ERR_InitializeByValueVariableWithReference, node);
937Error(diagnostics, ErrorCode.ERR_ByReferenceVariableMustBeInitialized, node);
942Error(diagnostics, ErrorCode.ERR_InitializeByReferenceVariableWithValue, node);
1030Error(localDiagnostics, ErrorCode.ERR_ImplicitlyTypedVariableAssignedBadValue, declarator, declTypeOpt.Type);
1039Error(localDiagnostics, ErrorCode.ERR_VarDeclIsStaticClass, typeSyntax, initializerType);
1081Error(localDiagnostics, ErrorCode.ERR_ImplicitlyTypedLocalCannotBeFixed, declarator);
1090Error(localDiagnostics, declTypeOpt.Type.IsFunctionPointer() ? ErrorCode.ERR_CannotUseFunctionPointerAsFixedLocal : ErrorCode.ERR_BadFixedInitType, declarator);
1104localDiagnostics.Add(ErrorCode.ERR_ScopedRefAndRefStructOnly, typeSyntax.Location);
1120Error(localDiagnostics, ErrorCode.ERR_FixedMustInit, declarator);
1169Error(diagnostics, ErrorCode.ERR_BadAsyncLocalType, identifierToken);
1174Error(diagnostics, ErrorCode.ERR_BadIteratorLocalType, identifierToken);
1246Error(diagnostics, ErrorCode.ERR_ExprCannotBeFixed, initializerSyntax);
1314Error(diagnostics, ErrorCode.ERR_ExprCannotBeFixed, initializerSyntax);
1351additionalDiagnostics.Add(ErrorCode.WRN_PatternBadSignature, initializer.Syntax.Location, initializer.Type, "fixed", patternMethodSymbol);
1476diagnostics.Add(ErrorCode.ERR_VoidAssignment, op1.Syntax.Location);
1563var errorCode = (rightEscape, _inUnsafeRegion) switch
1565(ReturnOnlyScope, false) => ErrorCode.ERR_RefAssignReturnOnly,
1566(ReturnOnlyScope, true) => ErrorCode.WRN_RefAssignReturnOnly,
1567(_, false) => ErrorCode.ERR_RefAssignNarrower,
1568(_, true) => ErrorCode.WRN_RefAssignNarrower
1591var errorCode = _inUnsafeRegion ? ErrorCode.WRN_RefAssignValEscapeWider : ErrorCode.ERR_RefAssignValEscapeWider;
1758new CSDiagnosticInfo(ErrorCode.ERR_BadEventUsage, leastOverridden, leastOverridden.ContainingType) :
1759new CSDiagnosticInfo(ErrorCode.ERR_BadEventUsageNoField, leastOverridden);
1833result = BindUnexpectedArrayInitializer((InitializerExpressionSyntax)node, diagnostics, ErrorCode.ERR_ArrayInitToNonArrayType);
1858Error(diagnostics, ErrorCode.ERR_AttributesNotAllowed, node.AttributeLists[0]);
1940Error(diagnostics, ErrorCode.ERR_RefAssignmentMustHaveIdentityConversion, expression.Syntax, targetType);
2015Error(diagnostics, ErrorCode.ERR_CannotInferDelegateType, syntax);
2023Error(diagnostics, ErrorCode.ERR_AnonMethToNonDel, syntax, id, targetType);
2030Error(diagnostics, ErrorCode.ERR_ExpressionTreeMustHaveDelegate, syntax, ((NamedTypeSymbol)targetType).TypeArgumentsWithAnnotationsNoUseSiteDiagnostics[0].Type);
2037Error(diagnostics, ErrorCode.ERR_AnonymousMethodToExpressionTree, syntax);
2043Error(diagnostics, ErrorCode.ERR_CantConvAnonMethReturnType, syntax, id, targetType);
2069Error(diagnostics, ErrorCode.ERR_CantConvAnonMethNoParams, syntax, targetType);
2081Error(diagnostics, ErrorCode.ERR_BadDelArgCount, syntax, delegateType, anonymousFunction.ParameterCount);
2114Error(diagnostics, ErrorCode.ERR_BadParamRef, anonymousFunction.ParameterLocation(i),
2140Error(diagnostics, ErrorCode.ERR_CantConvAnonMethParams, syntax, id, targetType);
2160Error(diagnostics, ErrorCode.ERR_BadParamType, lambdaParameterLocation,
2168Error(diagnostics, ErrorCode.ERR_BadParamExtraRef, lambdaParameterLocation, i + 1, lambdaRefKind.ToParameterDisplayString());
2173Error(diagnostics, ErrorCode.ERR_BadParamRef, lambdaParameterLocation, i + 1, delegateRefKind.ToParameterDisplayString());
2191diagnostics.Add(ErrorCode.ERR_InternalError, syntax.Location);
2211Error(diagnostics, ErrorCode.ERR_LiteralDoubleCast, syntax, (targetType.SpecialType == SpecialType.System_Single) ? "F" : "M", targetType);
2222Error(diagnostics, ErrorCode.ERR_ConstOutOfRange, syntax, sourceConstantValueOpt.Value, targetType);
2227Error(diagnostics, ErrorCode.ERR_NoImplicitConvCast, syntax, distinguisher.First, distinguisher.Second);
2237Error(diagnostics, ErrorCode.ERR_AmbigUDConv, syntax, originalUserDefinedConversions[0], originalUserDefinedConversions[1], sourceType, targetType);
2244Error(diagnostics, ErrorCode.ERR_NoImplicitConv, syntax, distinguisher.First, distinguisher.Second);
2253Error(diagnostics, ErrorCode.ERR_NoImplicitConv, syntax, sourceType, targetType);
2258Error(diagnostics, ErrorCode.ERR_NoImplicitConv, syntax, distinguisher.First, distinguisher.Second);
2280Error(diagnostics, ErrorCode.ERR_NoImplicitConv, syntax, operand.Display, targetType);
2312Error(diagnostics, ErrorCode.ERR_ConversionNotTupleCompatible, syntax, tuple.Arguments.Length, targetType);
2335Error(diagnostics, ErrorCode.ERR_TypeVarCantBeNull, syntax, targetType);
2340Error(diagnostics, ErrorCode.ERR_ValueCantBeNull, syntax, targetType);
2349Error(diagnostics, ErrorCode.ERR_StackAllocConversionNotPossible, syntax, stackAllocExpression.ElementType, targetType);
2368Error(diagnostics, ErrorCode.ERR_InvalidAddrOp, ((BoundAddressOfOperator)operand).Operand.Syntax);
2424ErrorCode errorCode;
2429errorCode = ErrorCode.ERR_MethFuncPtrMismatch;
2432Error(diagnostics, ErrorCode.ERR_MissingAddressOf, location);
2435errorCode = ErrorCode.ERR_CannotConvertAddressOfToDelegate;
2438errorCode = ErrorCode.ERR_MethDelegateMismatch;
2444errorCode = ErrorCode.ERR_AddressOfToNonFunctionPointer;
2450Error(diagnostics, ErrorCode.ERR_CannotInferDelegateType, location);
2455errorCode = ErrorCode.ERR_MethGrpToNonDel;
2587Error(diagnostics, ErrorCode.WRN_IncorrectBooleanAssg, assignment.Syntax);
2733Error(diagnostics, ErrorCode.ERR_ImplicitlyTypedVariableMultipleDeclarator, nodeOpt);
2803Error(diagnostics, ErrorCode.ERR_NoBreakOrCont, node);
2814Error(diagnostics, ErrorCode.ERR_NoBreakOrCont, node);
2912diagnostics.Add(ErrorCode.ERR_ReturnInIterator, syntax.ReturnKeyword.GetLocation());
2920diagnostics.Add(ErrorCode.ERR_MustNotHaveRefReturn, syntax.ReturnKeyword.GetLocation());
2925diagnostics.Add(ErrorCode.ERR_ReturnInIterator, syntax.ReturnKeyword.GetLocation());
2931var errorCode = refKind != RefKind.None
2932? ErrorCode.ERR_MustNotHaveRefReturn
2933: ErrorCode.ERR_MustHaveRefReturn;
2963Error(diagnostics, ErrorCode.ERR_RetNoObjectRequiredLambda, syntax.ReturnKeyword);
2967Error(diagnostics, ErrorCode.ERR_TaskRetNoObjectRequiredLambda, syntax.ReturnKeyword, retType);
2983Error(diagnostics, ErrorCode.ERR_RetNoObjectRequired, syntax.ReturnKeyword, container);
2987Error(diagnostics, ErrorCode.ERR_TaskRetNoObjectRequired, syntax.ReturnKeyword, container, retType);
3003Error(diagnostics, ErrorCode.ERR_RetObjectRequired, syntax.ReturnKeyword, requiredType);
3017Error(diagnostics, ErrorCode.ERR_CantReturnVoid, expressionSyntax);
3065Error(diagnostics, ErrorCode.ERR_RefReturnMustHaveIdentityConversion, argument.Syntax, returnType);
3082Error(diagnostics, ErrorCode.ERR_BadAsyncReturnExpression, argument.Syntax, returnType, argument.Type);
3124diagnostics.Add(ErrorCode.ERR_TooManyCatches, catchSyntax.CatchKeyword.GetLocation());
3162Error(diagnostics, ErrorCode.ERR_BadExceptionType, declaration.Type);
3204Error(diagnostics, ErrorCode.ERR_UnreachableCatch, declaration.Type, previousType);
3219Error(diagnostics, ErrorCode.WRN_UnreachableGeneralCatch, node.CatchKeyword);
3257var errorCode = boundFilter.ConstantValueOpt.BooleanValue
3258? ErrorCode.WRN_FilterIsConstantTrue
3260? ErrorCode.WRN_FilterIsConstantFalseRedundantTryCatch
3261: ErrorCode.WRN_FilterIsConstantFalse;
3284Error(diagnostics, ErrorCode.ERR_CantConvAsyncAnonFuncReturns,
3291Error(diagnostics, ErrorCode.ERR_CantConvAnonMethReturns,
3355Error(diagnostics, ErrorCode.ERR_MustNotHaveRefReturn, syntax);
3363var errorCode = refKind != RefKind.None
3364? ErrorCode.ERR_MustNotHaveRefReturn
3365: ErrorCode.ERR_MustHaveRefReturn;
3381Error(diagnostics, ErrorCode.ERR_IllegalStatement, syntax);
3397Error(diagnostics, ErrorCode.ERR_ReturnInIterator, syntax);
3630Error(diagnostics, ErrorCode.ERR_UnexpectedOrMissingConstructorInitializerInRecord, initializer?.ThisOrBaseKeyword ?? constructor.Identifier);
3641Error(diagnostics, ErrorCode.ERR_RecordStructConstructorCallsDefaultConstructor, initializer.ThisOrBaseKeyword);
3835diagnostics.Add(ErrorCode.ERR_BadCtorArgCount, diagnosticsLocation, baseType, /*desired param count*/ 0);
3849diagnostics.Add(ErrorCode.ERR_BadAccess, diagnosticsLocation, baseConstructor);
3888diagnostics.Add(ErrorCode.ERR_NoCopyConstructorInBaseType, diagnosticsLocation, baseType);
Binder\Binder_Symbols.cs (53)
338var diagnosticInfo = diagnostics.Add(ErrorCode.ERR_BadSKknown, syntax.Location, syntax, symbol.Symbol.GetKindText(), MessageID.IDS_SK_TYPE.Localize());
487diagnostics.Add(ErrorCode.ERR_BadRefInUsingAlias, refToken.GetLocation());
491diagnostics.Add(ErrorCode.ERR_UnexpectedToken, refToken.GetLocation(), refToken.ToString());
505diagnostics.Add(ErrorCode.ERR_UnexpectedToken, scopedToken.GetLocation(), scopedToken.ToString());
582return TypeWithAnnotations.Create(new ExtendedErrorTypeSymbol(left, LookupResultKind.NotATypeOrNamespace, diagnostics.Add(ErrorCode.ERR_ColColWithTypeAlias, node.Alias.Location, node.Alias.Identifier.Text)));
604diagnostics.Add(ErrorCode.ERR_TypeExpected, syntax.GetLocation());
618return new CSDiagnosticInfo(ErrorCode.ERR_NullableUnconstrainedTypeParameter, new CSharpRequiredLanguageVersion(requiredVersion));
636Error(diagnostics, ErrorCode.ERR_ArrayOfStaticClass, node.ElementType, type.Type);
647Error(diagnostics, ErrorCode.ERR_ArrayElementCantBeRefAny, node.ElementType, type.Type);
664Error(diagnostics, ErrorCode.ERR_ArraySizeInDeclaration, rankSpecifier);
751var info = new CSDiagnosticInfo(ErrorCode.ERR_TupleElementNamesAttributeMissing,
791Error(diagnostics, ErrorCode.ERR_TupleReservedElementNameAnyPosition, syntax, name);
796Error(diagnostics, ErrorCode.ERR_TupleReservedElementName, syntax, name, reserved);
801Error(diagnostics, ErrorCode.ERR_TupleDuplicateElementName, syntax);
860new CSDiagnosticInfo(ErrorCode.ERR_SingleTypeNameNotFound, identifierValueText)));
1048var info = new CSDiagnosticInfo(ErrorCode.ERR_DynamicAttributeMissing, AttributeDescription.DynamicAttribute.FullName);
1219diagnostics.Add(ErrorCode.ERR_UnexpectedUnboundGenericName, node.Location);
1327var diagnosticInfo = new CSDiagnosticInfo(ErrorCode.ERR_LookupInTypeVariable, qualifierOpt);
1376Error(diagnostics, ErrorCode.ERR_BadArity, typeSyntax, type, MessageID.IDS_SK_TYPE.Localize(), typeArgumentsSyntax.Count);
1411Error(diagnostics, ErrorCode.ERR_BadArity, syntax, plainName, MessageID.IDS_MethodGroup.Localize(), typeArgumentsSyntax.Count);
1439Error(diagnostics, ErrorCode.ERR_AmbiguousPrimaryConstructorParameterAsColorColorReceiver, colorColorValueReceiver.Syntax, parameter.Name, parameter.Type, parameter);
1672diagnostics.Add(ErrorCode.ERR_MissingPredefinedMember, syntax.Location, descriptor.DeclaringTypeMetadataName, descriptor.Name);
1822useSiteInfo = new UseSiteInfo<AssemblySymbol>(new CSDiagnosticInfo(ErrorCode.ERR_MissingPredefinedMember, memberDescriptor.DeclaringTypeMetadataName, memberDescriptor.Name));
1946diagnostics.Add(ErrorCode.WRN_SameFullNameThisNsAgg, where.Location, originalSymbols,
1957diagnostics.Add(ErrorCode.WRN_SameFullNameThisAggNs, where.Location, originalSymbols,
1968diagnostics.Add(ErrorCode.WRN_SameFullNameThisAggAgg, where.Location, originalSymbols,
2023info = new CSDiagnosticInfo(ErrorCode.ERR_AmbigContext, originalSymbols,
2034info = new CSDiagnosticInfo(ErrorCode.ERR_SameFullNameAggAgg, originalSymbols,
2059info = new CSDiagnosticInfo(ErrorCode.ERR_SameFullNameNsAgg, originalSymbols,
2074info = new CSDiagnosticInfo(ErrorCode.ERR_SameFullNameNsAgg, originalSymbols,
2116info = new CSDiagnosticInfo(ErrorCode.ERR_SameFullNameThisAggThisNs, originalSymbols,
2123info = new CSDiagnosticInfo(ErrorCode.ERR_AmbigMember, originalSymbols,
2137info = new CSDiagnosticInfo(ErrorCode.ERR_AmbigMember, originalSymbols,
2163info = new CSDiagnosticInfo(ErrorCode.ERR_AmbiguousAttribute, originalSymbols,
2169info = new CSDiagnosticInfo(ErrorCode.ERR_AmbigContext, originalSymbols,
2179info = new CSDiagnosticInfo(ErrorCode.ERR_AmbigMember, originalSymbols,
2208var errorInfo = new CSDiagnosticInfo(ErrorCode.ERR_SystemVoid);
2239if (errorInfo != null && errorInfo.Code == (int)ErrorCode.ERR_CircularBase)
2526return diagnostics.Add(ErrorCode.ERR_DottedTypeNameNotFoundInAgg, location, whereText, qualifierOpt);
2538? diagnostics.Add(ErrorCode.ERR_GlobalSingleTypeNameNotFound, location, whereText)
2539: diagnostics.Add(ErrorCode.ERR_GlobalSingleTypeNameNotFoundFwd, location, whereText, forwardedToAssembly);
2553? diagnostics.Add(ErrorCode.ERR_DottedTypeNameNotFoundInNS, location, whereText, container)
2554: diagnostics.Add(ErrorCode.ERR_DottedTypeNameNotFoundInNSFwd, location, whereText, container, forwardedToAssembly);
2561return diagnostics.Add(ErrorCode.ERR_AliasNotFound, location, whereText);
2566var code = (where.Parent is QueryClauseSyntax) ? ErrorCode.ERR_TypeVarNotFoundRangeVariable : ErrorCode.ERR_TypeVarNotFound;
2575? diagnostics.Add(ErrorCode.ERR_SingleTypeNameNotFoundFwd, location, whereText, forwardedToAssembly)
2576: diagnostics.Add(ErrorCode.ERR_DottedTypeNameNotFoundInNSFwd, location, whereText, qualifierOpt, forwardedToAssembly);
2579return diagnostics.Add(ErrorCode.ERR_SingleTypeNameNotFound, location, whereText);
2601if (diagInfo.Code == (int)ErrorCode.ERR_CycleInTypeForwarder)
2604diagnostics.Add(ErrorCode.ERR_CycleInTypeForwarder, location, fullName, forwardedType.ContainingAssembly.Name);
2606else if (diagInfo.Code == (int)ErrorCode.ERR_TypeForwardedToMultipleAssemblies)
Binder\Binder_TupleOperators.cs (3)
189Error(diagnostics, ErrorCode.ERR_BadBinaryOps, node, node.OperatorToken.Text, left.Display, right.Display);
225Error(diagnostics, ErrorCode.ERR_TupleSizesMismatchForBinOps, node, leftCardinality, rightCardinality);
321diagnostics.Add(ErrorCode.WRN_TupleBinopLiteralNameMismatch, location, complaintName);
Binder\ExecutableCodeBinder.cs (7)
114diagnostics.Add(ErrorCode.ERR_BadIteratorArgType, parameter.Locations[0]);
118diagnostics.Add(ErrorCode.ERR_UnsafeIteratorArgType, parameter.Locations[0]);
126diagnostics.Add(ErrorCode.ERR_VarargsIterator, errorLocation);
132diagnostics.Add(ErrorCode.ERR_IllegalInnerUnsafe, errorLocation);
143Error(diagnostics, ErrorCode.ERR_BadIteratorReturnRef, errorLocation, iterator);
147Error(diagnostics, ErrorCode.ERR_BadIteratorReturn, errorLocation, iterator, returnType);
154diagnostics.Add(ErrorCode.ERR_IteratorMustBeAsync, errorLocation, iterator, returnType);
Binder\ForEachLoopBinder.cs (29)
231Error(diagnostics, ErrorCode.ERR_RefLvalueExpected, collectionExpr.Syntax);
245diagnostics.Add(ErrorCode.ERR_BadGetAsyncEnumerator, expr.Location, getEnumeratorMethod.ReturnTypeWithAnnotations, getEnumeratorMethod);
305diagnostics.Add(ErrorCode.ERR_ScopedRefAndRefStructOnly, typeSyntax.Location);
368Error(diagnostics, ErrorCode.ERR_MustDeclareForeachIteration, variables);
386Error(diagnostics, ErrorCode.ERR_MustDeclareForeachIteration, variables);
451Error(diagnostics, ErrorCode.ERR_RefAssignmentMustHaveIdentityConversion, collectionExpr.Syntax, iterationVariableType.Type);
463diagnostics.Add(ErrorCode.ERR_AmbigUDConv, foreachKeyword.GetLocation(), originalUserDefinedConversions[0], originalUserDefinedConversions[1], inferredType.Type, iterationVariableType);
468diagnostics.Add(ErrorCode.ERR_NoExplicitConv, foreachKeyword.GetLocation(), distinguisher.First, distinguisher.Second);
508diagnostics.Add(ErrorCode.ERR_BadSpecialByRefIterator, foreachKeyword.GetLocation(), getEnumeratorType);
730var errorCode = wrongAsync
731? (isAsync ? ErrorCode.ERR_AwaitForEachMissingMemberWrongAsync : ErrorCode.ERR_ForEachMissingMemberWrongAsync)
732: (isAsync ? ErrorCode.ERR_AwaitForEachMissingMember : ErrorCode.ERR_ForEachMissingMember);
755diagnostics.Add(ErrorCode.ERR_AnonMethGrpInForEach, _syntax.Expression.Location, collectionExpr.Display);
772diagnostics.Add(ErrorCode.ERR_BadDynamicAwaitForEach, _syntax.Expression.Location);
804diagnostics.Add(ErrorCode.ERR_ForEachMissingMember, _syntax.Expression.Location, unwrappedCollectionExprType, GetEnumeratorMethodName);
811diagnostics.Add(ErrorCode.ERR_AwaitForEachMissingMember, _syntax.Expression.Location, unwrappedCollectionExprType, GetAsyncEnumeratorMethodName);
864diagnostics.Add(isAsync ? ErrorCode.ERR_BadGetAsyncEnumerator : ErrorCode.ERR_BadGetEnumerator, _syntax.Expression.Location, getEnumeratorMethod.ReturnType, getEnumeratorMethod);
885diagnostics.Add(isAsync ? ErrorCode.ERR_MultipleIAsyncEnumOfT : ErrorCode.ERR_MultipleIEnumOfT, errorLocationSyntax.Location, unwrappedCollectionExprType,
914diagnostics.Add(ErrorCode.ERR_AwaitForEachMissingMember, _syntax.Expression.Location, unwrappedCollectionExprType, GetAsyncEnumeratorMethodName);
1004diagnostics.Add(ErrorCode.ERR_NullNotValid, _syntax.Expression.Location);
1244diagnostics.Add(ErrorCode.WRN_PatternNotPublicOrNotInstance, _syntax.Expression.Location, patternType, patternName.Localize(), result);
1276diagnostics.Add(ErrorCode.WRN_PatternIsAmbiguous, _syntax.Expression.Location, patternType, MessageID.IDS_Collection.Localize(),
1347diagnostics.Add(ErrorCode.WRN_PatternIsAmbiguous, _syntax.Expression.Location, collectionExpr.Type, MessageID.IDS_Collection.Localize(),
1506diagnostics.Add(ErrorCode.WRN_PatternBadSignature, _syntax.Expression.Location, enumeratorType, MessageID.IDS_Collection.Localize(), patternMemberCandidate);
1676diagnostics.Add(ErrorCode.ERR_NoSuchMember, _syntax.Expression.Location, patternType, memberName);
Binder\Semantics\OverloadResolution\OverloadResolutionResult.cs (41)
478diagnostics.Add(ErrorCode.ERR_FunctionPointersCannotBeCalledWithNamedArguments, badName);
567(ErrorCode)diagInfo.Code,
578ErrorCode.ERR_WrongFuncPtrCallingConvention,
612ErrorCode.ERR_BadAccess,
641diagnostics.Add(ErrorCode.ERR_QueryNoProvider, location, receiverOpt.Type, symbol.Name);
645diagnostics.Add(ErrorCode.ERR_InitializerAddHasWrongSignature, location, symbol);
649diagnostics.Add(ErrorCode.ERR_BadAwaitArg, location, receiverOpt.Type);
653diagnostics.Add(ErrorCode.ERR_FuncPtrMethMustBeStatic, location, symbol);
657ErrorCode errorCode =
660? ErrorCode.ERR_FieldInitRefNonstatic
661: ErrorCode.ERR_ObjectRequired
662: ErrorCode.ERR_ObjectProhibited;
681diagnostics.Add(delegateOrFunctionPointerType.IsFunctionPointer() ? ErrorCode.ERR_FuncPtrRefMismatch : ErrorCode.ERR_DelegateRefMismatch,
690diagnostics.Add(ErrorCode.ERR_BadRetType, location, method, method.ReturnType);
737ErrorCode.ERR_CantInferMethTypeArgs,
757ErrorCode.ERR_NoSuchMemberOrExtension,
783ErrorCode.ERR_NamedArgumentUsedInPositional,
803ErrorCode.ERR_BadNonTrailingNamedArgument,
816diagnostics.Add(new CSDiagnosticInfo(ErrorCode.ERR_DuplicateNamedArgument, name), location);
844ErrorCode code = (object)delegateTypeBeingInvoked != null ?
845ErrorCode.ERR_BadNamedArgumentForDelegateInvoke :
846ErrorCode.ERR_BadNamedArgument;
896ErrorCode.ERR_NoCorrespondingArgument,
919(ErrorCode code, object target) = (typeContainingConstructor, delegateTypeBeingInvoked, functionPointerMethodBeingInvoked) switch
921(object t, _, _) => (ErrorCode.ERR_BadCtorArgCount, t),
922(_, object t, _) => (ErrorCode.ERR_BadDelArgCount, t),
923(_, _, object t) => (ErrorCode.ERR_BadFuncPointerArgCount, t),
924_ => (ErrorCode.ERR_BadArgCount, name)
1097diagnostics.Add(ErrorCode.ERR_InitializerAddHasParamModifiers, location, symbols, method);
1103diagnostics.Add(ErrorCode.ERR_BadArgTypesForCollectionAdd, location, symbols, method);
1143ErrorCode.ERR_BadArgType,
1192diagnostics.Add(ErrorCode.ERR_MissingAddressOf, sourceLocation);
1205ErrorCode.ERR_BadArgType,
1219ErrorCode.ERR_BadArgExtraRef,
1229ErrorCode.ERR_BadArgRef,
1250ErrorCode.ERR_BadInstanceArgType,
1277ErrorCode.ERR_BadArgType,
1287ErrorCode.ERR_BadArgType,
1336diagnostics.Add(ErrorCode.ERR_QueryMultipleProviders, location, receiver.Type, name);
1446return new DiagnosticInfoWithSymbols(ErrorCode.ERR_AmbigCall, arguments, symbols);
CommandLine\CSharpCommandLineParser.cs (103)
152AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, "<text>", name.ToString());
207AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_Text.Localize(), "/langversion:");
213AddDiagnostic(diagnostics, ErrorCode.ERR_LanguageVersionCannotHaveLeadingZeroes, value);
221AddDiagnostic(diagnostics, ErrorCode.ERR_BadCompatMode, value);
234AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsNumber, nameMemory.ToString());
240AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsNumber, nameMemory.ToString());
302AddDiagnostic(diagnostics, ErrorCode.ERR_StdInOptionProvidedButConsoleInputIsNotRedirected);
344AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, "<text>", arg);
357AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, "<text>", name);
364AddDiagnostic(diagnostics, ErrorCode.FTL_BadCodepage, value);
375AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, "<text>", name);
382AddDiagnostic(diagnostics, ErrorCode.FTL_BadChecksumAlgorithm, value);
413AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_Text.Localize(), name);
437AddDiagnostic(diagnostics, ErrorCode.ERR_BadNullableContextOption, value);
467AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, "<text>", name);
492AddDiagnostic(diagnostics, ErrorCode.ERR_MissingGuidForOption, "<text>", name);
499AddDiagnostic(diagnostics, ErrorCode.ERR_InvalidFormatForGuidForOption, value, name);
509AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, "<text>", arg);
528AddDiagnostic(diagnostics, ErrorCode.WRN_BadUILang, value);
542AddDiagnostic(diagnostics, ErrorCode.ERR_NoFileSpec, arg);
555AddDiagnostic(diagnostics, ErrorCode.ERR_NoFileSpec, arg);
581AddDiagnostic(diagnostics, ErrorCode.FTL_InvalidTarget);
596AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, "<text>", arg);
601AddDiagnostic(diagnostics, ErrorCode.ERR_InvalidAssemblyName, "<text>", arg);
614AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_Text.Localize(), "modulename");
628AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, "<string>", arg);
645AddDiagnostic(diagnostics, ErrorCode.ERR_NoFileSpec, arg);
662AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_Text.Localize(), arg);
675AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_Text.Localize(), arg);
683AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_Text.Localize(), "/doc:"); // Different argument.
695AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_Text.Localize(), "/addmodule:");
699AddDiagnostic(diagnostics, ErrorCode.ERR_NoFileSpec, arg);
770AddDiagnostic(diagnostics, ErrorCode.ERR_NoFileSpec, arg);
787AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_Text.Localize(), name);
803AddDiagnostic(diagnostics, ErrorCode.ERR_BadDebugType, value);
898AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsNumber, name);
919AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsNumber, name);
946AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsNumber, name);
954AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsNumber, name);
958AddDiagnostic(diagnostics, ErrorCode.ERR_BadWarningLevel);
1023AddDiagnostic(diagnostics, ErrorCode.ERR_NoFileSpec, "keyfile");
1044AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_Text.Localize(), "keycontainer");
1088AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsNumber, name);
1092AddDiagnostic(diagnostics, ErrorCode.ERR_BadBaseNumber, value);
1106AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_Text.Localize(), "subsystemversion");
1118AddDiagnostic(diagnostics, ErrorCode.ERR_InvalidSubsystemVersion, value);
1127AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_Text.Localize(), "touchedfiles");
1155AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, "<text>", name);
1189AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsNumber, name);
1193AddDiagnostic(diagnostics, ErrorCode.ERR_InvalidFileAlignment, value);
1197AddDiagnostic(diagnostics, ErrorCode.ERR_InvalidFileAlignment, value);
1209AddDiagnostic(diagnostics, ErrorCode.ERR_NoFileSpec, arg);
1262AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, ErrorLogOptionFormat, RemoveQuotesAndSlashes(arg));
1269AddDiagnostic(diagnostics, ErrorCode.ERR_BadSwitchValue, valueMemory.Value.ToString(), "/errorlog:", ErrorLogOptionFormat);
1278AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, ":<text>", RemoveQuotesAndSlashes(arg));
1290AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, "<text>", name);
1304AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, "<file list>", name);
1319AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, "<file list>", name);
1354AddDiagnostic(diagnostics, ErrorCode.ERR_StdInOptionProvidedButConsoleInputIsNotRedirected);
1360AddDiagnostic(diagnostics, ErrorCode.ERR_BadSwitch, arg);
1376AddDiagnostic(diagnostics, diagnosticOptions, ErrorCode.ERR_NoRefOutWhenRefOnly);
1381AddDiagnostic(diagnostics, diagnosticOptions, ErrorCode.ERR_NoNetModuleOutputWhenRefOutOrRefOnly);
1386AddDiagnostic(diagnostics, diagnosticOptions, ErrorCode.WRN_NoSources);
1398AddDiagnostic(diagnostics, ErrorCode.ERR_BadBaseNumber, string.Format("0x{0:X}", baseAddress));
1422AddDiagnostic(diagnostics, ErrorCode.ERR_NoOutputDirectory);
1437AddDiagnostic(diagnostics, ErrorCode.ERR_SourceLinkRequiresPdb);
1447AddDiagnostic(diagnostics, ErrorCode.ERR_CannotEmbedWithoutPdb);
1523diagnostics.Add(new CSDiagnostic(new CSDiagnosticInfo(ErrorCode.ERR_NullableOptionNotAvailable,
1588AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_PathList.Localize(), switchName);
1597AddDiagnostic(diagnostics, ErrorCode.WRN_InvalidSearchPathDir, path, origin.Localize(), MessageID.IDS_DirectoryHasInvalidPath.Localize());
1601AddDiagnostic(diagnostics, ErrorCode.WRN_InvalidSearchPathDir, path, origin.Localize(), MessageID.IDS_DirectoryDoesNotExist.Localize());
1614AddDiagnostic(diagnostics, ErrorCode.ERR_NoFileSpec, arg);
1621AddDiagnostic(diagnostics, ErrorCode.ERR_NoFileSpec, arg);
1651AddDiagnostic(diagnostics, ErrorCode.ERR_OutputNeedsName);
1665AddDiagnostic(diagnostics, ErrorCode.FTL_InvalidInputFileName, outputFileName);
1676AddDiagnostic(diagnostics, ErrorCode.FTL_InvalidInputFileName, outputFileName);
1691AddDiagnostic(diagnostics, ErrorCode.ERR_AssemblyNameOnNonModule);
1745outputDiagnostics.Add(Diagnostic.Create(CSharp.MessageProvider.Instance, (int)ErrorCode.WRN_DefineIdentifierRequired, valueMemory.ToString()));
1777outputDiagnostics.Add(Diagnostic.Create(CSharp.MessageProvider.Instance, (int)ErrorCode.WRN_DefineIdentifierRequired, id));
1803AddDiagnostic(diagnostics, ErrorCode.ERR_BadPlatformType, value);
1831AddDiagnostic(diagnostics, ErrorCode.FTL_InvalidTarget);
1840AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_Namespace1.Localize(), arg);
1854AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_Text.Localize(), arg);
1859AddDiagnostic(diagnostics, ErrorCode.ERR_NoFileSpec, arg);
1881AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_Text.Localize(), arg);
1888AddDiagnostic(diagnostics, ErrorCode.ERR_NoFileSpec, arg);
1913AddDiagnostic(diagnostics, ErrorCode.ERR_BadExternIdentifier, alias);
1949AddDiagnostic(diagnostics, ErrorCode.ERR_OneAliasPerReference);
1955AddDiagnostic(diagnostics, ErrorCode.ERR_AliasMissingFile, alias);
1967AddDiagnostic(diagnostics, ErrorCode.ERR_CantHaveWin32ResAndIcon);
1972AddDiagnostic(diagnostics, ErrorCode.ERR_CantHaveWin32ResAndManifest);
1978AddDiagnostic(diagnostics, ErrorCode.WRN_CantHaveManifestForModule);
1994AddDiagnostic(diagnostics, ErrorCode.ERR_InvalidInstrumentationKind, kind);
2048AddDiagnostic(diagnostics, ErrorCode.ERR_BadResourceVis, accessibility);
2054AddDiagnostic(diagnostics, ErrorCode.ERR_NoFileSpec, arg);
2061AddDiagnostic(diagnostics, ErrorCode.FTL_InvalidInputFileName, filePath);
2090ids.Add(CSharp.MessageProvider.Instance.GetIdForErrorCode((int)ErrorCode.WRN_MissingNonNullTypesContextForAnnotation));
2091ids.Add(CSharp.MessageProvider.Instance.GetIdForErrorCode((int)ErrorCode.WRN_MissingNonNullTypesContextForAnnotationInGeneratedCode));
2097ErrorFacts.IsWarning((ErrorCode)number))
2139AddDiagnostic(diagnostics, ErrorCode.WRN_UnimplementedCommandLineSwitch, "/" + switchName);
2147private static void AddDiagnostic(IList<Diagnostic> diagnostics, ErrorCode errorCode)
2152private static void AddDiagnostic(IList<Diagnostic> diagnostics, ErrorCode errorCode, params object[] arguments)
2160private static void AddDiagnostic(IList<Diagnostic> diagnostics, Dictionary<string, ReportDiagnostic> warningOptions, ErrorCode errorCode, params object[] arguments)
Compilation\CSharpCompilation.cs (29)
513diagnostics.Add(ErrorCode.ERR_DebugEntryPointNotSourceMethodDefinition, Location.None);
1598ErrorCode.ERR_GlobalSingleTypeNameNotFound,
1700diagnostics.Add(ErrorCode.ERR_SimpleProgramNotAnExecutable, simpleProgramEntryPointSymbol.ReturnTypeSyntax.Location);
1728diagnostics.Add(ErrorCode.ERR_SimpleProgramDisallowsMainType, NoLocation.Singleton);
1761diagnostics.Add(ErrorCode.WRN_MainIgnored, NoLocation.Singleton, mainTypeName);
1768diagnostics.Add(ErrorCode.ERR_MainClassNotFound, NoLocation.Singleton, mainTypeName);
1775diagnostics.Add(ErrorCode.ERR_MainClassNotClass, mainTypeOrNamespace.Locations.First(), mainTypeOrNamespace);
1796diagnostics.Add(ErrorCode.WRN_MainIgnored, main.Locations.First(), main);
1824noMainFoundDiagnostics.Add(ErrorCode.WRN_InvalidMainSig, candidate.Locations.First(), candidate);
1832noMainFoundDiagnostics.Add(ErrorCode.WRN_MainCantBeGeneric, candidate.Locations.First(), candidate);
1855diagnostics.Add(ErrorCode.ERR_NonTaskMainCantBeAsync, candidate.Locations.First());
1888ErrorCode.WRN_SyncAndAsyncEntryPoints,
1916if (diagnostic.Code == (int)ErrorCode.WRN_InvalidMainSig || diagnostic.Code == (int)ErrorCode.WRN_MainCantBeGeneric)
1930diagnostics.Add(ErrorCode.ERR_NoEntryPoint, NoLocation.Singleton);
1934diagnostics.Add(ErrorCode.ERR_NoMainInClass, mainType.Locations.First(), mainType);
1945diagnostics.Add(ErrorCode.ERR_EntryPointCannotBeUnmanagedCallersOnly, viableEntryPoint.Locations.First());
1953ErrorCode.ERR_MultipleEntryPoints,
2079=> code == (int)ErrorCode.ERR_NoTypeDef;
2402ErrorCode code = info.Kind == SyntaxKind.ExternAliasDirective
2403? ErrorCode.HDN_UnusedExternAlias
2404: ErrorCode.HDN_UnusedUsingDirective;
2725builder.Add(new CSDiagnostic(new CSDiagnosticInfo(ErrorCode.ERR_NullableOptionNotAvailable,
3204excludeDiagnostics.Add((int)ErrorCode.ERR_ConcreteMissingBody);
3224diagnostics.Add(ErrorCode.ERR_ModuleEmitFailure, NoLocation.Singleton, ((Cci.INamedEntity)moduleBeingBuilt).Name,
3335_diagnostics.Add(ErrorCode.ERR_FileTypeNonUniquePath, location, symbol, filePath);
3427diagnostics.Add(new CSDiagnosticInfo(ErrorCode.ERR_BindToBogus, m), NoLocation.Singleton);
3469runtimeMDVersionDiagnostics.Add(ErrorCode.WRN_NoRuntimeMetadataVersion, NoLocation.Singleton);
3533diagnostics.Add(ErrorCode.WRN_ConflictingChecksum, new SourceLocation(checksumDirective), path);
Compiler\ClsComplianceChecker.cs (41)
125this.AddDiagnostic(ErrorCode.WRN_CLS_NotOnModules, warningLocation);
129this.AddDiagnostic(ErrorCode.WRN_CLS_NotOnModules2, warningLocation);
148this.AddDiagnostic(ErrorCode.WRN_CLS_ModuleMissingCLS, warningLocation);
253this.AddDiagnostic(ErrorCode.WRN_CLS_BadAttributeType, symbol.Locations[0], symbol);
328this.AddDiagnostic(ErrorCode.WRN_CLS_NoVarArgs, symbol.Locations[0]);
343this.AddDiagnostic(ErrorCode.ERR_AttributeNotOnAccessor, attributeLocation, attribute.AttributeClass.Name, attributeUsage.GetValidTargetsErrorArgument());
407this.AddDiagnostic(ErrorCode.WRN_CLS_VolatileField, symbol.Locations[0], symbol);
453this.AddDiagnostic(ErrorCode.WRN_CLS_MeaninglessOnPrivateType, symbol.Locations[0], symbol);
497this.AddDiagnostic(ErrorCode.WRN_CLS_BadInterfaceMember, symbol.Locations[0], symbol);
501this.AddDiagnostic(ErrorCode.WRN_CLS_NoAbstractMembers, symbol.Locations[0], symbol);
518this.AddDiagnostic(ErrorCode.WRN_CLS_BadInterface, symbol.Locations[0], symbol, interfaceType);
529this.AddDiagnostic(ErrorCode.WRN_CLS_BadBase, symbol.Locations[0], symbol, baseType);
542this.AddDiagnostic(ErrorCode.WRN_CLS_IllegalTrueInFalse, symbol.Locations[0], symbol, containingType);
559this.AddDiagnostic(ErrorCode.WRN_CLS_BadTypeVar, typeParameter.Locations[0], constraintType.Type);
573this.AddDiagnostic(ErrorCode.WRN_CLS_BadArgType, parameter.Locations[0], parameter.Type);
605this.AddDiagnostic(ErrorCode.WRN_CLS_ArrayArgumentToAttribute, warningLocation);
621this.AddDiagnostic(ErrorCode.WRN_CLS_ArrayArgumentToAttribute, warningLocation);
639this.AddDiagnostic(ErrorCode.WRN_CLS_ArrayArgumentToAttribute, warningLocation);
690this.AddDiagnostic(ErrorCode.WRN_CLS_MeaninglessOnParam, attributeLocation);
700this.AddDiagnostic(ErrorCode.WRN_CLS_MeaninglessOnReturn, attributeLocation);
708ErrorCode code;
713code = ErrorCode.WRN_CLS_BadFieldPropType;
717code = ErrorCode.WRN_CLS_BadFieldPropType;
721code = ErrorCode.WRN_CLS_BadFieldPropType;
725code = ErrorCode.WRN_CLS_BadReturnType;
785ErrorCode code = IsTrue(compliance)
786? ErrorCode.WRN_CLS_AssemblyNotCLS
787: ErrorCode.WRN_CLS_AssemblyNotCLS2;
889this.AddDiagnostic(ErrorCode.WRN_CLS_BadIdentifierCase, symbol.Locations[0], symbol);
902ErrorCode code;
914this.AddDiagnostic(ErrorCode.WRN_CLS_BadIdentifierCase, symbol.Locations[0], symbol);
949this.AddDiagnostic(ErrorCode.WRN_CLS_BadIdentifier, symbol.Locations[0], name);
1246private void AddDiagnostic(ErrorCode code, Location location)
1253private void AddDiagnostic(ErrorCode code, Location location, params object[] args)
1309private static bool TryGetCollisionErrorCode(Symbol x, Symbol y, out ErrorCode code)
1316code = ErrorCode.Void;
1403sawArrayOfArraysDifference ? ErrorCode.WRN_CLS_OverloadUnnamed :
1404sawArrayRankDifference ? ErrorCode.WRN_CLS_OverloadRefOut : // Lumping rank difference with refkind is odd, but matches dev11.
1405sawRefKindDifference ? ErrorCode.WRN_CLS_OverloadRefOut :
1406ErrorCode.Void;
1408return code != ErrorCode.Void;
Compiler\DocumentationCommentCompiler.cs (13)
112diagnostics.Add(ErrorCode.ERR_DocFileGen, Location.None, e.Message);
311_diagnostics.Add(ErrorCode.WRN_MissingXMLComment, location, symbol);
382_diagnostics.Add(ErrorCode.WRN_MissingParamTag, location, parameter.Name, symbol);
396_diagnostics.Add(ErrorCode.WRN_MissingTypeParamTag, location, typeParameter, symbol);
557_diagnostics.Add(ErrorCode.WRN_XMLParseError, location, GetDescription(e));
740if ((ErrorCode)diag.Code == ErrorCode.WRN_XMLParseError)
1162diagnostics.Add(ErrorCode.WRN_UnmatchedParamTag, identifier.Location, identifier);
1165diagnostics.Add(ErrorCode.WRN_UnmatchedParamRefTag, identifier.Location, identifier, memberSymbol);
1168diagnostics.Add(ErrorCode.WRN_UnmatchedTypeParamTag, identifier.Location, identifier);
1171diagnostics.Add(ErrorCode.WRN_UnmatchedTypeParamRefTag, identifier.Location, identifier, memberSymbol);
1192diagnostics.Add(ErrorCode.WRN_DuplicateParamTag, syntax.Location, identifier);
1202diagnostics.Add(ErrorCode.WRN_DuplicateTypeParamTag, syntax.Location, identifier);
Compiler\DocumentationCommentCompiler.IncludeElementExpander.cs (7)
283_diagnostics.Add(ErrorCode.WRN_FailedInclude, location, filePathValue, xpathValue, new LocalizableErrorArgument(MessageID.IDS_OperationCausedStackOverflow));
304includeDiagnostics.Add(ErrorCode.WRN_InvalidInclude, location, subMessage);
315includeDiagnostics.Add(ErrorCode.WRN_FailedInclude, location, filePathValue, xpathValue, new CodeAnalysisResourcesLocalizableErrorArgument(nameof(CodeAnalysisResources.XmlReferencesNotSupported)));
325includeDiagnostics.Add(ErrorCode.WRN_FailedInclude, location, filePathValue, xpathValue, new CodeAnalysisResourcesLocalizableErrorArgument(nameof(CodeAnalysisResources.FileNotFound)));
346includeDiagnostics.Add(ErrorCode.WRN_FailedInclude, location, filePathValue, xpathValue, e.Message);
358includeDiagnostics.Add(ErrorCode.WRN_FailedInclude, location, filePathValue, xpathValue, errorMessage);
405includeDiagnostics.Add(ErrorCode.WRN_XMLParseIncludeError, errorLocation, GetDescription(e)); //NOTE: location is in included file.
CSharpCompilationOptions.cs (11)
671builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_NoMainOnDLL));
676builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(MainTypeName), MainTypeName));
682builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadPlatformType, Platform.ToString()));
687MetadataHelpers.CheckAssemblyOrModuleName(ModuleName, MessageProvider.Instance, (int)ErrorCode.ERR_BadModuleName, builder);
692builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(OutputKind), OutputKind.ToString()));
697builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(OptimizationLevel), OptimizationLevel.ToString()));
702builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(ScriptClassName), ScriptClassName ?? "null"));
707builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(WarningLevel), WarningLevel));
712builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(Usings), Usings.Where(u => !u.IsValidClrNamespaceName()).First() ?? "null"));
717builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadPrefer32OnLib));
722builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(MetadataImportOptions), MetadataImportOptions.ToString()));
Declarations\DeclarationTreeBuilder.cs (12)
120bag.Add(ErrorCode.ERR_SimpleProgramIsEmpty, ((EmptyStatementSyntax)firstGlobalStatement.Statement).SemicolonToken.GetLocation());
365diagnostics.Add(ErrorCode.ERR_GlobalUsingOutOfOrder, directive.GlobalKeyword.GetLocation());
451diagnostics.Add(ErrorCode.ERR_MultipleFileScopedNamespace, node.Name.GetLocation());
460diagnostics.Add(ErrorCode.ERR_FileScopedAndNormalNamespace, node.Name.GetLocation());
478diagnostics.Add(ErrorCode.ERR_FileScopedNamespaceNotBeforeAllMembers, node.Name.GetLocation());
490diagnostics.Add(ErrorCode.ERR_FileScopedAndNormalNamespace, node.Name.GetLocation());
497diagnostics.Add(ErrorCode.ERR_UnexpectedGenericName, node.Name.GetLocation());
502diagnostics.Add(ErrorCode.ERR_UnexpectedAliasedName, node.Name.GetLocation());
507diagnostics.Add(ErrorCode.ERR_BadModifiersOnNamespace, node.AttributeLists[0].GetLocation());
512diagnostics.Add(ErrorCode.ERR_BadModifiersOnNamespace, node.Modifiers[0].GetLocation());
519diagnostics.Add(ErrorCode.ERR_GlobalUsingInNamespace, directive.GlobalKeyword.GetLocation());
643diagnostics.Add(ErrorCode.ERR_UnexpectedParameterList, node.ParameterList.GetLocation());
Emitter\Model\PEModuleBuilder.cs (10)
173diagnostics.Add(new CSDiagnosticInfo(ErrorCode.WRN_ReferencedAssemblyDoesNotHaveStrongName, assembly), NoLocation.Singleton);
180diagnostics.Add(new CSDiagnosticInfo(ErrorCode.WRN_RefCultureMismatch, assembly, refIdentity.CultureName), NoLocation.Singleton);
199diagnostics.Add(new CSDiagnosticInfo(ErrorCode.WRN_ConflictingMachineAssembly, assembly), NoLocation.Singleton);
676diagnostics.Add(ErrorCode.ERR_ExportedTypeConflictsWithDeclaration, NoLocation.Singleton, type, type.ContainingModule);
680diagnostics.Add(ErrorCode.ERR_ForwardedTypeConflictsWithDeclaration, NoLocation.Singleton, type);
696diagnostics.Add(ErrorCode.ERR_ExportedTypesConflict, NoLocation.Singleton, type, type.ContainingModule, contender, contender.ContainingModule);
701diagnostics.Add(ErrorCode.ERR_ForwardedTypeConflictsWithExportedType, NoLocation.Singleton, type, type.ContainingAssembly, contender, contender.ContainingModule);
706diagnostics.Add(ErrorCode.ERR_ForwardedTypesConflict, NoLocation.Singleton, type, type.ContainingAssembly, contender, contender.ContainingAssembly);
972diagnostics.Add(new CSDiagnostic(diagInfo ?? new CSDiagnosticInfo(ErrorCode.ERR_BogusType, string.Empty), syntaxNodeOpt == null ? NoLocation.Singleton : syntaxNodeOpt.Location));
1089new CSDiagnosticInfo(ErrorCode.ERR_PredefinedValueTupleTypeMustBeStruct, namedTypeSymbol.MetadataName),
Emitter\NoPia\EmbeddedTypesManager.cs (17)
191Error(diagnostics, ErrorCode.ERR_InteropTypesWithSameNameAndGuid, null,
200Error(diagnostics, ErrorCode.ERR_LocalTypeNameClash, null,
223Error(diagnostics, ErrorCode.WRN_ReferencedAssemblyReferencesLinkedPIA, null,
249ErrorCode error = ErrorCode.Unknown;
260error = ErrorCode.ERR_DefaultInterfaceImplementationInNoPIAType;
265error = ErrorCode.ERR_ReAbstractionInNoPIAType;
271if (error != ErrorCode.Unknown)
285error = ErrorCode.ERR_NoPIANestedType;
293error = ErrorCode.ERR_GenericsUsedInNoPIAType;
300error = ErrorCode.ERR_NewCoClassOnLink;
304if (error != ErrorCode.Unknown)
313private static void ReportNotEmbeddableSymbol(ErrorCode error, Symbol symbol, SyntaxNode syntaxNodeOpt, DiagnosticBag diagnostics, EmbeddedTypesManager optTypeManager)
322internal static void Error(DiagnosticBag diagnostics, ErrorCode code, SyntaxNode syntaxOpt, params object[] args)
445ReportNotEmbeddableSymbol(ErrorCode.ERR_InteropStructContainsMethods, field.AdaptedFieldSymbol.ContainingType, syntaxNodeOpt, diagnostics, this);
480ReportNotEmbeddableSymbol(ErrorCode.ERR_InteropStructContainsMethods, type.UnderlyingNamedType.AdaptedNamedTypeSymbol, syntaxNodeOpt, diagnostics, this);
487Error(diagnostics, ErrorCode.ERR_InteropMethodWithBody, syntaxNodeOpt, method.AdaptedMethodSymbol.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat));
Errors\MessageProvider.cs (98)
39return ErrorFacts.GetSeverity((ErrorCode)code);
44return ErrorFacts.GetMessage((ErrorCode)code, language);
49return ErrorFacts.GetMessageFormat((ErrorCode)code);
54return ErrorFacts.GetDescription((ErrorCode)code);
59return ErrorFacts.GetTitle((ErrorCode)code);
64return ErrorFacts.GetHelpLink((ErrorCode)code);
69return ErrorFacts.GetCategory((ErrorCode)code);
91return ErrorFacts.GetWarningLevel((ErrorCode)code);
96get { return typeof(ErrorCode); }
101var info = new CSDiagnosticInfo((ErrorCode)code, args, ImmutableArray<Symbol>.Empty, ImmutableArray<Location>.Empty);
122(ErrorCode)code is not (
123ErrorCode.WRN_UseDefViolationPropertySupportedVersion
124or ErrorCode.WRN_UseDefViolationFieldSupportedVersion
125or ErrorCode.WRN_UseDefViolationThisSupportedVersion
126or ErrorCode.WRN_UnassignedThisAutoPropertySupportedVersion
127or ErrorCode.WRN_UnassignedThisSupportedVersion
150return (ErrorCode)errorCode switch
153ErrorCode.Unknown => false,
154ErrorCode.Void => false,
155ErrorCode.ERR_IdentifierExpectedKW => false, // message uses {1} rather than {0}
156ErrorCode.WRN_XMLParseError => false, // XmlSyntaxDiagnosticInfo.GetMessage() uses distinct error code
162public override int ERR_FailedToCreateTempFile => (int)ErrorCode.ERR_CantMakeTempFile;
163public override int ERR_MultipleAnalyzerConfigsInSameDir => (int)ErrorCode.ERR_MultipleAnalyzerConfigsInSameDir;
166public override int ERR_ExpectedSingleScript => (int)ErrorCode.ERR_ExpectedSingleScript;
167public override int ERR_OpenResponseFile => (int)ErrorCode.ERR_OpenResponseFile;
168public override int ERR_InvalidPathMap => (int)ErrorCode.ERR_InvalidPathMap;
169public override int FTL_InvalidInputFileName => (int)ErrorCode.FTL_InvalidInputFileName;
170public override int ERR_FileNotFound => (int)ErrorCode.ERR_FileNotFound;
171public override int ERR_NoSourceFile => (int)ErrorCode.ERR_NoSourceFile;
172public override int ERR_CantOpenFileWrite => (int)ErrorCode.ERR_CantOpenFileWrite;
173public override int ERR_OutputWriteFailed => (int)ErrorCode.ERR_OutputWriteFailed;
174public override int WRN_NoConfigNotOnCommandLine => (int)ErrorCode.WRN_NoConfigNotOnCommandLine;
175public override int ERR_BinaryFile => (int)ErrorCode.ERR_BinaryFile;
176public override int WRN_AnalyzerCannotBeCreated => (int)ErrorCode.WRN_AnalyzerCannotBeCreated;
177public override int WRN_NoAnalyzerInAssembly => (int)ErrorCode.WRN_NoAnalyzerInAssembly;
178public override int WRN_UnableToLoadAnalyzer => (int)ErrorCode.WRN_UnableToLoadAnalyzer;
179public override int WRN_AnalyzerReferencesFramework => (int)ErrorCode.WRN_AnalyzerReferencesFramework;
180public override int WRN_AnalyzerReferencesNewerCompiler => (int)ErrorCode.WRN_AnalyzerReferencesNewerCompiler;
181public override int WRN_DuplicateAnalyzerReference => (int)ErrorCode.WRN_DuplicateAnalyzerReference;
182public override int INF_UnableToLoadSomeTypesInAnalyzer => (int)ErrorCode.INF_UnableToLoadSomeTypesInAnalyzer;
183public override int ERR_CantReadRulesetFile => (int)ErrorCode.ERR_CantReadRulesetFile;
184public override int ERR_CompileCancelled => (int)ErrorCode.ERR_CompileCancelled;
187public override int ERR_BadSourceCodeKind => (int)ErrorCode.ERR_BadSourceCodeKind;
188public override int ERR_BadDocumentationMode => (int)ErrorCode.ERR_BadDocumentationMode;
191public override int ERR_BadCompilationOptionValue => (int)ErrorCode.ERR_BadCompilationOptionValue;
192public override int ERR_MutuallyExclusiveOptions => (int)ErrorCode.ERR_MutuallyExclusiveOptions;
195public override int ERR_InvalidDebugInformationFormat => (int)ErrorCode.ERR_InvalidDebugInformationFormat;
196public override int ERR_InvalidOutputName => (int)ErrorCode.ERR_InvalidOutputName;
197public override int ERR_InvalidFileAlignment => (int)ErrorCode.ERR_InvalidFileAlignment;
198public override int ERR_InvalidSubsystemVersion => (int)ErrorCode.ERR_InvalidSubsystemVersion;
199public override int ERR_InvalidInstrumentationKind => (int)ErrorCode.ERR_InvalidInstrumentationKind;
200public override int ERR_InvalidHashAlgorithmName => (int)ErrorCode.ERR_InvalidHashAlgorithmName;
203public override int ERR_MetadataFileNotAssembly => (int)ErrorCode.ERR_ImportNonAssembly;
204public override int ERR_MetadataFileNotModule => (int)ErrorCode.ERR_AddModuleAssembly;
205public override int ERR_InvalidAssemblyMetadata => (int)ErrorCode.FTL_MetadataCantOpenFile;
206public override int ERR_InvalidModuleMetadata => (int)ErrorCode.FTL_MetadataCantOpenFile;
207public override int ERR_ErrorOpeningAssemblyFile => (int)ErrorCode.FTL_MetadataCantOpenFile;
208public override int ERR_ErrorOpeningModuleFile => (int)ErrorCode.FTL_MetadataCantOpenFile;
209public override int ERR_MetadataFileNotFound => (int)ErrorCode.ERR_NoMetadataFile;
210public override int ERR_MetadataReferencesNotSupported => (int)ErrorCode.ERR_MetadataReferencesNotSupported;
211public override int ERR_LinkedNetmoduleMetadataMustProvideFullPEImage => (int)ErrorCode.ERR_LinkedNetmoduleMetadataMustProvideFullPEImage;
215diagnostics.Add(ErrorCode.ERR_DuplicateImport, location,
222diagnostics.Add(ErrorCode.ERR_DuplicateImportSimple, location,
228public override int ERR_PublicKeyFileFailure => (int)ErrorCode.ERR_PublicKeyFileFailure;
229public override int ERR_PublicKeyContainerFailure => (int)ErrorCode.ERR_PublicKeyContainerFailure;
230public override int ERR_OptionMustBeAbsolutePath => (int)ErrorCode.ERR_OptionMustBeAbsolutePath;
233public override int ERR_CantReadResource => (int)ErrorCode.ERR_CantReadResource;
234public override int ERR_CantOpenWin32Resource => (int)ErrorCode.ERR_CantOpenWin32Res;
235public override int ERR_CantOpenWin32Manifest => (int)ErrorCode.ERR_CantOpenWin32Manifest;
236public override int ERR_CantOpenWin32Icon => (int)ErrorCode.ERR_CantOpenIcon;
237public override int ERR_ErrorBuildingWin32Resource => (int)ErrorCode.ERR_ErrorBuildingWin32Resources;
238public override int ERR_BadWin32Resource => (int)ErrorCode.ERR_BadWin32Res;
239public override int ERR_ResourceFileNameNotUnique => (int)ErrorCode.ERR_ResourceFileNameNotUnique;
240public override int ERR_ResourceNotUnique => (int)ErrorCode.ERR_ResourceNotUnique;
241public override int ERR_ResourceInModule => (int)ErrorCode.ERR_CantRefResource;
244public override int ERR_PermissionSetAttributeFileReadError => (int)ErrorCode.ERR_PermissionSetAttributeFileReadError;
247public override int ERR_EncodinglessSyntaxTree => (int)ErrorCode.ERR_EncodinglessSyntaxTree;
248public override int WRN_PdbUsingNameTooLong => (int)ErrorCode.WRN_DebugFullNameTooLong;
249public override int WRN_PdbLocalNameTooLong => (int)ErrorCode.WRN_PdbLocalNameTooLong;
250public override int ERR_PdbWritingFailed => (int)ErrorCode.FTL_DebugEmitFailure;
253public override int ERR_MetadataNameTooLong => (int)ErrorCode.ERR_MetadataNameTooLong;
254public override int ERR_EncReferenceToAddedMember => (int)ErrorCode.ERR_EncReferenceToAddedMember;
255public override int ERR_TooManyUserStrings => (int)ErrorCode.ERR_TooManyUserStrings;
256public override int ERR_PeWritingFailure => (int)ErrorCode.ERR_PeWritingFailure;
257public override int ERR_ModuleEmitFailure => (int)ErrorCode.ERR_ModuleEmitFailure;
258public override int ERR_EncUpdateFailedMissingAttribute => (int)ErrorCode.ERR_EncUpdateFailedMissingAttribute;
259public override int ERR_InvalidDebugInfo => (int)ErrorCode.ERR_InvalidDebugInfo;
260public override int ERR_FunctionPointerTypesInAttributeNotSupported => (int)ErrorCode.ERR_FunctionPointerTypesInAttributeNotSupported;
263public override int WRN_GeneratorFailedDuringInitialization => (int)ErrorCode.WRN_GeneratorFailedDuringInitialization;
264public override int WRN_GeneratorFailedDuringGeneration => (int)ErrorCode.WRN_GeneratorFailedDuringGeneration;
270diagnostics.Add(ErrorCode.ERR_InvalidAttributeArgument, attributeArgumentSyntax.Location, node.GetErrorDisplayName());
276diagnostics.Add(ErrorCode.ERR_InvalidNamedArgument, node.ArgumentList.Arguments[namedArgumentIndex].Location, parameterName);
282diagnostics.Add(ErrorCode.ERR_ParameterNotValidForType, node.ArgumentList.Arguments[namedArgumentIndex].Location);
289diagnostics.Add(ErrorCode.ERR_MarshalUnmanagedTypeNotValidForFields, attributeArgumentSyntax.Location, unmanagedTypeName);
296diagnostics.Add(ErrorCode.ERR_MarshalUnmanagedTypeOnlyValidForFields, attributeArgumentSyntax.Location, unmanagedTypeName);
302diagnostics.Add(ErrorCode.ERR_AttributeParameterRequired1, node.Name.Location, parameterName);
308diagnostics.Add(ErrorCode.ERR_AttributeParameterRequired2, node.Name.Location, parameterName1, parameterName2);
311public override int ERR_BadAssemblyName => (int)ErrorCode.ERR_BadAssemblyName;
FlowAnalysis\DefiniteAssignment.cs (51)
413Diagnostics.Add(ErrorCode.WRN_AsyncLacksAwaits, diagnosticLocation);
489hasAssociatedProperty ? ErrorCode.WRN_UnassignedThisAutoPropertySupportedVersion : ErrorCode.WRN_UnassignedThisSupportedVersion,
496hasAssociatedProperty ? ErrorCode.ERR_UnassignedThisAutoPropertyUnsupportedVersion : ErrorCode.ERR_UnassignedThisUnsupportedVersion,
512Diagnostics.Add(ErrorCode.ERR_ParamUnassigned, location, parameter.Name);
546if (compatDiagnostics.AsEnumerable().Any(d => (ErrorCode)d.Code == ErrorCode.ERR_InsufficientStack))
575ErrorCode oldCode = (ErrorCode)diagnostic.Code;
576ErrorCode newCode = oldCode switch
579ErrorCode.ERR_UnassignedThisAutoPropertyUnsupportedVersion => ErrorCode.WRN_UnassignedThisAutoPropertyUnsupportedVersion,
580ErrorCode.ERR_UnassignedThisUnsupportedVersion => ErrorCode.WRN_UnassignedThisUnsupportedVersion,
581ErrorCode.ERR_ParamUnassigned => ErrorCode.WRN_ParamUnassigned,
582ErrorCode.ERR_UseDefViolationProperty => ErrorCode.WRN_UseDefViolationProperty,
583ErrorCode.ERR_UseDefViolationField => ErrorCode.WRN_UseDefViolationField,
584ErrorCode.ERR_UseDefViolationThisUnsupportedVersion => ErrorCode.WRN_UseDefViolationThisUnsupportedVersion,
585ErrorCode.ERR_UseDefViolationPropertyUnsupportedVersion => ErrorCode.WRN_UseDefViolationPropertyUnsupportedVersion,
586ErrorCode.ERR_UseDefViolationFieldUnsupportedVersion => ErrorCode.WRN_UseDefViolationFieldUnsupportedVersion,
587ErrorCode.ERR_UseDefViolationOut => ErrorCode.WRN_UseDefViolationOut,
588ErrorCode.ERR_UseDefViolation => ErrorCode.WRN_UseDefViolation,
594Debug.Assert(newCode != oldCode || oldCode == ErrorCode.ERR_InsufficientStack, oldCode.ToString());
672diagnostics.Add(ErrorCode.ERR_LocalCantBeFixedAndHoisted, location, captured.Name);
1198Diagnostics.Add(ErrorCode.ERR_UseDefViolationOut, node.Location, symbolName);
1203Diagnostics.Add(ErrorCode.ERR_UseDefViolation, node.Location, symbolName);
1245Diagnostics.Add(ErrorCode.WRN_UseDefViolationThisSupportedVersion, node.Location);
1250ErrorCode.ERR_UseDefViolationThisUnsupportedVersion,
1263Diagnostics.Add(hasAssociatedProperty ? ErrorCode.ERR_UseDefViolationProperty : ErrorCode.ERR_UseDefViolationField, node.Location, symbolName);
1273Diagnostics.Add(hasAssociatedProperty ? ErrorCode.ERR_UseDefViolationProperty : ErrorCode.ERR_UseDefViolationField, node.Location, symbolName);
1287hasAssociatedProperty ? ErrorCode.WRN_UseDefViolationPropertySupportedVersion : ErrorCode.WRN_UseDefViolationFieldSupportedVersion,
1294hasAssociatedProperty ? ErrorCode.ERR_UseDefViolationPropertyUnsupportedVersion : ErrorCode.ERR_UseDefViolationFieldUnsupportedVersion,
1825ErrorCode.WRN_UnreadRecordParameter :
1826ErrorCode.WRN_UnreadPrimaryConstructorParameter,
2163Diagnostics.Add(assigned && _writtenVariables.Contains(symbol) ? ErrorCode.WRN_UnreferencedVarAssg : ErrorCode.WRN_UnreferencedVar, symbol.Locations.FirstOrNone(), symbol.Name);
2182Diagnostics.Add(ErrorCode.WRN_UnreferencedLocalFunction, symbol.Locations.FirstOrNone(), symbol.Name);
2211Diagnostics.Add(ErrorCode.ERR_FixedLocalInLambda, new SourceLocation(node.Syntax), localSymbol);
FlowAnalysis\NullableWalker.cs (34)
753var info = new CSDiagnosticInfo(ErrorCode.WRN_UninitializedNonNullableField, new object[] { symbol.Kind.Localize(), symbol.Name }, ImmutableArray<Symbol>.Empty, additionalLocations: symbol.Locations);
765Diagnostics.Add(ErrorCode.WRN_MemberNotNull, syntaxOpt?.GetLocation() ?? methodMainNode.Syntax.GetLastToken().GetLocation(), member.Name);
836Diagnostics.Add(ErrorCode.WRN_MemberNotNullWhen, syntaxOpt?.GetLocation() ?? methodMainNode.Syntax.GetLastToken().GetLocation(), member.Name, sense ? "true" : "false");
1174Diagnostics.Add(ErrorCode.WRN_ParameterDisallowsNull, location, parameter.Name);
1201Diagnostics.Add(ErrorCode.WRN_ParameterConditionallyDisallowsNull, syntax.Location, parameter.Name, sense ? "true" : "false");
1260Diagnostics.Add(ErrorCode.WRN_ParameterNotNullIfNotNull, location, outputParam.Name, inputParam.Name);
1265Diagnostics.Add(ErrorCode.WRN_ReturnNotNullIfNotNull, location, inputParam.Name);
1279ReportDiagnostic(ErrorCode.WRN_ShouldNotReturn, syntaxOpt?.GetLocation() ?? methodMainNode.Syntax.GetLastToken().GetLocation());
2262ReportDiagnostic(assignmentKind == AssignmentKind.Return ? ErrorCode.WRN_NullReferenceReturn : ErrorCode.WRN_NullAsNonNullable, location);
2266ReportDiagnostic(ErrorCode.WRN_NullReferenceArgument, location,
2284ReportDiagnostic(assignmentKind == AssignmentKind.Return ? ErrorCode.WRN_NullReferenceReturn : ErrorCode.WRN_NullReferenceAssignment, location);
2440ReportDiagnostic(ErrorCode.WRN_NullabilityMismatchInAssignment, syntaxNode, sourceType, destinationType);
2445ReportDiagnostic(ErrorCode.WRN_NullabilityMismatchInAssignment, location, sourceType, destinationType);
2502ReportDiagnostic(ErrorCode.WRN_ConvertingNullableToNonNullable, location);
2505private void ReportDiagnostic(ErrorCode errorCode, SyntaxNode syntaxNode, params object[] arguments)
2510private void ReportDiagnostic(ErrorCode errorCode, Location location, params object[] arguments)
3833ReportDiagnostic(ErrorCode.WRN_NullReferenceInitializer, initializer.Syntax, symbol);
6648ReportDiagnostic(ErrorCode.WRN_DisallowNullAttributeForbidsMaybeNullAssignment, location);
7793ReportDiagnostic(ErrorCode.WRN_NullabilityMismatchInReturnTypeOfTargetDelegate, arg.location,
7800ReportDiagnostic(ErrorCode.WRN_NullabilityMismatchInParameterTypeOfTargetDelegate, arg.location,
7857ReportDiagnostic(ErrorCode.WRN_NullabilityMismatchInReturnTypeOfTargetDelegate, location,
7867ReportDiagnostic(ErrorCode.WRN_NullabilityMismatchInParameterTypeOfTargetDelegate, location,
7904/// If <see langword="true"/>, indicates that the "non-safety" diagnostic <see cref="ErrorCode.WRN_ConvertingNullableToNonNullable"/>
8057ReportDiagnostic(ErrorCode.WRN_UnboxPossibleNull, diagnosticLocationOpt);
8151ReportDiagnostic(ErrorCode.WRN_NullableValueTypeMayBeNull, diagnosticLocationOpt);
9742ReportDiagnostic(ErrorCode.WRN_NullabilityMismatchInArgument,
9759ReportDiagnostic(forOutput ? ErrorCode.WRN_NullabilityMismatchInArgumentForOutput : ErrorCode.WRN_NullabilityMismatchInArgument,
10101ReportDiagnostic(ErrorCode.WRN_NullReferenceReceiver, expr.Syntax.GetLocation());
10911ReportDiagnostic(isValueType ? ErrorCode.WRN_NullableValueTypeMayBeNull : ErrorCode.WRN_NullReferenceReceiver, syntax);
11065ReportDiagnostic(ErrorCode.WRN_ThrowPossibleNull, expr.Syntax);
Generated\BoundNodes.xml.Generated.cs (3)
1953public BoundUnconvertedConditionalOperator(SyntaxNode syntax, BoundExpression condition, BoundExpression consequence, BoundExpression alternative, ConstantValue? constantValueOpt, ErrorCode noCommonTypeError, bool hasErrors = false)
1973public ErrorCode NoCommonTypeError { get; }
1978public BoundUnconvertedConditionalOperator Update(BoundExpression condition, BoundExpression consequence, BoundExpression alternative, ConstantValue? constantValueOpt, ErrorCode noCommonTypeError)
Lowering\AsyncRewriter\AsyncMethodBuilderMemberCollection.cs (6)
356F.Diagnostics.Add(ErrorCode.ERR_WrongArityAsyncReturn, F.Syntax.Location, builderType);
367F.Diagnostics.Add(ErrorCode.ERR_BadAsyncReturn, F.Syntax.Location);
461new CSDiagnosticInfo(ErrorCode.ERR_MissingPredefinedMember, (customBuilder ? (object)builderType : descriptor.DeclaringTypeMetadataName), descriptor.Name),
494F.Diagnostics.Add(ErrorCode.ERR_MissingPredefinedMember, F.Syntax.Location, builderType, methodName);
519new CSDiagnosticInfo(ErrorCode.ERR_BadAsyncMethodBuilderTaskProperty, builderType, returnType, property.Type),
529new CSDiagnosticInfo(ErrorCode.ERR_MissingPredefinedMember, builderType, propertyName),
Lowering\DiagnosticsPass_ExpressionTrees.cs (76)
58private void Error(ErrorCode code, BoundNode node, params object[] args)
72Error(ErrorCode.ERR_ExpressionTreeContainsPointerOp, node);
82Error(ErrorCode.ERR_ExpressionTreeContainsMultiDimensionalArrayInitializer, node);
94Error(ErrorCode.ERR_ExpressionTreeContainsPatternImplicitIndexer, node);
104Error(ErrorCode.ERR_ExpressionTreeContainsPatternImplicitIndexer, node);
114Error(ErrorCode.ERR_ExpressionTreeContainsFromEndIndexExpression, node);
124Error(ErrorCode.ERR_ExpressionTreeContainsRangeExpression, node);
134Error(ErrorCode.ERR_ExpressionTreeContainsPointerOp, node);
164Error(ErrorCode.ERR_ExpressionTreeContainsBaseAccess, node);
186var diagnostic = _staticLocalOrAnonymousFunction.MethodKind == MethodKind.LocalFunction
187? ErrorCode.ERR_StaticLocalFunctionCannotCaptureThis
188: ErrorCode.ERR_StaticAnonymousFunctionCannotCaptureThis;
201var diagnostic = _staticLocalOrAnonymousFunction.MethodKind == MethodKind.LocalFunction
202? ErrorCode.ERR_StaticLocalFunctionCannotCaptureVariable
203: ErrorCode.ERR_StaticAnonymousFunctionCannotCaptureVariable;
222Error(ErrorCode.ERR_ExpressionTreeContainsSwitchExpression, node);
244Error(ErrorCode.ERR_ExpressionTreeContainsAssignment, node);
254Error(ErrorCode.ERR_ExpressionTreeContainsDynamicOperation, node);
277Error(ErrorCode.ERR_ExpressionTreeContainsAssignment, node);
314Error(ErrorCode.ERR_PartialMethodInExpressionTree, node);
318Error(ErrorCode.ERR_ExpressionTreeContainsIndexedProperty, node);
322Error(ErrorCode.ERR_ExpressionTreeContainsOptionalArgument, node);
326Error(ErrorCode.ERR_ExpressionTreeContainsNamedArgument, node);
330Error(ErrorCode.ERR_ComRefCallInExpressionTree, node);
334Error(ErrorCode.ERR_ExpressionTreeContainsLocalFunction, node);
338Error(ErrorCode.ERR_RefReturningCallInExpressionTree, node);
342Error(ErrorCode.ERR_ExpressionTreeContainsAbstractStaticMemberAccess, node);
369Error(ErrorCode.ERR_ExpressionTreeCantContainRefStruct, node, type.Name);
378Error(ErrorCode.ERR_FeatureNotValidInExpressionTree, node, "__reftype");
388Error(ErrorCode.ERR_FeatureNotValidInExpressionTree, node, "__refvalue");
398Error(ErrorCode.ERR_FeatureNotValidInExpressionTree, node, "__makeref");
408Error(ErrorCode.ERR_VarArgsInExpressionTree, node);
418Error(ErrorCode.ERR_NullPropagatingOpInExpressionTree, node);
428Error(ErrorCode.ERR_DictionaryInitializerInExpressionTree, node);
454Error(ErrorCode.ERR_ExpressionTreeContainsOutVariable, local);
462Error(ErrorCode.ERR_ExpressionTreeContainsDiscard, argument);
470Error(ErrorCode.ERR_ExtensionCollectionElementInitializerInExpressionTree, node);
499Error(ErrorCode.ERR_RefReturningCallInExpressionTree, node);
511Error(ErrorCode.ERR_ExpressionTreeContainsAbstractStaticMemberAccess, node);
526Error(ErrorCode.ERR_LambdaWithAttributesToExpressionTree, node);
534_diagnostics.Add(ErrorCode.ERR_ByRefParameterInExpressionTree, p.Locations[0]);
538_diagnostics.Add(ErrorCode.ERR_ExpressionTreeCantContainRefStruct, p.Locations[0], p.Type.Name);
543_diagnostics.Add(ErrorCode.ERR_LambdaWithAttributesToExpressionTree, p.Locations[0]);
555Error(ErrorCode.ERR_BadAsyncExpressionTree, node);
559Error(ErrorCode.ERR_StatementLambdaToExpressionTree, node);
563Error(ErrorCode.ERR_BadRefReturnExpressionTree, node);
573Error(ErrorCode.ERR_BadAsyncExpressionTree, node);
577Error(ErrorCode.ERR_StatementLambdaToExpressionTree, node);
581Error(ErrorCode.ERR_BadRefReturnExpressionTree, node);
587Error(ErrorCode.ERR_ExpressionTreeContainsAnonymousMethod, node);
647Error(ErrorCode.ERR_ExpressionTreeContainsAbstractStaticMemberAccess, node);
658Error(ErrorCode.ERR_ExpressionTreeContainsDynamicOperation, node);
666Error(ErrorCode.ERR_ExpressionTreeContainsDynamicOperation, node);
678Error(ErrorCode.ERR_ExpressionTreeContainsAbstractStaticMemberAccess, node);
699Error(ErrorCode.ERR_ExpressionTreeContainsAssignment, node);
743Error(ErrorCode.ERR_ExpressionTreeContainsDynamicOperation, node);
753Error(ErrorCode.ERR_ExpressionTreeContainsTupleConversion, node);
760Error(ErrorCode.ERR_ExpressionTreeContainsInterpolatedStringHandlerConversion, node);
768Error(ErrorCode.ERR_ExpressionTreeContainsAbstractStaticMemberAccess, node);
810Error(ErrorCode.ERR_ExpressionTreeContainsLocalFunction, node);
814Error(ErrorCode.ERR_AddressOfMethodGroupInExpressionTree, node);
818Error(ErrorCode.ERR_ExpressionTreeContainsAbstractStaticMemberAccess, node);
842Error(ErrorCode.ERR_ExpressionTreeContainsBadCoalesce, node.LeftOperand);
852Error(ErrorCode.ERR_ExpressionTreeCantContainNullCoalescingAssignment, node);
862Error(ErrorCode.ERR_ExpressionTreeContainsDynamicOperation, node);
878Error(ErrorCode.ERR_ExpressionTreeContainsDynamicOperation, node);
889Error(ErrorCode.ERR_ExpressionTreeContainsDynamicOperation, node);
899Error(ErrorCode.ERR_ExpressionTreeContainsDynamicOperation, node);
909Error(ErrorCode.ERR_ExpressionTreeContainsDynamicOperation, node);
919Error(ErrorCode.ERR_ExpressionTreeContainsIsMatch, node);
929Error(ErrorCode.ERR_ExpressionTreeContainsTupleLiteral, node);
939Error(ErrorCode.ERR_ExpressionTreeContainsTupleLiteral, node);
949Error(ErrorCode.ERR_ExpressionTreeContainsTupleBinOp, node);
959Error(ErrorCode.ERR_ExpressionTreeContainsThrowExpression, node);
969Error(ErrorCode.ERR_ExpressionTreeContainsWithExpression, node);
979Error(ErrorCode.ERR_ExpressionTreeContainsPointerOp, node);
Lowering\DiagnosticsPass_Warnings.cs (27)
63Error(ErrorCode.WRN_VolatileByRef, fieldAccess, fieldSymbol);
68Error(ErrorCode.WRN_ByRefNonAgileField, fieldAccess, fieldSymbol);
91Error(ErrorCode.WRN_CallOnNonAgileField, fieldAccess, fieldSymbol);
258Error(ErrorCode.ERR_FeatureNotValidInExpressionTree, node, method);
262Error(ErrorCode.ERR_ExpressionTreeContainsAbstractStaticMemberAccess, node);
280Error(ErrorCode.ERR_FeatureNotValidInExpressionTree, node, ">>>");
300Error(ErrorCode.ERR_ExpressionTreeContainsAssignment, node);
333_diagnostics.Add(ErrorCode.WRN_BadRefCompareLeft, node.Syntax.Location, t);
338_diagnostics.Add(ErrorCode.WRN_BadRefCompareRight, node.Syntax.Location, t);
388Error(ErrorCode.WRN_ComparisonToSelf, node);
454Error(ErrorCode.WRN_VacuousIntegralComp, tree, conversion.Operand.Type);
569Error(ErrorCode.WRN_BitwiseOrSignExtend, node);
729Error(ErrorCode.WRN_AlwaysNull, node, node.Type);
745Error(ErrorCode.WRN_AlwaysNull, node, node.Type);
770Error(ErrorCode.WRN_NubExprIsConstBool, node, always, node.Left.Type.GetNullableUnderlyingType(), node.Left.Type);
774Error(ErrorCode.WRN_NubExprIsConstBool, node, always, node.Right.Type.GetNullableUnderlyingType(), node.Right.Type);
800Error(ErrorCode.WRN_CmpAlwaysFalse, node, GetTypeForLiftedComparisonWarning(node.Right));
804Error(ErrorCode.WRN_CmpAlwaysFalse, node, GetTypeForLiftedComparisonWarning(node.Left));
818Error(node.OperatorKind.IsUserDefined() ? ErrorCode.WRN_NubExprIsConstBool2 : ErrorCode.WRN_NubExprIsConstBool, node, always, node.Left.Type.GetNullableUnderlyingType(), GetTypeForLiftedComparisonWarning(node.Right));
822Error(node.OperatorKind.IsUserDefined() ? ErrorCode.WRN_NubExprIsConstBool2 : ErrorCode.WRN_NubExprIsConstBool, node, always, node.Right.Type.GetNullableUnderlyingType(), GetTypeForLiftedComparisonWarning(node.Left));
830Error(ErrorCode.WRN_AlwaysNull, node, node.Type);
836Error(ErrorCode.WRN_AlwaysNull, node, node.Type);
847Error(ErrorCode.WRN_AlwaysNull, node, node.Type);
881Error(ErrorCode.WRN_AssignmentToSelf, node);
925Error(ErrorCode.WRN_AssignmentToSelf, leftArgument);
Parser\AbstractLexer.cs (8)
66protected void AddError(int position, int width, ErrorCode code)
71protected void AddError(int position, int width, ErrorCode code, params object[] args)
81protected void AddError(ErrorCode code)
86protected void AddError(ErrorCode code, params object[] args)
114protected SyntaxDiagnosticInfo MakeError(int position, int width, ErrorCode code)
120protected SyntaxDiagnosticInfo MakeError(int position, int width, ErrorCode code, params object[] args)
137protected static SyntaxDiagnosticInfo MakeError(ErrorCode code)
142protected static SyntaxDiagnosticInfo MakeError(ErrorCode code, params object[] args)
Parser\DirectiveParser.cs (51)
38hash = this.AddError(hash, ErrorCode.ERR_BadDirectivePlacement);
125id = this.AddError(id, ErrorCode.ERR_PPDirectiveExpected);
129hash = this.AddError(hash, ErrorCode.ERR_PPDirectiveExpected);
166return this.AddError(SyntaxFactory.BadDirectiveTrivia(hash, keyword, eod, isActive), ErrorCode.ERR_EndRegionDirectiveExpected);
170return this.AddError(SyntaxFactory.BadDirectiveTrivia(hash, keyword, eod, isActive), ErrorCode.ERR_EndifDirectiveExpected);
174return this.AddError(SyntaxFactory.BadDirectiveTrivia(hash, keyword, eod, isActive), ErrorCode.ERR_UnexpectedDirective);
189return this.AddError(SyntaxFactory.BadDirectiveTrivia(hash, keyword, eod, isActive), ErrorCode.ERR_EndRegionDirectiveExpected);
193return this.AddError(SyntaxFactory.BadDirectiveTrivia(hash, keyword, eod, isActive), ErrorCode.ERR_EndifDirectiveExpected);
197return this.AddError(SyntaxFactory.BadDirectiveTrivia(hash, keyword, eod, isActive), ErrorCode.ERR_UnexpectedDirective);
212return this.AddError(SyntaxFactory.BadDirectiveTrivia(hash, keyword, eod, isActive), ErrorCode.ERR_EndRegionDirectiveExpected);
216return this.AddError(SyntaxFactory.BadDirectiveTrivia(hash, keyword, eod, isActive), ErrorCode.ERR_UnexpectedDirective);
234return this.AddError(SyntaxFactory.BadDirectiveTrivia(hash, keyword, eod, isActive), ErrorCode.ERR_EndifDirectiveExpected);
238return this.AddError(SyntaxFactory.BadDirectiveTrivia(hash, keyword, eod, isActive), ErrorCode.ERR_UnexpectedDirective);
246keyword = this.AddError(keyword, ErrorCode.ERR_PPDefFollowsToken);
249var name = this.EatToken(SyntaxKind.IdentifierToken, ErrorCode.ERR_IdentifierExpected);
324eod = this.AddError(eod, triviaOffset, triviaWidth, isError ? ErrorCode.ERR_ErrorDirective : ErrorCode.WRN_WarningDirective, errorText);
336eod = this.AddError(eod, triviaOffset, triviaWidth, ErrorCode.ERR_CompilerAndLanguageVersion, version,
346ErrorCode error = this.Options.LanguageVersion.GetErrorCode();
378line = this.EatToken(SyntaxKind.NumericLiteralToken, ErrorCode.ERR_InvalidLineNumber, reportError: isActive);
384line = this.AddError(line, ErrorCode.ERR_InvalidLineNumber);
388line = this.AddError(line, ErrorCode.WRN_TooManyLinesForDebugger);
414start = this.AddError(start, ErrorCode.ERR_LineSpanDirectiveRequiresSpace);
424end = this.AddError(end, ErrorCode.ERR_LineSpanDirectiveEndLessThanStart);
433characterOffset = this.AddError(characterOffset, ErrorCode.ERR_LineSpanDirectiveRequiresSpace);
436var file = EatToken(SyntaxKind.StringLiteralToken, ErrorCode.ERR_MissingPPFile, reportError: reportError);
441file = this.AddError(file, ErrorCode.ERR_LineSpanDirectiveRequiresSpace);
475var token = this.EatToken(SyntaxKind.NumericLiteralToken, ErrorCode.ERR_LineSpanDirectiveInvalidValue, reportError: reportError);
486token = this.AddError(token, ErrorCode.ERR_LineSpanDirectiveInvalidValue);
499keyword = this.AddError(keyword, ErrorCode.ERR_ReferenceDirectiveOnlyAllowedInScripts);
503keyword = this.AddError(keyword, ErrorCode.ERR_PPReferenceFollowsToken);
507SyntaxToken file = this.EatToken(SyntaxKind.StringLiteralToken, ErrorCode.ERR_ExpectedPPFile, reportError: isActive);
519keyword = this.AddError(keyword, ErrorCode.ERR_LoadDirectiveOnlyAllowedInScripts);
523keyword = this.AddError(keyword, ErrorCode.ERR_PPLoadFollowsToken);
527SyntaxToken file = this.EatToken(SyntaxKind.StringLiteralToken, ErrorCode.ERR_ExpectedPPFile, reportError: isActive);
545_ => EatToken(SyntaxKind.DisableKeyword, ErrorCode.ERR_NullableDirectiveQualifierExpected, reportError: isActive)
554_ => EatToken(SyntaxKind.WarningsKeyword, ErrorCode.ERR_NullableDirectiveTargetExpected, reportError: !setting.IsMissing && isActive)
609id = this.EatToken(SyntaxKind.NumericLiteralToken, ErrorCode.WRN_IdentifierOrNumericLiteralExpected, reportError: isActive);
629style = this.EatToken(SyntaxKind.DisableKeyword, ErrorCode.WRN_IllegalPPWarning, reportError: isActive);
637var file = this.EatToken(SyntaxKind.StringLiteralToken, ErrorCode.WRN_IllegalPPChecksum, reportError: isActive);
638var guid = this.EatToken(SyntaxKind.StringLiteralToken, ErrorCode.WRN_IllegalPPChecksum, reportError: isActive && !file.IsMissing);
644guid = this.AddError(guid, ErrorCode.WRN_IllegalPPChecksum);
648var bytes = this.EatToken(SyntaxKind.StringLiteralToken, ErrorCode.WRN_IllegalPPChecksum, reportError: isActive && !guid.IsMissing);
653bytes = this.AddError(bytes, ErrorCode.WRN_IllegalPPChecksum);
661bytes = this.AddError(bytes, ErrorCode.WRN_IllegalPPChecksum);
674var warning = this.EatToken(SyntaxKind.WarningKeyword, ErrorCode.WRN_IllegalPragma, reportError: isActive);
704var errorCode = ErrorCode.ERR_EndOfPPLineExpected;
707errorCode = ErrorCode.WRN_EndOfPPLineExpected;
711errorCode = ErrorCode.ERR_MissingPPFile;
810return SyntaxFactory.IdentifierName(this.EatToken(SyntaxKind.IdentifierToken, ErrorCode.ERR_InvalidPreprocExpr));
Parser\DocumentationCommentParser.cs (12)
801SyntaxDiagnosticInfo crefInfo = new SyntaxDiagnosticInfo(rawInfo.Offset, rawInfo.Width, ErrorCode.WRN_ErrorOverride, rawInfo, rawInfo.Code);
933result = this.AddError(result, ErrorCode.WRN_BadXMLRefSyntax, result.ToFullString());
1012SyntaxDiagnosticInfo rawInfo = new SyntaxDiagnosticInfo(offset, width, ErrorCode.ERR_OvlOperatorExpected);
1013SyntaxDiagnosticInfo crefInfo = new SyntaxDiagnosticInfo(offset, width, ErrorCode.WRN_ErrorOverride, rawInfo, rawInfo.Code);
1059SyntaxDiagnosticInfo rawInfo = new SyntaxDiagnosticInfo(offset, width, ErrorCode.ERR_OvlOperatorExpected);
1060SyntaxDiagnosticInfo crefInfo = new SyntaxDiagnosticInfo(offset, width, ErrorCode.WRN_ErrorOverride, rawInfo, rawInfo.Code);
1102SyntaxDiagnosticInfo rawInfo = new SyntaxDiagnosticInfo(offset, width, ErrorCode.ERR_OvlOperatorExpected);
1103SyntaxDiagnosticInfo crefInfo = new SyntaxDiagnosticInfo(offset, width, ErrorCode.WRN_ErrorOverride, rawInfo, rawInfo.Code);
1132var misplacedToken = this.AddError(this.EatToken(), ErrorCode.ERR_MisplacedUnchecked);
1294typeSyntax = this.AddError(typeSyntax, ErrorCode.WRN_ErrorOverride,
1295new SyntaxDiagnosticInfo(ErrorCode.ERR_TypeParamMustBeIdentifier), $"{(int)ErrorCode.ERR_TypeParamMustBeIdentifier:d4}");
Parser\LanguageParser.cs (139)
231return AddError(node, position, 0, ErrorCode.ERR_InsufficientStack);
254namespaceToken = this.AddError(namespaceToken, ErrorCode.ERR_NamespaceNotAllowedInScript);
460IsScript ? ErrorCode.ERR_GlobalDefinitionOrStatementExpected : ErrorCode.ERR_EOFExpected);
490@extern = this.AddErrorToFirstToken(@extern, ErrorCode.ERR_ExternAfterElements);
540attribute = this.AddError(attribute, attribute.Target.Identifier, ErrorCode.ERR_GlobalAttributesNotFirst);
567IsScript ? ErrorCode.ERR_GlobalDefinitionOrStatementExpected : ErrorCode.ERR_EOFExpected);
616memberOrStatement = this.AddError(memberOrStatement, ErrorCode.ERR_TopLevelStatementAfterNamespaceOrType);
661@using = this.AddError(@using, ErrorCode.ERR_UsingAfterElements);
1600this.AddError(ConvertToKeyword(this.EatToken()), ErrorCode.ERR_MisplacedRecord),
1721token = this.AddError(token, ErrorCode.ERR_InvalidMemberDecl, token.Text);
1854? this.AddError(this.CreateMissingIdentifierName(), ErrorCode.ERR_IdentifierExpected)
1864bounds.Add(_syntaxFactory.TypeConstraint(this.AddError(this.CreateMissingIdentifierName(), ErrorCode.ERR_TypeExpected)));
1885bounds.Add(_syntaxFactory.TypeConstraint(this.AddError(this.CreateMissingIdentifierName(), ErrorCode.ERR_TypeExpected)));
1948? this.AddError(this.EatToken(), ErrorCode.ERR_UnexpectedToken, SyntaxFacts.GetText(SyntaxKind.QuestionToken))
1962this.AddError(this.CreateMissingIdentifierName(), ErrorCode.ERR_NoEnumConstraint),
1971this.AddError(this.CreateMissingIdentifierName(), ErrorCode.ERR_NoDelegateConstraint),
2246this.AddError(SyntaxFactory.MissingToken(SyntaxKind.VoidKeyword), ErrorCode.ERR_MemberNeedsType));
2594ErrorCode.ERR_BadModifierLocation,
2626result = this.AddErrorToLastToken(incompleteMember, ErrorCode.ERR_NamespaceUnexpected);
2635ErrorCode.ERR_InvalidMemberDecl,
3009token = this.EatToken(SyntaxKind.ThisKeyword, ErrorCode.ERR_ThisOrBaseExpected);
3078semicolon = this.EatTokenWithPrejudice(ErrorCode.ERR_UnexpectedSemicolon);
3158initializer = this.AddErrorToFirstToken(initializer, ErrorCode.ERR_UnexpectedToken, colonToken.Text);
3319type = this.AddError(this.CreateMissingIdentifierName(), ErrorCode.ERR_IdentifierExpected);
3416separator = this.AddError(separator, ErrorCode.ERR_AliasQualAsExpression);
3449var misplacedToken = this.AddError(this.EatToken(), ErrorCode.ERR_MisplacedUnchecked);
3489SyntaxDiagnosticInfo diagInfo = MakeError(opTokenErrorOffset, opTokenErrorWidth, ErrorCode.ERR_BadOperatorSyntax, SyntaxFacts.GetText(SyntaxKind.PlusToken));
3495type = this.AddError(type, ErrorCode.ERR_BadOperatorSyntax, SyntaxFacts.GetText(SyntaxKind.PlusToken));
3537SyntaxDiagnosticInfo diagInfo = MakeError(opTokenErrorOffset, opTokenErrorWidth, ErrorCode.ERR_OvlUnaryOperatorExpected);
3545SyntaxDiagnosticInfo diagInfo = MakeError(opTokenErrorOffset, opTokenErrorWidth, ErrorCode.ERR_OvlBinaryOperatorExpected);
3553SyntaxDiagnosticInfo diagInfo = MakeError(opTokenErrorOffset, opTokenErrorWidth, ErrorCode.ERR_OvlOperatorExpected);
3558opToken = this.AddError(opToken, ErrorCode.ERR_BadBinOpArgs, SyntaxFacts.GetText(opKind));
3562opToken = this.AddError(opToken, ErrorCode.ERR_BadUnOpArgs, SyntaxFacts.GetText(opKind));
3566opToken = this.AddError(opToken, ErrorCode.ERR_OvlOperatorExpected);
3611thisKeyword = this.AddError(thisKeyword, ErrorCode.ERR_UnexpectedGenericName);
3631semicolon = this.EatTokenWithPrejudice(ErrorCode.ERR_UnexpectedSemicolon);
3669identifier = this.AddError(identifier, ErrorCode.ERR_UnexpectedGenericName);
3708semicolon = this.EatTokenWithPrejudice(ErrorCode.ERR_UnexpectedSemicolon);
3745isEvent ? ErrorCode.ERR_AddOrRemoveExpected : ErrorCode.ERR_GetOrSetExpected) == PostSkipAction.Abort)
3778private PostSkipAction SkipBadAccessorListTokens(ref SyntaxToken openBrace, SyntaxListBuilder<AccessorDeclarationSyntax> list, ErrorCode error)
3878ErrorCode error)
3924ErrorCode error,
3974ErrorCode errorCode,
4010isEvent ? ErrorCode.ERR_AddOrRemoveExpected : ErrorCode.ERR_GetOrSetExpected);
4026isEvent ? ErrorCode.ERR_AddOrRemoveExpected : ErrorCode.ERR_GetOrSetExpected);
4097? ErrorCode.ERR_SemiOrLBraceOrArrowExpected
4098: ErrorCode.ERR_SemiOrLBraceExpected);
4311identifier = this.AddError(CreateMissingIdentifierToken(), ErrorCode.ERR_IdentifierExpected);
4322this.AddError(this.EatToken(), ErrorCode.ERR_BadArraySyntax),
4358this.AddError(SyntaxFactory.Token(exclamationEquals.GetLeadingTrivia(), SyntaxKind.ExclamationToken, "!", "!", trailing: null), ErrorCode.ERR_ParameterNullCheckingNotSupported));
4367identifier = AddTrailingSkippedSyntax(identifier, this.AddError(this.EatToken(), ErrorCode.ERR_ParameterNullCheckingNotSupported));
4564identifier = this.AddError(identifier, ErrorCode.ERR_IdentifierExpected);
4570identifier = this.AddError(identifier, ErrorCode.ERR_UnexpectedGenericName);
4606semi = this.AddError(semi, ErrorCode.ERR_UnexpectedSemicolon);
4675eventToken = this.AddError(eventToken, ErrorCode.ERR_ExplicitEventFieldImpl); // Better error message for confusing event situation.
4957missingIdentifier = this.AddError(missingIdentifier, offset, width, ErrorCode.ERR_IdentifierExpected);
4990name = this.AddError(name, ErrorCode.ERR_MultiTypeInDeclaration);
5040argumentList = this.AddError(argumentList, ErrorCode.ERR_BadVarDecl);
5053close = this.AddError(close, ErrorCode.ERR_ValueExpected);
5065expression = this.AddError(expression, ErrorCode.ERR_ArraySizeInDeclaration);
5079argumentList = this.AddError(argumentList, ErrorCode.ERR_CStyleArray);
5092name = this.AddError(name, ErrorCode.ERR_ConstValueRequired); // Error here for missing constant initializers
5099name = this.AddError(name, ErrorCode.ERR_FixedDimsRequired);
5219name = this.AddError(name, ErrorCode.ERR_UnexpectedGenericName);
5306? this.ParseIdentifierName(ErrorCode.ERR_ConstantExpected)
5383private IdentifierNameSyntax ParseIdentifierName(ErrorCode code = ErrorCode.ERR_IdentifierExpected)
5397private SyntaxToken ParseIdentifierToken(ErrorCode code = ErrorCode.ERR_IdentifierExpected)
5411result = this.AddError(result, ErrorCode.ERR_InvalidExprTerm, this.CurrentToken.Text);
5419identifierToken = this.AddError(identifierToken, ErrorCode.ERR_BadAwaitAsIdentifier);
5509this.AddError(CreateMissingIdentifierToken(), ErrorCode.ERR_IdentifierExpected));
5933? this.AddError(this.EatToken(), ErrorCode.ERR_IllegalVarianceSyntax)
5974result = this.AddError(result, ErrorCode.ERR_TypeExpected);
6051separator = this.AddError(separator, ErrorCode.ERR_AliasQualAsExpression);
6105AddError(separator, ErrorCode.ERR_ExplicitEventFieldImpl));
6170separator = this.AddError(separator, ErrorCode.ERR_UnexpectedAliasedName);
6240separator = this.AddError(separator, ErrorCode.ERR_AliasQualAsExpression);
6326separator = this.AddError(separator, ErrorCode.ERR_UnexpectedAliasedName);
6360var missingName = this.AddError(this.CreateMissingIdentifierName(), ErrorCode.ERR_IdentifierExpected);
7076list[i] = this.AddError(this.CreateMissingIdentifierName(), offset, width, ErrorCode.ERR_ValueExpected);
7111var missing = this.AddError(this.CreateMissingIdentifierName(), ErrorCode.ERR_TupleTooFewElements);
7144token = this.AddError(token, mode == ParseTypeMode.Parameter ? ErrorCode.ERR_NoVoidParameter : ErrorCode.ERR_NoVoidHere);
7167mode == ParseTypeMode.NewExpression ? ErrorCode.ERR_BadNewExpr : ErrorCode.ERR_TypeExpected);
7321unmanagedCallingConventions = AddError(unmanagedCallingConventions, ErrorCode.ERR_CannotSpecifyManagedWithUnmanagedSpecifiers);
8074? ErrorCode.ERR_SemiOrLBraceOrArrowExpected
8075: ErrorCode.ERR_SemiOrLBraceExpected)
8309!semicolonToken.GetDiagnostics().Contains(diagnosticInfo => (ErrorCode)diagnosticInfo.Code == ErrorCode.ERR_SemicolonExpected))
8311semicolonToken = this.AddError(semicolonToken, ErrorCode.ERR_SemicolonExpected);
8384tryBlock = this.AddErrorToLastToken(tryBlock, ErrorCode.ERR_ExpectedEndTry);
8734skippedForToken = this.AddError(skippedForToken, ErrorCode.ERR_SyntaxError, SyntaxFacts.GetText(SyntaxKind.ForEachKeyword));
8745var @in = this.EatToken(SyntaxKind.InKeyword, ErrorCode.ERR_InExpected);
8748@in = this.AddError(@in, ErrorCode.ERR_BadForeachDecl);
8988this.EatToken(SyntaxKind.IfKeyword, ErrorCode.ERR_ElseCannotStartStatement),
9047returnOrBreak = this.AddError(returnOrBreak, ErrorCode.ERR_EmptyYield);
9125expression = this.AddError(expression, ErrorCode.ERR_SwitchGoverningExpressionRequiresParens);
9159ParseIdentifierName(ErrorCode.ERR_ConstantExpected),
9171node = this.AddError(node, ErrorCode.ERR_DiscardPatternInSwitchStatement);
9460mods[i] = this.AddError(mod, ErrorCode.ERR_BadMemberFlag, mod.Text);
9630type = this.AddError(type, ErrorCode.ERR_NoVoidHere);
9670mod = this.AddError(mod, ErrorCode.ERR_BadMemberFlag, mod.Text);
9675mod = this.AddError(mod, ErrorCode.ERR_TypeExpected);
9812modifier = this.AddError(modifier, ErrorCode.ERR_BadMemberFlag, modifier.Text);
10304return this.AddError(this.CreateMissingIdentifierName(), ErrorCode.ERR_InvalidExprTerm, SyntaxFacts.GetText(tk));
10351skipped = this.AddError(skipped, ErrorCode.ERR_InvalidExprTerm, this.CurrentToken.Text);
10359this.AddError(result, ErrorCode.ERR_InvalidExprTerm, SyntaxFacts.GetText(tk));
10479ErrorCode errorCode = leftOperand.Kind == SyntaxKind.IsPatternExpression ? ErrorCode.ERR_UnexpectedToken : ErrorCode.WRN_PrecedenceInversion;
10584leftOperand = this.AddError(leftOperand, ErrorCode.ERR_ConditionalInInterpolation);
10668return this.AddError(this.CreateMissingIdentifierName(), ErrorCode.ERR_InvalidExprTerm, this.CurrentToken.Text);
10693return this.AddError(this.CreateMissingIdentifierName(), ErrorCode.ERR_InvalidExprTerm, this.CurrentToken.Text);
10750return this.AddError(_syntaxFactory.RefExpression(refKeyword, this.ParseExpressionCore()), ErrorCode.ERR_InvalidExprTerm, SyntaxFacts.GetText(tk));
10764expr = this.AddError(expr, ErrorCode.ERR_InvalidExprTerm, SyntaxFacts.GetText(tk));
10775expr = this.AddError(expr, ErrorCode.ERR_ExpressionExpected);
10779expr = this.AddError(expr, ErrorCode.ERR_InvalidExprTerm, SyntaxFacts.GetText(tk));
10895this.ConvertToMissingWithTrailingTrivia(this.AddError(this.EatToken(), ErrorCode.ERR_UnexpectedAliasedName), SyntaxKind.DotToken),
10926this.AddError(this.CreateMissingIdentifierName(), ErrorCode.ERR_IdentifierExpected));
11179expression = this.ParseIdentifierName(ErrorCode.ERR_ValueExpected);
11183expression = this.ParseIdentifierName(ErrorCode.ERR_MissingArgument);
11533this.AddError(this.CreateMissingIdentifierName(), ErrorCode.ERR_TupleTooFewElements)));
11956this.EatToken(SyntaxKind.OpenParenToken, ErrorCode.ERR_BadNewExpr, reportError: type?.ContainsDiagnostics == false),
12165var size = this.AddError(this.ParseExpressionCore(), ErrorCode.ERR_InvalidArray);
12239var size = this.AddError(this.ParseExpressionCore(), ErrorCode.ERR_InvalidStackAllocArray);
12245var comma = this.AddError(this.EatToken(), ErrorCode.ERR_InvalidStackAllocArray);
12706fc = this.AddError(fc, ErrorCode.WRN_PrecedenceInversion, SyntaxFacts.GetText(SyntaxKind.FromKeyword));
12750this.EatToken(SyntaxKind.SelectKeyword, ErrorCode.ERR_ExpectedSelectOrGroup),
12806onKeyword: this.EatContextualToken(SyntaxKind.OnKeyword, ErrorCode.ERR_ExpectedContextualKeywordOn),
12808equalsKeyword: this.EatContextualToken(SyntaxKind.EqualsKeyword, ErrorCode.ERR_ExpectedContextualKeywordEquals),
12910this.EatContextualToken(SyntaxKind.ByKeyword, ErrorCode.ERR_ExpectedContextualKeywordBy),
13184node = this.AddError(node, ErrorCode.ERR_UnexpectedToken, trailingTrash[0].ToString());
Parser\Lexer.cs (25)
477this.AddError(ErrorCode.ERR_TripleDotNotAllowed);
776this.AddError(ErrorCode.ERR_ExpectedVerbatimLiteral);
887this.AddError(ErrorCode.ERR_EndifDirectiveExpected);
892this.AddError(ErrorCode.ERR_EndRegionDirectiveExpected);
928this.AddError(ErrorCode.ERR_UnexpectedCharacter, info.Text);
1125this.AddError(MakeError(ErrorCode.ERR_LegacyObjectIdSyntax));
1162this.AddError(MakeError(ErrorCode.ERR_InvalidReal));
1233this.AddError(MakeError(start, TextWindow.Position - start, ErrorCode.ERR_InvalidNumber));
1265this.AddError(MakeError(ErrorCode.ERR_InvalidNumber));
1393this.AddError(MakeError(ErrorCode.ERR_IntOverflow));
1407this.AddError(MakeError(ErrorCode.ERR_IntOverflow));
1413this.AddError(MakeError(ErrorCode.ERR_IntOverflow));
1425this.AddError(MakeError(ErrorCode.ERR_FloatOverflow, "double"));
1437this.AddError(MakeError(ErrorCode.ERR_FloatOverflow, "float"));
1472this.AddError(this.MakeError(start, end - start, ErrorCode.ERR_FloatOverflow, "decimal"));
1945this.AddError(start, atCount, ErrorCode.ERR_IllegalAtSequence);
2352this.AddError(ErrorCode.ERR_OpenEndedComment);
2453ErrorCode.ERR_Merge_conflict_marker_encountered);
3159this.AddError(TextWindow.LexemeStartPosition, TextWindow.Width, ErrorCode.ERR_OpenEndedComment);
4062this.AddCrefError(ErrorCode.ERR_UnexpectedCharacter, ".");
4201this.AddError(ErrorCode.ERR_ExpectedVerbatimLiteral);
4208this.AddCrefError(ErrorCode.ERR_UnexpectedCharacter, info.Text);
4219this.AddCrefError(ErrorCode.ERR_UnexpectedCharacter, info.Text);
4312private void AddCrefError(ErrorCode code, params object[] args)
4325this.AddError(ErrorCode.WRN_ErrorOverride, info, info.Code);
Parser\Lexer_StringLiteral.cs (28)
30this.AddError(ErrorCode.ERR_RawStringNotInDirectives);
64this.AddError(ErrorCode.ERR_NewlineInConst);
80this.AddError((_builder.Length != 0) ? ErrorCode.ERR_TooManyCharsInConst : ErrorCode.ERR_EmptyCharConst);
178this.AddError(start, TextWindow.Position - start, ErrorCode.ERR_IllegalEscape);
198this.AddError(start, width: TextWindow.Position - start, ErrorCode.ERR_IllegalAtSequence);
226this.AddError(ErrorCode.ERR_UnterminatedStringLit);
457TrySetError(_lexer.MakeError(start, window.Position - start, ErrorCode.ERR_StringMustStartWithQuoteCharacter));
468TrySetError(_lexer.MakeError(start, window.Position - start, ErrorCode.ERR_IllegalAtSequence));
474TrySetError(_lexer.MakeError(window.Position - startingQuoteCount, startingQuoteCount, ErrorCode.ERR_NotEnoughQuotesForRawString));
532width: 1, ErrorCode.ERR_UnterminatedStringLit));
555width: 1, ErrorCode.ERR_UnterminatedRawString));
574ErrorCode.ERR_TooManyQuotesForRawString));
589_lexer.TextWindow.Position - 1, width: 1, ErrorCode.ERR_UnterminatedRawString));
602ErrorCode.ERR_RawStringDelimiterOnOwnLine));
621ErrorCode.ERR_TooManyQuotesForRawString));
675TrySetError(_lexer.MakeError(escapeStart, _lexer.TextWindow.Position - escapeStart, ErrorCode.ERR_EscapedCurly, ch));
706_lexer.TextWindow.Position - closeQuoteCount, closeQuoteCount, ErrorCode.ERR_RawStringMustContainContent));
806TrySetError(_lexer.MakeError(pos, 1, ErrorCode.ERR_UnescapedCurly, "}"));
824ErrorCode.ERR_TooManyCloseBracesForRawString));
860TrySetError(_lexer.MakeError(openBracePosition - 1, 2, ErrorCode.ERR_UnclosedExpressionHole));
895ErrorCode.ERR_TooManyOpenBracesForRawString));
910ErrorCode.ERR_UnclosedExpressionHole));
918ErrorCode.ERR_NotEnoughCloseBracesForRawString));
958TrySetError(_lexer.MakeError(pos, 1, ErrorCode.ERR_EscapedCurly, ch));
975_lexer.TextWindow.Position, 1, ErrorCode.ERR_UnexpectedCharacter, ch));
1015TrySetError(_lexer.MakeError(_lexer.TextWindow.Position, 1, ErrorCode.ERR_SyntaxError, endingChar.ToString()));
1047TrySetError(_lexer.MakeError(_lexer.TextWindow.Position, 1, ErrorCode.ERR_SyntaxError, endingChar.ToString()));
Parser\SyntaxParser.cs (31)
528private SyntaxToken CreateMissingToken(SyntaxKind expected, ErrorCode code, bool reportError)
559protected SyntaxToken EatToken(SyntaxKind kind, ErrorCode code, bool reportError = true)
585protected SyntaxToken EatTokenWithPrejudice(ErrorCode errorCode, params object[] args)
592protected SyntaxToken EatContextualToken(SyntaxKind kind, ErrorCode code, bool reportError = true)
623var code = GetExpectedTokenErrorCode(expected, actual);
624if (code == ErrorCode.ERR_SyntaxError)
628else if (code == ErrorCode.ERR_IdentifierExpectedKW)
646private static ErrorCode GetExpectedTokenErrorCode(SyntaxKind expected, SyntaxKind actual)
653return ErrorCode.ERR_IdentifierExpectedKW; // A keyword -- use special message.
657return ErrorCode.ERR_IdentifierExpected;
661return ErrorCode.ERR_SemicolonExpected;
666return ErrorCode.ERR_CloseParenExpected;
668return ErrorCode.ERR_LbraceExpected;
670return ErrorCode.ERR_RbraceExpected;
674return ErrorCode.ERR_SyntaxError;
722protected TNode AddError<TNode>(TNode node, ErrorCode code) where TNode : GreenNode
727protected TNode AddError<TNode>(TNode node, ErrorCode code, params object[] args) where TNode : GreenNode
777protected TNode AddError<TNode>(TNode node, int offset, int length, ErrorCode code, params object[] args) where TNode : CSharpSyntaxNode
782protected TNode AddError<TNode>(TNode node, CSharpSyntaxNode location, ErrorCode code, params object[] args) where TNode : CSharpSyntaxNode
790protected TNode AddErrorToFirstToken<TNode>(TNode node, ErrorCode code) where TNode : CSharpSyntaxNode
796protected TNode AddErrorToFirstToken<TNode>(TNode node, ErrorCode code, params object[] args) where TNode : CSharpSyntaxNode
802protected TNode AddErrorToLastToken<TNode>(TNode node, ErrorCode code) where TNode : CSharpSyntaxNode
810protected TNode AddErrorToLastToken<TNode>(TNode node, ErrorCode code, params object[] args) where TNode : CSharpSyntaxNode
831protected static SyntaxDiagnosticInfo MakeError(int offset, int width, ErrorCode code)
836protected static SyntaxDiagnosticInfo MakeError(int offset, int width, ErrorCode code, params object[] args)
841protected static SyntaxDiagnosticInfo MakeError(GreenNode node, ErrorCode code, params object[] args)
846protected static SyntaxDiagnosticInfo MakeError(ErrorCode code, params object[] args)
918tokenDiagnostics[i] = new SyntaxDiagnosticInfo(d.Offset - leadingWidth, d.Width, (ErrorCode)d.Code, d.Arguments);
971targetDiagnostics[i] = new SyntaxDiagnosticInfo(d.Offset + triviaWidth, d.Width, (ErrorCode)d.Code, d.Arguments);
985new SyntaxDiagnosticInfo(newOffset, diagnostic.Width, (ErrorCode)diagnostic.Code, diagnostic.Arguments)
1093return AddError(node, ErrorCode.WRN_ErrorOverride, info, (int)info.Code);
Symbols\AssemblySymbol.cs (3)
365DiagnosticInfo diagnosticInfo = new CSDiagnosticInfo(ErrorCode.ERR_CycleInTypeForwarder, emittedName.FullName, this.Name);
371var diagnosticInfo = new CSDiagnosticInfo(ErrorCode.ERR_TypeForwardedToMultipleAssemblies, forwardingModule, this, emittedName.FullName, destination1, destination2);
964warnings.Add(ErrorCode.WRN_MultiplePredefTypes, NoLocation.Singleton, result, result.ContainingAssembly);
Symbols\Attributes\AttributeData.cs (11)
268((BindingDiagnosticBag)arguments.Diagnostics).Add(ErrorCode.ERR_IllegalUnsafe, arguments.AttributeSyntaxOpt.Location);
319((BindingDiagnosticBag)arguments.Diagnostics).Add(ErrorCode.WRN_MemberNotNullBadMember, arguments.AttributeSyntaxOpt.Location, memberName);
397diagnostics.Add(ErrorCode.ERR_SecurityAttributeMissingAction, nodeOpt != null ? nodeOpt.Name.Location : NoLocation.Singleton);
420diagnostics.Add(ErrorCode.ERR_PrincipalPermissionInvalidAction, syntaxLocation, displayString);
450diagnostics.Add(ErrorCode.ERR_SecurityAttributeInvalidAction, syntaxLocation, nodeOpt != null ? nodeOpt.GetErrorDisplayName() : "", displayString);
466diagnostics.Add(ErrorCode.ERR_SecurityAttributeInvalidActionTypeOrMethod, syntaxLocation, displayString);
480diagnostics.Add(ErrorCode.ERR_SecurityAttributeInvalidActionAssembly, syntaxLocation, displayString);
556diagnostics.Add(ErrorCode.ERR_PermissionSetAttributeInvalidFile, argSyntaxLocation, fileName ?? "<null>", filePropName);
613diagnostics.Add(ErrorCode.ERR_InvalidAttributeArgument, attributeArgumentSyntaxLocation, nodeOpt != null ? nodeOpt.GetErrorDisplayName() : "");
640diagnostics.Add(ErrorCode.ERR_InvalidAttributeArgument, attributeArgumentSyntax.Location, node.GetErrorDisplayName());
657diagnostics.Add(ErrorCode.ERR_InvalidAttributeArgument, attributeArgumentSyntaxLocation, nodeOpt != null ? nodeOpt.GetErrorDisplayName() : "");
Symbols\ConstraintsHelper.cs (26)
150diagnosticsBuilder.Add(new TypeParameterDiagnosticInfo(constraintTypeParameter, new UseSiteInfo<AssemblySymbol>(new CSDiagnosticInfo(ErrorCode.ERR_CircularConstraint, constraintTypeParameter, typeParameter))));
169ErrorCode errorCode;
172errorCode = ErrorCode.ERR_ConWithUnmanagedCon;
176errorCode = ErrorCode.ERR_ConWithValCon;
222diagnosticsBuilder.Add(new TypeParameterDiagnosticInfo(underlyingTypeParameter, new UseSiteInfo<AssemblySymbol>(new CSDiagnosticInfo(ErrorCode.ERR_CircularConstraint, underlyingTypeParameter, typeParameter))));
274diagnosticsBuilder.Add(new TypeParameterDiagnosticInfo(typeParameter, new UseSiteInfo<AssemblySymbol>(new CSDiagnosticInfo(ErrorCode.ERR_BaseConstraintConflict, typeParameter, constraintDeducedBase, deducedBaseType))));
660args.Diagnostics.Add(ErrorCode.ERR_BogusType, args.Location, type);
698args.Diagnostics.Add(ErrorCode.ERR_BogusType, args.Location, type);
884diagnosticsBuilder.Add(new TypeParameterDiagnosticInfo(typeParameter, new UseSiteInfo<AssemblySymbol>(new CSDiagnosticInfo(ErrorCode.ERR_BadTypeArgument, typeArgument.Type))));
891diagnosticsBuilder.Add(new TypeParameterDiagnosticInfo(typeParameter, new UseSiteInfo<AssemblySymbol>(new CSDiagnosticInfo(ErrorCode.ERR_GenericArgIsStaticClass, typeArgument.Type))));
900diagnosticsBuilder.Add(new TypeParameterDiagnosticInfo(typeParameter, new UseSiteInfo<AssemblySymbol>(new CSDiagnosticInfo(ErrorCode.ERR_RefConstraintNotSatisfied, containingSymbol.ConstructedFrom(), typeParameter, typeArgument.Type))));
916diagnosticsBuilder.Add(new TypeParameterDiagnosticInfo(typeParameter, new UseSiteInfo<AssemblySymbol>(new CSDiagnosticInfo(ErrorCode.ERR_UnmanagedConstraintNotSatisfied, containingSymbol.ConstructedFrom(), typeParameter, typeArgument.Type))));
940diagnosticsBuilder.Add(new TypeParameterDiagnosticInfo(typeParameter, new UseSiteInfo<AssemblySymbol>(new CSDiagnosticInfo(ErrorCode.ERR_ValConstraintNotSatisfied, containingSymbol.ConstructedFrom(), typeParameter, typeArgument.Type))));
991new UseSiteInfo<AssemblySymbol>(new CSDiagnosticInfo(ErrorCode.ERR_GenericConstraintNotSatisfiedInterfaceWithStaticAbstractMembers, iface, member))));
1025diagnosticsBuilder.Add(new TypeParameterDiagnosticInfo(typeParameter, new UseSiteInfo<AssemblySymbol>(new CSDiagnosticInfo(ErrorCode.ERR_NewConstraintNotSatisfied, containingSymbol.ConstructedFrom(), typeParameter, typeArgument.Type))));
1029diagnosticsBuilder.Add(new TypeParameterDiagnosticInfo(typeParameter, new UseSiteInfo<AssemblySymbol>(new CSDiagnosticInfo(ErrorCode.ERR_NewConstraintCannotHaveRequiredMembers, containingSymbol.ConstructedFrom(), typeParameter, typeArgument.Type))));
1048nullabilityDiagnosticsBuilderOpt.Add(new TypeParameterDiagnosticInfo(typeParameter, new UseSiteInfo<AssemblySymbol>(new CSDiagnosticInfo(ErrorCode.WRN_NullabilityMismatchInTypeParameterNotNullConstraint, containingSymbol.ConstructedFrom(), typeParameter, typeArgument))));
1055nullabilityDiagnosticsBuilderOpt.Add(new TypeParameterDiagnosticInfo(typeParameter, new UseSiteInfo<AssemblySymbol>(new CSDiagnosticInfo(ErrorCode.WRN_NullabilityMismatchInTypeParameterReferenceTypeConstraint, containingSymbol.ConstructedFrom(), typeParameter, typeArgument))));
1079nullabilityDiagnosticsBuilderOpt.Add(new TypeParameterDiagnosticInfo(typeParameter, new UseSiteInfo<AssemblySymbol>(new CSDiagnosticInfo(ErrorCode.WRN_NullabilityMismatchInTypeParameterConstraint, containingSymbol.ConstructedFrom(), constraintType, typeParameter, typeArgument))));
1085ErrorCode errorCode;
1088errorCode = ErrorCode.ERR_GenericConstraintNotSatisfiedRefType;
1092errorCode = constraintType.Type.IsInterfaceType() ? ErrorCode.ERR_GenericConstraintNotSatisfiedNullableInterface : ErrorCode.ERR_GenericConstraintNotSatisfiedNullableEnum;
1096errorCode = ErrorCode.ERR_GenericConstraintNotSatisfiedTyVar;
1100errorCode = ErrorCode.ERR_GenericConstraintNotSatisfiedValType;
1339return new TypeParameterDiagnosticInfo(typeParameter, new UseSiteInfo<AssemblySymbol>(new CSDiagnosticInfo(ErrorCode.ERR_BaseConstraintConflict, typeParameter, deducedBase, classConflict ? "class" : "struct")));
Symbols\FunctionPointers\FunctionPointerMethodSymbol.cs (10)
61diagnostics.Add(ErrorCode.ERR_DupReturnTypeMod, modifier.GetLocation(), modifier.Text);
66diagnostics.Add(ErrorCode.ERR_InvalidFuncPointerReturnTypeModifier, modifier.GetLocation(), modifier.Text);
75diagnostics.Add(ErrorCode.ERR_NoVoidHere, returnTypeParameter.Location);
83diagnostics.Add(ErrorCode.ERR_MethodReturnCantBeRefAny, returnTypeParameter.Location, returnType);
119diagnostics.Add(ErrorCode.ERR_CannotSpecifyManagedWithUnmanagedSpecifiers, callingConventionSyntax.UnmanagedCallingConventionList.GetLocation());
166diagnostics.Add(ErrorCode.ERR_InvalidFunctionPointerCallingConvention, unmanagedList.OpenBracketToken.GetLocation(), "");
217specifierType = new MissingMetadataTypeSymbol.TopLevel(compilation.Assembly.CorLibrary.Modules[0], ref metadataName, new CSDiagnosticInfo(ErrorCode.ERR_TypeNotFound, typeName));
221diagnostics.Add(ErrorCode.ERR_TypeMustBePublic, specifier.GetLocation(), specifierType);
233diagnostics.Add(ErrorCode.ERR_RuntimeDoesNotSupportUnmanagedDefaultCallConv, errorLocation);
778MergeUseSiteInfo(ref info, new UseSiteInfo<AssemblySymbol>(new CSDiagnosticInfo(ErrorCode.ERR_UnsupportedCallingConvention, this)));
Symbols\MissingMetadataTypeSymbol.cs (6)
79return new CSDiagnosticInfo(ErrorCode.ERR_NoTypeDef, this, containingAssembly.Identity);
88return new CSDiagnosticInfo(ErrorCode.ERR_NoTypeDefFromModule, this, containingModule.Name);
111return new CSDiagnosticInfo(ErrorCode.ERR_MissingTypeInSource, this);
120return new CSDiagnosticInfo(ErrorCode.ERR_MissingTypeInAssembly, this, containingAssembly.Name);
130return new CSDiagnosticInfo(ErrorCode.ERR_BogusType, string.Empty);
323new CSDiagnosticInfo(ErrorCode.ERR_PredefinedTypeNotFound, MetadataHelpers.BuildQualifiedName(_namespaceName, MetadataName)) :
Symbols\ObsoleteAttributeHelpers.cs (16)
162return new CSDiagnosticInfo(ErrorCode.WRN_Experimental, new FormattedSymbol(symbol, SymbolDisplayFormat.CSharpErrorMessageFormat));
168var errorCode = (message: data.Message, isError: data.IsError, isColInit) switch
171(message: null, isError: _, isColInit: true) => ErrorCode.WRN_DeprecatedCollectionInitAdd,
172(message: null, isError: _, isColInit: false) => ErrorCode.WRN_DeprecatedSymbol,
173(message: { }, isError: true, isColInit: true) => ErrorCode.ERR_DeprecatedCollectionInitAddStr,
174(message: { }, isError: true, isColInit: false) => ErrorCode.ERR_DeprecatedSymbolStr,
175(message: { }, isError: false, isColInit: true) => ErrorCode.WRN_DeprecatedCollectionInitAddStr,
176(message: { }, isError: false, isColInit: false) => ErrorCode.WRN_DeprecatedSymbolStr
189return (ErrorCode)diagnosticInfo.Code is
190(ErrorCode.WRN_Experimental or ErrorCode.WRN_DeprecatedCollectionInitAdd or
191ErrorCode.WRN_DeprecatedSymbol or ErrorCode.ERR_DeprecatedCollectionInitAddStr or
192ErrorCode.ERR_DeprecatedSymbolStr or ErrorCode.WRN_DeprecatedCollectionInitAddStr or
193ErrorCode.WRN_DeprecatedSymbolStr);
Symbols\Source\ExplicitInterfaceHelpers.cs (15)
199diagnostics.Add(ErrorCode.ERR_ExplicitInterfaceImplementationInNonClassOrStruct, memberLocation, implementingMember);
209diagnostics.Add(ErrorCode.ERR_ExplicitInterfaceImplementationNotInterface, location, explicitInterfaceType);
227diagnostics.Add(ErrorCode.WRN_NullabilityMismatchInExplicitlyImplementedInterface, location);
231diagnostics.Add(ErrorCode.ERR_ClassDoesntImplementInterface, location, implementingMember, explicitInterfaceNamedType);
275diagnostics.Add(ErrorCode.ERR_ExplicitMethodImplAccessor, memberLocation, implementingMember, interfaceMember);
281diagnostics.Add(ErrorCode.ERR_BogusExplicitImpl, memberLocation, implementingMember, interfaceMember);
287diagnostics.Add(ErrorCode.ERR_ExplicitImplParams, memberLocation, implementingMember, interfaceMember);
300diagnostics.Add(ErrorCode.ERR_InterfaceMemberNotFound, memberLocation, implementingMember);
310diagnostics.Add(ErrorCode.ERR_BadAccess, memberLocation, implementedMember);
334diagnostics.Add(ErrorCode.ERR_BadAccess, memberLocation, accessor);
359diagnostics.Add(ErrorCode.ERR_ImplBadTupleNames, memberLocation, implementingMember, implementedMember);
370diagnostics.Add(ErrorCode.ERR_RuntimeDoesNotSupportStaticAbstractMembersInInterfaces, implementingMember.Locations[0]);
411diagnostics.Add(ErrorCode.ERR_ExplicitImplCollisionOnRefOut, explicitInterfaceType.Locations[0], explicitInterfaceType, implementedMember);
416diagnostics.Add(ErrorCode.WRN_ExplicitImplCollision, implementingMember.Locations[0], implementingMember);
428diagnostics.Add(ErrorCode.WRN_ExplicitImplCollision, implementingMember.Locations[0], implementingMember);
Symbols\Source\ModifierUtils.cs (12)
96diagnostics.Add(ErrorCode.ERR_StaticNotVirtual, errorLocation, ModifierUtils.ConvertSingleModifierToSyntaxText(oneError));
100diagnostics.Add(ErrorCode.ERR_BadMemberFlag, errorLocation, ConvertSingleModifierToSyntaxText(oneError));
137diagnostics.Add(ErrorCode.ERR_PartialMisplaced, partialToken.GetLocation());
142diagnostics.Add(ErrorCode.ERR_PartialMisplaced, errorLocation);
164diagnostics.Add(ErrorCode.ERR_BadMemberFlag, errorLocation, ConvertSingleModifierToSyntaxText(DeclarationModifiers.Sealed));
205diagnostics.Add(ErrorCode.ERR_InvalidModifierForLanguageVersion, errorLocation,
415ErrorCode.ERR_PartialMisplaced,
453ErrorCode.ERR_DuplicateModifier,
466diagnostics.Add(ErrorCode.ERR_BadMemberProtection, errorLocation);
482diagnostics.Add(ErrorCode.ERR_RuntimeDoesNotSupportProtectedAccessForInterfaceMember, errorLocation);
499diagnostics.Add(ErrorCode.ERR_RequiredMemberCannotBeLessVisibleThanContainingType, errorLocation, symbol, symbol.ContainingType);
505diagnostics.Add(ErrorCode.ERR_RequiredMemberMustBeSettable, errorLocation, symbol);
Symbols\Source\ParameterHelpers.cs (29)
98diagnostics.Add(ErrorCode.ERR_NoVoidParameter, syntax.Type.Location);
145diagnostics.Add(ErrorCode.ERR_ThisInBadContext, thisKeyword.GetLocation());
160diagnostics.Add(ErrorCode.ERR_IllegalVarArgs, arglistToken.GetLocation());
166diagnostics.Add(ErrorCode.ERR_VarargsLast, concreteParam.GetLocation());
186diagnostics.Add(ErrorCode.ERR_IllegalRefParam, refnessKeyword.GetLocation());
427diagnostics.Add(ErrorCode.ERR_ThisInBadContext, modifier.GetLocation());
439diagnostics.Add(ErrorCode.ERR_BadParamModThis, modifier.GetLocation());
505diagnostics.Add(ErrorCode.ERR_IllegalParams, modifier.GetLocation());
513diagnostics.Add(ErrorCode.ERR_BadParamModThis, modifier.GetLocation());
579diagnostics.Add(ErrorCode.ERR_ReadOnlyNotSuppAsParamModDidYouMeanIn, modifier.GetLocation());
584diagnostics.Add(ErrorCode.ERR_BadFuncPointerParamModifier, modifier.GetLocation(), SyntaxFacts.GetText(modifier.Kind()));
594diagnostics.Add(ErrorCode.ERR_DupParamMod, modifier.GetLocation(), SyntaxFacts.GetText(modifier.Kind()));
599diagnostics.Add(ErrorCode.ERR_BadParameterModifiers, modifier.GetLocation(), SyntaxFacts.GetText(modifier.Kind()), SyntaxFacts.GetText(otherModifierKind));
604diagnostics.Add(ErrorCode.ERR_ParamsCantBeWithModifier, modifier.GetLocation(), SyntaxFacts.GetText(otherModifierKind));
632diagnostics.Add(ErrorCode.ERR_BadThisParam, thisKeyword.GetLocation(), owner?.Name ?? "");
637diagnostics.Add(ErrorCode.ERR_IllegalParams, paramsKeyword.GetLocation());
642diagnostics.Add(ErrorCode.ERR_ParamsMustBeArray, paramsKeyword.GetLocation());
657diagnostics.Add(ErrorCode.ERR_DefaultValueBeforeRequiredValue, loc);
663diagnostics.Add(ErrorCode.ERR_MethodArgCantBeRefAny, syntax.Location, typeWithAnnotations.Type);
669diagnostics.Add(ErrorCode.ERR_ParamsLast, syntax.GetLocation());
674diagnostics.Add(ErrorCode.ERR_ScopedRefAndRefStructOnly, syntax.Location);
722diagnostics.Add(ErrorCode.ERR_RefOutDefaultValue, refnessKeyword.GetLocation());
728diagnostics.Add(ErrorCode.ERR_DefaultValueForParamsParameter, paramsKeyword.GetLocation());
738diagnostics.Add(ErrorCode.ERR_DefaultValueForExtensionParameter, thisKeyword.GetLocation());
747diagnostics.Add(ErrorCode.ERR_DefaultValueMustBeConstant, parameterSyntax.Default.Value.Location, parameterSyntax.Identifier.ValueText);
760diagnostics.Add(ErrorCode.ERR_NoConversionForDefaultParam, parameterSyntax.Identifier.GetLocation(),
772diagnostics.Add(ErrorCode.ERR_NotNullRefDefaultParameter, parameterSyntax.Identifier.GetLocation(),
794diagnostics.Add(ErrorCode.ERR_NoConversionForNubDefaultParam, parameterSyntax.Identifier.GetLocation(),
823diagnostics.Add(ErrorCode.WRN_DefaultValueForUnconsumedLocation,
Symbols\Source\SourceAssemblySymbol.cs (46)
594diagnostics.Add(ErrorCode.WRN_DelaySignButNoKey, NoLocation.Singleton);
601diagnostics.Add(ErrorCode.ERR_PublicSignNetModule, NoLocation.Singleton);
605diagnostics.Add(ErrorCode.ERR_PublicSignButNoKey, NoLocation.Singleton);
623diagnostics.Add(ErrorCode.ERR_SignButNoPrivateKey, NoLocation.Singleton, StrongNameKeys.KeyFilePath);
739diagnostics.Add(ErrorCode.ERR_FriendAssemblySNReq, oneKey.Value.Item1, oneKey.Value.Item2);
770diagnostics.Add(ErrorCode.WRN_CmdOptionConflictsSource, NoLocation.Singleton, "DelaySign", AttributeDescription.AssemblyDelaySignAttribute.FullName);
775diagnostics.Add(ErrorCode.WRN_CmdOptionConflictsSource, NoLocation.Singleton,
811diagnostics.Add(ErrorCode.ERR_CmdOptionConflictsSource, NoLocation.Singleton, AttributeDescription.AssemblyKeyNameAttribute.FullName, "CryptoKeyContainer");
815diagnostics.Add(ErrorCode.WRN_CmdOptionConflictsSource, NoLocation.Singleton, "CryptoKeyContainer", AttributeDescription.AssemblyKeyNameAttribute.FullName);
824diagnostics.Add(ErrorCode.WRN_AttributeIgnoredWhenPublicSigning, NoLocation.Singleton, AttributeDescription.AssemblyKeyNameAttribute.FullName);
848diagnostics.Add(ErrorCode.ERR_CmdOptionConflictsSource, NoLocation.Singleton, AttributeDescription.AssemblyKeyFileAttribute.FullName, "CryptoKeyFile");
852diagnostics.Add(ErrorCode.WRN_CmdOptionConflictsSource, NoLocation.Singleton, "CryptoKeyFile", AttributeDescription.AssemblyKeyFileAttribute.FullName);
861diagnostics.Add(ErrorCode.WRN_AttributeIgnoredWhenPublicSigning, NoLocation.Singleton, AttributeDescription.AssemblyKeyFileAttribute.FullName);
976diagnostics.Add(ErrorCode.ERR_NetModuleNameMismatch, NoLocation.Singleton, moduleName, fileName);
993diagnostics.Add(ErrorCode.ERR_NetModuleNameMustBeUnique, NoLocation.Singleton, m.Name);
1007diagnostics.Add(ErrorCode.ERR_AgnosticToMachineModule, NoLocation.Singleton, m);
1013diagnostics.Add(ErrorCode.ERR_ConflictingMachineModule, NoLocation.Singleton, m);
1031diagnostics.Add(ErrorCode.ERR_MissingNetModuleReference, NoLocation.Singleton, referencedModuleName);
1037diagnostics.Add(new CSDiagnosticInfo(ErrorCode.ERR_BindToBogus, m), NoLocation.Singleton);
1088diagnostics.Add(ErrorCode.ERR_DuplicateNameInNS, y.Locations.FirstOrNone(),
1252diagnostics.Add(ErrorCode.WRN_AssemblyAttributeFromModuleIsOverridden, NoLocation.Singleton, attribute.AttributeClass, netModuleName);
1258diagnostics.Add(ErrorCode.ERR_DuplicateAttributeInNetModule, NoLocation.Singleton, attribute.AttributeClass.Name, netModuleName);
2095bag.Add(ErrorCode.ERR_FriendRefNotEqualToThis, NoLocation.Singleton,
2098bag.Add(ErrorCode.ERR_FriendRefSigningMismatch, NoLocation.Singleton,
2187diagnostics.Add(ErrorCode.ERR_InvalidFwdType, GetAssemblyAttributeLocationForDiagnostic(arguments.AttributeSyntaxOpt));
2192if (useSiteInfo.DiagnosticInfo?.Code != (int)ErrorCode.ERR_UnexpectedUnboundGenericName &&
2202diagnostics.Add(ErrorCode.ERR_ForwardedTypeInThisAssembly, GetAssemblyAttributeLocationForDiagnostic(arguments.AttributeSyntaxOpt), forwardedType);
2208diagnostics.Add(ErrorCode.ERR_ForwardedTypeIsNested, GetAssemblyAttributeLocationForDiagnostic(arguments.AttributeSyntaxOpt), forwardedType, forwardedType.ContainingType);
2218diagnostics.Add(ErrorCode.ERR_InvalidFwdType, GetAssemblyAttributeLocationForDiagnostic(arguments.AttributeSyntaxOpt));
2238diagnostics.Add(ErrorCode.ERR_DuplicateTypeForwarder, GetAssemblyAttributeLocationForDiagnostic(arguments.AttributeSyntaxOpt), forwardedType);
2256diagnostics.Add(ErrorCode.ERR_CannotPassNullForFriendAssembly, GetAssemblyAttributeLocationForDiagnostic(nodeOpt));
2264diagnostics.Add(ErrorCode.WRN_InvalidAssemblyName, GetAssemblyAttributeLocationForDiagnostic(nodeOpt), displayName);
2274diagnostics.Add(ErrorCode.ERR_FriendAssemblyBadArgs, GetAssemblyAttributeLocationForDiagnostic(nodeOpt), displayName);
2356diagnostics.Add(ErrorCode.ERR_InvalidSignaturePublicKey, attribute.GetAttributeArgumentSyntaxLocation(0, arguments.AttributeSyntaxOpt));
2379diagnostics.Add(foundBadWildcard ? ErrorCode.ERR_InvalidVersionFormatDeterministic : ErrorCode.ERR_InvalidVersionFormat, attributeArgumentSyntaxLocation, verString ?? "<null>");
2391diagnostics.Add(ErrorCode.WRN_InvalidVersionFormat, attributeArgumentSyntaxLocation, verString ?? "<null>");
2411diagnostics.Add(ErrorCode.ERR_InvalidAssemblyCultureForExe, attribute.GetAttributeArgumentSyntaxLocation(0, arguments.AttributeSyntaxOpt));
2415diagnostics.Add(ErrorCode.ERR_InvalidAssemblyCulture, attribute.GetAttributeArgumentSyntaxLocation(0, arguments.AttributeSyntaxOpt));
2443diagnostics.Add(ErrorCode.ERR_InvalidVersionFormat2, attributeArgumentSyntaxLocation, verString ?? "<null>");
2527diagnostics.Add(ErrorCode.ERR_ExplicitExtension, arguments.AttributeSyntaxOpt.Location);
2561diagnostics.Add(ErrorCode.ERR_InvalidAttributeArgument, attributeArgumentSyntaxLocation, (object)nodeOpt != null ? nodeOpt.GetErrorDisplayName() : "");
2693diagnostics.Add(ErrorCode.WRN_UnreferencedEvent, associatedPropertyOrEvent.Locations.FirstOrNone(), associatedPropertyOrEvent);
2698diagnostics.Add(ErrorCode.WRN_UnreferencedField, field.Locations.FirstOrNone(), field);
2702diagnostics.Add(ErrorCode.WRN_UnassignedInternalField, field.Locations.FirstOrNone(), field, DefaultValue(field.Type));
2722diagnostics.Add(ErrorCode.WRN_UnreferencedFieldAssg, field.Locations.FirstOrNone(), field);
Symbols\Source\SourceComplexParameterSymbol.cs (41)
758diagnostics.Add(ErrorCode.ERR_DefaultValueUsedWithAttributes, arguments.AttributeSyntaxOpt.Name.Location);
764diagnostics.Add(ErrorCode.ERR_ExplicitParamArray, arguments.AttributeSyntaxOpt.Name.Location);
858diagnostics.Add(ErrorCode.ERR_UnscopedRefAttributeUnsupportedTarget, arguments.AttributeSyntaxOpt.Location);
862diagnostics.Add(ErrorCode.ERR_UnscopedScoped, arguments.AttributeSyntaxOpt.Location);
911diagnostics.Add(ErrorCode.ERR_ParamDefaultValueDiffersFromAttribute, syntax.Location);
944diagnosticsOpt.Add(ErrorCode.ERR_DefaultValueUsedWithAttributes, node.Name.Location);
982diagnosticsOpt.Add(ErrorCode.ERR_DefaultValueTypeMustMatch, node.Name.Location);
992diagnosticsOpt.Add(ErrorCode.ERR_DefaultValueBadValueType, node.Name.Location, arg.TypeInternal);
1002diagnosticsOpt.Add(ErrorCode.ERR_DefaultValueTypeMustMatch, node.Name.Location);
1057diagnostics.Add(ErrorCode.WRN_CallerLineNumberParamForUnconsumedLocation, node.Name.Location, CSharpSyntaxNode.Identifier.ValueText);
1063diagnostics.Add(ErrorCode.ERR_NoConversionForCallerLineNumberParam, node.Name.Location, intType, TypeWithAnnotations.Type);
1070diagnostics.Add(ErrorCode.ERR_BadCallerLineNumberParamWithoutDefaultValue, node.Name.Location);
1085diagnostics.Add(ErrorCode.WRN_CallerFilePathParamForUnconsumedLocation, node.Name.Location, CSharpSyntaxNode.Identifier.ValueText);
1091diagnostics.Add(ErrorCode.ERR_NoConversionForCallerFilePathParam, node.Name.Location, stringType, TypeWithAnnotations.Type);
1098diagnostics.Add(ErrorCode.ERR_BadCallerFilePathParamWithoutDefaultValue, node.Name.Location);
1103diagnostics.Add(ErrorCode.WRN_CallerLineNumberPreferredOverCallerFilePath, node.Name.Location, CSharpSyntaxNode.Identifier.ValueText);
1118diagnostics.Add(ErrorCode.WRN_CallerMemberNameParamForUnconsumedLocation, node.Name.Location, CSharpSyntaxNode.Identifier.ValueText);
1124diagnostics.Add(ErrorCode.ERR_NoConversionForCallerMemberNameParam, node.Name.Location, stringType, TypeWithAnnotations.Type);
1131diagnostics.Add(ErrorCode.ERR_BadCallerMemberNameParamWithoutDefaultValue, node.Name.Location);
1136diagnostics.Add(ErrorCode.WRN_CallerLineNumberPreferredOverCallerMemberName, node.Name.Location, CSharpSyntaxNode.Identifier.ValueText);
1141diagnostics.Add(ErrorCode.WRN_CallerFilePathPreferredOverCallerMemberName, node.Name.Location, CSharpSyntaxNode.Identifier.ValueText);
1159diagnostics.Add(ErrorCode.WRN_CallerArgumentExpressionParamForUnconsumedLocation, node.Name.Location, CSharpSyntaxNode.Identifier.ValueText);
1165diagnostics.Add(ErrorCode.ERR_NoConversionForCallerArgumentExpressionParam, node.Name.Location, stringType, TypeWithAnnotations.Type);
1172diagnostics.Add(ErrorCode.ERR_BadCallerArgumentExpressionParamWithoutDefaultValue, node.Name.Location);
1177diagnostics.Add(ErrorCode.WRN_CallerLineNumberPreferredOverCallerArgumentExpression, node.Name.Location, CSharpSyntaxNode.Identifier.ValueText);
1182diagnostics.Add(ErrorCode.WRN_CallerFilePathPreferredOverCallerArgumentExpression, node.Name.Location, CSharpSyntaxNode.Identifier.ValueText);
1187diagnostics.Add(ErrorCode.WRN_CallerMemberNamePreferredOverCallerArgumentExpression, node.Name.Location, CSharpSyntaxNode.Identifier.ValueText);
1193diagnostics.Add(ErrorCode.WRN_CallerArgumentExpressionAttributeHasInvalidParameterName, node.Name.Location, CSharpSyntaxNode.Identifier.ValueText);
1198diagnostics.Add(ErrorCode.WRN_CallerArgumentExpressionAttributeSelfReferential, node.Name.Location, CSharpSyntaxNode.Identifier.ValueText);
1208diagnostics.Add(ErrorCode.WRN_UnconsumedEnumeratorCancellationAttributeUsage, node.Name.Location, CSharpSyntaxNode.Identifier.ValueText);
1241diagnostics.Add(ErrorCode.ERR_TypeIsNotAnInterpolatedStringHandlerType, errorLocation, Type);
1249diagnostics.Add(ErrorCode.WRN_InterpolatedStringHandlerArgumentAttributeIgnoredOnLambdaParameters, errorLocation);
1277diagnostics.Add(ErrorCode.ERR_NullInvalidInterpolatedStringHandlerArgumentName, arguments.AttributeSyntaxOpt!.Location);
1321diagnostics.Add(ErrorCode.ERR_NullInvalidInterpolatedStringHandlerArgumentName, arguments.AttributeSyntaxOpt.Location);
1339diagnostics.Add(ErrorCode.ERR_NotInstanceInvalidInterpolatedStringHandlerArgumentName, arguments.AttributeSyntaxOpt.Location, ContainingSymbol);
1350diagnostics.Add(ErrorCode.ERR_InvalidInterpolatedStringHandlerArgumentName, arguments.AttributeSyntaxOpt.Location, name, ContainingSymbol);
1357diagnostics.Add(ErrorCode.ERR_CannotUseSelfAsInterpolatedStringHandlerArgument, errorLocation);
1366diagnostics.Add(ErrorCode.WRN_ParameterOccursAfterInterpolatedStringHandlerParameter, errorLocation, parameter.Name, this.Name);
1397diagnostics.Add(ErrorCode.ERR_OutAttrOnRefParam, this.Locations[0]);
1404diagnostics.Add(ErrorCode.ERR_InAttrOnOutParam, this.Locations[0]);
1411diagnostics.Add(ErrorCode.ERR_OutAttrOnInParam, this.Locations[0]);
Symbols\Source\SourceConstructorSymbol.cs (6)
50diagnostics.Add(ErrorCode.ERR_MemberNeedsType, location);
57diagnostics.Add(ErrorCode.ERR_ExternHasConstructorInitializer, location, this);
62diagnostics.Add(ErrorCode.ERR_ExternHasBody, location, this);
127diagnostics.Add(ErrorCode.ERR_StaticConstructorWithAccessModifiers, location, this);
149diagnostics.Add(ErrorCode.ERR_ConcreteMissingBody, location, this);
157diagnostics.Add(ErrorCode.ERR_ConstructorInStaticClass, location);
Symbols\Source\SourceCustomEventSymbol.cs (8)
95diagnostics.Add(ErrorCode.ERR_DuplicateAccessor, accessor.Keyword.GetLocation());
106diagnostics.Add(ErrorCode.ERR_DuplicateAccessor, accessor.Keyword.GetLocation());
112diagnostics.Add(ErrorCode.ERR_AddOrRemoveExpected, accessor.Keyword.GetLocation());
126diagnostics.Add(ErrorCode.ERR_AddRemoveMustHaveBody, accessor.SemicolonToken.GetLocation());
134diagnostics.Add(ErrorCode.ERR_AbstractEventHasAccessors, syntax.AccessorList.OpenBraceToken.GetLocation(), this);
139diagnostics.Add(ErrorCode.ERR_EventNeedsBothAccessors, this.Locations[0], this);
144diagnostics.Add(ErrorCode.ERR_ExplicitEventFieldImpl, this.Locations[0]);
155diagnostics.Add(ErrorCode.ERR_RuntimeDoesNotSupportDefaultInterfaceImplementation, this.Locations[0]);
Symbols\Source\SourceDelegateMethodSymbol.cs (6)
64diagnostics.Add(ErrorCode.ERR_MethodReturnCantBeRefAny, returnTypeSyntax.Location, returnType.Type);
101diagnostics.Add(ErrorCode.ERR_BadVisDelegateReturn, delegateType.Locations[0], delegateType, invoke.ReturnType);
107diagnostics.Add(ErrorCode.ERR_FileTypeDisallowedInSignature, delegateType.Locations[0], invoke.ReturnType, delegateType);
116diagnostics.Add(ErrorCode.ERR_BadVisDelegateParam, delegateType.Locations[0], delegateType, parameterSymbol.Type);
120diagnostics.Add(ErrorCode.ERR_FileTypeDisallowedInSignature, delegateType.Locations[0], parameterSymbol.Type, delegateType);
288diagnostics.Add(ErrorCode.ERR_IllegalVarArgs, new SourceLocation(arglistToken));
Symbols\Source\SourceEventSymbol.cs (17)
312diagnostics.Add(ErrorCode.ERR_UnscopedRefAttributeUnsupportedMemberTarget, arguments.AttributeSyntaxOpt!.Location);
527diagnostics.Add(ErrorCode.ERR_VirtualPrivate, location, this);
532diagnostics.Add(ErrorCode.ERR_StaticMemberCantBeReadOnly, location, this);
537diagnostics.Add(ErrorCode.ERR_FieldLikeEventCantBeReadOnly, location, this);
542diagnostics.Add(ErrorCode.ERR_OverrideNotNew, location, this);
547diagnostics.Add(ErrorCode.ERR_SealedNonOverride, location, this);
552diagnostics.Add(ErrorCode.ERR_BadMemberFlag, location, SyntaxFacts.GetText(SyntaxKind.AbstractKeyword));
557diagnostics.Add(ErrorCode.ERR_BadMemberFlag, location, SyntaxFacts.GetText(SyntaxKind.VirtualKeyword));
561diagnostics.Add(ErrorCode.ERR_AbstractAndExtern, location, this);
565diagnostics.Add(ErrorCode.ERR_AbstractAndSealed, location, this);
569diagnostics.Add(ErrorCode.ERR_AbstractNotVirtual, location, this.Kind.Localize(), this);
577diagnostics.Add(ErrorCode.ERR_InstanceMemberInStaticClass, location, Name);
588diagnostics.Add(ErrorCode.ERR_BadVisEventType, location, this, this.Type);
593diagnostics.Add(ErrorCode.ERR_EventNotDelegate, location, this);
598diagnostics.Add(ErrorCode.ERR_AbstractInConcreteClass, location, this, ContainingType);
603diagnostics.Add(ErrorCode.ERR_NewVirtualInSealed, location, this, ContainingType);
772diagnostics.Add(ErrorCode.ERR_ExplicitPropertyAddingAccessor, thisAccessor.Locations[0], thisAccessor, explicitlyImplementedEvent);
Symbols\Source\SourceFieldLikeEventSymbol.cs (7)
69diagnostics.Add(ErrorCode.ERR_InterfaceEventInitializer, this.Locations[0], this);
73diagnostics.Add(ErrorCode.ERR_AbstractEventInitializer, this.Locations[0], this);
77diagnostics.Add(ErrorCode.ERR_ExternEventInitializer, this.Locations[0], this);
91diagnostics.Add(ErrorCode.ERR_FieldlikeEventsInRoStruct, this.Locations[0]);
100diagnostics.Add(ErrorCode.ERR_RuntimeDoesNotSupportStaticAbstractMembersInInterfaces, this.Locations[0]);
107diagnostics.Add(ErrorCode.ERR_RuntimeDoesNotSupportDefaultInterfaceImplementation, this.Locations[0]);
112diagnostics.Add(ErrorCode.ERR_EventNeedsBothAccessors, this.Locations[0], this);
Symbols\Source\SourceMemberContainerSymbol.cs (89)
234diagnostics.Add(ErrorCode.ERR_PartialModifierConflict, Locations[0], this);
343diagnostics.Add(ErrorCode.ERR_AbstractSealedStatic, Locations[0], this);
349diagnostics.Add(ErrorCode.ERR_SealedStaticClass, Locations[0], this);
422diagnostics.Add(ErrorCode.ERR_FileTypeNoExplicitAccessibility, Locations[0], this);
437? ErrorCode.ERR_FileLocalDuplicateNameInNS
438: ErrorCode.ERR_DuplicateNameInNS, declaration.Declarations[i].NameLocation, this.Name, this.ContainingSymbol);
447diagnostics.Add(ErrorCode.ERR_DuplicateNameInClass, declaration.Declarations[i].NameLocation, this.ContainingSymbol, this.Name);
461diagnostics.Add(ErrorCode.ERR_MissingPartial, singleDeclaration.NameLocation, this.Name);
483if (reportIfContextual(SyntaxKind.RecordKeyword, MessageID.IDS_FeatureRecords, ErrorCode.WRN_RecordNamedDisallowed)
484|| reportIfContextual(SyntaxKind.RequiredKeyword, MessageID.IDS_FeatureRequiredMembers, ErrorCode.ERR_RequiredNameDisallowed)
485|| reportIfContextual(SyntaxKind.FileKeyword, MessageID.IDS_FeatureFileTypes, ErrorCode.ERR_FileTypeNameDisallowed)
486|| reportIfContextual(SyntaxKind.ScopedKeyword, MessageID.IDS_FeatureRefFields, ErrorCode.ERR_ScopedTypeNameDisallowed))
492diagnostics.Add(ErrorCode.WRN_LowerCaseTypeName, location, name);
495bool reportIfContextual(SyntaxKind contextualKind, MessageID featureId, ErrorCode error)
1315diagnostics.Add(ErrorCode.ERR_PartialTypeKindConflict, t.Locations[0], t);
1319diagnostics.Add(ErrorCode.ERR_DuplicateNameInClass, t.Locations[0], this, t.Name);
1358diagnostics.Add(ErrorCode.ERR_MemberNameSameAsType, member.Locations[0], this.Name);
1784diagnostics.Add(ErrorCode.ERR_FilePathCannotBeConvertedToUtf8, location, this, errorMessage);
1789diagnostics.Add(ErrorCode.ERR_FileTypeNested, location, this);
1837diagnostics.Add(ErrorCode.ERR_CloneDisallowedInRecord, member.Locations[0]);
1946diagnostics.Add(ErrorCode.ERR_DuplicateNameInClass, symbol.Locations[0], this, symbol.Name);
1976diagnostics.Add(ErrorCode.ERR_DuplicateConversionInClass, conversion.Locations[0], this);
2062diagnostics.Add(ErrorCode.ERR_OverloadRefKind, method1.Locations[0], this, methodKind.Localize(), refKind1.ToParameterDisplayString(), refKind2.ToParameterDisplayString());
2074diagnostics.Add(ErrorCode.ERR_MemberAlreadyExists, method1.Locations[0], methodName, this);
2116diagnostics.Add(ErrorCode.ERR_DuplicateNameInClass, indexer.Locations[0], this, indexerName);
2147diagnostics.Add(ErrorCode.ERR_InconsistentIndexerNames, indexer.Locations[0]);
2158diagnostics.Add(ErrorCode.ERR_DuplicateNameInClass, indexer.Locations[0], this, indexerName);
2167diagnostics.Add(ErrorCode.ERR_MemberAlreadyExists, indexer.Locations[0], SyntaxFacts.GetText(SyntaxKind.ThisKeyword), this);
2201diagnostics.Add(ErrorCode.ERR_DuplicateNameInClass, dup.Locations[0], this, tp.Name);
2300diagnostics.Add(ErrorCode.ERR_StructLayoutCyclePrimaryConstructorParameter, parameterSymbol.Locations[0], parameterSymbol, type);
2308diagnostics.Add(ErrorCode.ERR_StructLayoutCycle, symbol.Locations[0], symbol, type);
2339diagnostics.Add(ErrorCode.ERR_ProtectedInStatic, member.Locations[0], member);
2403diagnostics.Add(ErrorCode.ERR_OperatorNeedsMatch, op1.Locations[0], op1,
2409diagnostics.Add(ErrorCode.ERR_CheckedOperatorNeedsMatch, op1.Locations[0], op1);
2487diagnostics.Add(ErrorCode.WRN_EqualsWithoutGetHashCode, this.Locations[0], this);
2493diagnostics.Add(ErrorCode.WRN_EqualityOpWithoutEquals, this.Locations[0], this);
2499diagnostics.Add(ErrorCode.WRN_EqualityOpWithoutGetHashCode, this.Locations[0], this);
2533diagnostics.Add(ErrorCode.ERR_RequiredMembersBaseTypeInvalid, method.Locations[0], BaseTypeNoUseSiteDiagnostics);
2547diagnostics.Add(ErrorCode.ERR_ScriptsAndSubmissionsCannotHaveRequiredMembers, member.Locations[0]);
2578diagnostics.Add(ErrorCode.ERR_StructLayoutCycle, f.Locations[0], f, type);
2642diagnostics.Add(ErrorCode.WRN_SequentialOnPartialClass, Locations[0], this);
3180Binder.Error(diagnostics, ErrorCode.ERR_SimpleProgramMultipleUnitsWithTopLevelStatements, singleDecl.NameLocation);
3427diagnostics.Add(ErrorCode.ERR_ConstructorInStaticClass, syntax.Identifier.GetLocation());
3441diagnostics.Add(ErrorCode.ERR_MultipleRecordParameterLists, parameterList.Location);
3481diagnostics.Add(ErrorCode.ERR_PartialMethodOnlyOneActual, methodPart.Locations[0]);
3487diagnostics.Add(ErrorCode.ERR_PartialMethodOnlyOneLatent, methodPart.Locations[0]);
3511diagnostics.Add(ErrorCode.ERR_PartialMethodMustHaveLatent, method.Locations[0], method);
3515diagnostics.Add(ErrorCode.ERR_PartialMethodWithAccessibilityModsMustHaveImplementation, method.Locations[0], method);
3596diagnostics.Add(ErrorCode.ERR_DuplicateNameInClass, GetAccessorOrPropertyLocation(propertySymbol, getNotSet), this, accessorName);
3606diagnostics.Add(ErrorCode.ERR_MemberReserved, GetAccessorOrPropertyLocation(propertySymbol, getNotSet), accessorName, this);
3632diagnostics.Add(ErrorCode.ERR_DuplicateNameInClass, GetAccessorOrEventLocation(eventSymbol, isAdder), this, accessorName);
3642diagnostics.Add(ErrorCode.ERR_MemberReserved, GetAccessorOrEventLocation(eventSymbol, isAdder), accessorName, this);
3794diagnostics.Add(ErrorCode.ERR_InterfacesCantContainConstructors, member.Locations[0]);
3801diagnostics.Add(ErrorCode.ERR_OnlyClassesCanContainDestructors, member.Locations[0]);
3844diagnostics.Add(ErrorCode.ERR_EnumsCantContainDefaultConstructor, location);
3851diagnostics.Add(ErrorCode.ERR_NonPublicParameterlessStructConstructor, location);
3883diagnostics.Add(ErrorCode.ERR_StructHasInitializersAndNoDeclaredConstructor, Locations[0]);
3997diagnostics.Add(ErrorCode.WRN_RecordEqualsWithoutGetHashCode, thisEquals.Locations[0], declaration.Name);
4049diagnostics.Add(ErrorCode.ERR_NonPublicAPIInRecord, deconstruct.Locations[0], deconstruct);
4054diagnostics.Add(ErrorCode.ERR_SignatureMismatchInRecord, deconstruct.Locations[0], deconstruct, targetMethod.ReturnType);
4059diagnostics.Add(ErrorCode.ERR_StaticAPIInRecord, deconstruct.Locations[0], deconstruct);
4093diagnostics.Add(ErrorCode.ERR_RecordAmbigCtor, copyCtor.Locations[0]);
4102diagnostics.Add(ErrorCode.ERR_CopyConstructorWrongAccessibility, constructor.Locations[0], constructor);
4146diagnostics.Add(ErrorCode.ERR_NonPrivateAPIInRecord, printMembersMethod.Locations[0], printMembersMethod);
4151diagnostics.Add(ErrorCode.ERR_NonProtectedAPIInRecord, printMembersMethod.Locations[0], printMembersMethod);
4158diagnostics.Add(ErrorCode.ERR_SignatureMismatchInRecord, printMembersMethod.Locations[0], printMembersMethod, targetMethod.ReturnType);
4197ErrorCode.ERR_InheritingFromRecordWithSealedToString,
4306diagnostics.Add(ErrorCode.ERR_BadRecordMemberForPositionalParameter,
4334diagnostics.Add(ErrorCode.ERR_HiddenPositionalMember, param.Locations[0], symbol);
4374diagnostics.Add(ErrorCode.ERR_SealedAPIInRecord, getHashCode.Locations[0], getHashCode);
4408diagnostics.Add(ErrorCode.ERR_NonPrivateAPIInRecord, equalityContract.Locations[0], equalityContract);
4413diagnostics.Add(ErrorCode.ERR_NonProtectedAPIInRecord, equalityContract.Locations[0], equalityContract);
4420diagnostics.Add(ErrorCode.ERR_SignatureMismatchInRecord, equalityContract.Locations[0], equalityContract, targetProperty.Type);
4430diagnostics.Add(ErrorCode.ERR_EqualityContractRequiresGetter, equalityContract.Locations[0], equalityContract);
4473diagnostics.Add(ErrorCode.ERR_NonPublicAPIInRecord, thisEquals.Locations[0], thisEquals);
4478diagnostics.Add(ErrorCode.ERR_SignatureMismatchInRecord, thisEquals.Locations[0], thisEquals, targetMethod.ReturnType);
4493diagnostics.Add(ErrorCode.ERR_NotOverridableAPIInRecord, symbol.Locations[0], symbol);
4497diagnostics.Add(ErrorCode.ERR_StaticAPIInRecord, symbol.Locations[0], symbol);
4654diagnostics.Add(ErrorCode.ERR_NamespaceUnexpected,
4698diagnostics.Add(ErrorCode.ERR_NamespaceUnexpected,
4712diagnostics.Add(ErrorCode.ERR_NamespaceUnexpected,
4731diagnostics.Add(ErrorCode.ERR_NamespaceUnexpected,
4749diagnostics.Add(ErrorCode.ERR_NamespaceUnexpected,
4801ErrorCode.ERR_NamespaceUnexpected,
4854diagnostics.Add(ErrorCode.ERR_NamespaceUnexpected,
4874diagnostics.Add(ErrorCode.ERR_NamespaceUnexpected,
4891diagnostics.Add(ErrorCode.ERR_NamespaceUnexpected,
4906diagnostics.Add(ErrorCode.ERR_NamespaceUnexpected,
4967diagnostics.Add(ErrorCode.ERR_GlobalStatement, new SourceLocation(globalStatement));
Symbols\Source\SourceMemberContainerSymbol_ImplementationChecks.cs (57)
105diagnostics.Add(ErrorCode.ERR_UnimplementedAbstractMethod, this.Locations[0], this, abstractMember);
168Diagnostic diag = new CSDiagnostic(new CSDiagnosticInfo(ErrorCode.ERR_DuplicateExplicitImpl, interfaceMember), this.Locations[0]);
188ErrorCode.ERR_InterfaceImplementedImplicitlyByVariadic,
229var info = new CSDiagnosticInfo(ErrorCode.ERR_MixingWinRTEventWithRegular, args, ImmutableArray<Symbol>.Empty, ImmutableArray.Create<Location>(this.Locations[0]));
294diagnostics.Add(ErrorCode.ERR_UnimplementedInterfaceMember, GetImplementsLocationOrFallback(@interface), this, interfaceMember);
304diagnostics.Add(ErrorCode.WRN_NullabilityMismatchInInterfaceImplementedByBase, GetImplementsLocationOrFallback(@interface), this, interfaceMember);
565diagnostics.Add(ErrorCode.ERR_CantOverrideSealed, method.Locations[0], method, overridden);
716diagnostics.Add(ErrorCode.WRN_NewRequired, symbolLocation, symbol, hiddenMember);
724diagnostics.Add(ErrorCode.ERR_RequiredMemberCannotBeHidden, symbolLocation, hiddenMember, symbol);
736diagnostics.Add(ErrorCode.WRN_NewNotRequired, symbolLocation, symbol);
769ErrorCode errorCode =
770overridingMemberIsMethod ? ErrorCode.ERR_CantOverrideNonFunction :
771overridingMemberIsProperty ? ErrorCode.ERR_CantOverrideNonProperty :
772ErrorCode.ERR_CantOverrideNonEvent;
805diagnostics.Add(ErrorCode.ERR_OverrideNotExpected, overridingMemberLocation, overridingMember);
819diagnostics.Add(ErrorCode.ERR_NoGetToOverride, overridingMemberLocation, overridingMember, overriddenProperty);
823diagnostics.Add(ErrorCode.ERR_NoSetToOverride, overridingMemberLocation, overridingMember, overriddenProperty);
827diagnostics.Add(ErrorCode.ERR_OverrideNotExpected, overridingMemberLocation, overridingMember);
837diagnostics.Add(ErrorCode.ERR_AmbigOverride, overridingMemberLocation,
860diagnostics.Add(ErrorCode.WRN_MultipleRuntimeOverrideMatches, ambiguousMethod.Locations[0], ambiguousMethod, overridingMember);
887diagnostics.Add(ErrorCode.ERR_CantOverrideBogusMethod, overridingMemberLocation, overridingMember, overriddenMember);
894diagnostics.Add(ErrorCode.ERR_CantOverrideNonVirtual, overridingMemberLocation, overridingMember, overriddenMember);
900diagnostics.Add(ErrorCode.ERR_CantOverrideSealed, overridingMemberLocation, overridingMember, overriddenMember);
906diagnostics.Add(ErrorCode.ERR_CantChangeAccessOnOverride, overridingMemberLocation, overridingMember, accessibility, overriddenMember);
913diagnostics.Add(ErrorCode.ERR_CantChangeTupleNamesOnOverride, overridingMemberLocation, overridingMember, overriddenMember);
918diagnostics.Add(ErrorCode.ERR_OverrideMustHaveRequired, overridingMemberLocation, overridingMember, overriddenMember);
937ErrorCode code = overridingMemberIsObsolete
938? ErrorCode.WRN_ObsoleteOverridingNonObsolete
939: ErrorCode.WRN_NonObsoleteOverridingObsolete;
962diagnostics.Add(ErrorCode.ERR_CantChangeTypeOnOverride, overridingMemberLocation, overridingMember, overriddenMember, overriddenMemberType.Type);
970(diagnostics, overriddenEvent, overridingEvent, location) => diagnostics.Add(ErrorCode.WRN_NullabilityMismatchInTypeOnOverride, location),
989diagnostics.Add(ErrorCode.ERR_CantChangeRefReturnOnOverride, overridingMemberLocation, overridingMember, overriddenMember);
1002diagnostics.Add(ErrorCode.ERR_RuntimeDoesNotSupportCovariantReturnsOfClasses, overridingMemberLocation, overridingMember, overriddenMember, overriddenMethod.ReturnType);
1016diagnostics.Add(ErrorCode.ERR_CantChangeReturnTypeOnOverride, overridingMemberLocation, overridingMember, overriddenMember, overriddenMethod.ReturnType);
1022diagnostics.Add(ErrorCode.ERR_OverrideFinalizeDeprecated, overridingMemberLocation);
1057diagnostics.Add(ErrorCode.ERR_CantChangeRefReturnOnOverride, overridingMemberLocation, overridingProperty, overriddenProperty);
1074diagnostics.Add(ErrorCode.ERR_RuntimeDoesNotSupportCovariantPropertiesOfClasses, overridingMemberLocation, overridingMember, overriddenMember, overriddenMemberType.Type);
1086diagnostics.Add(ErrorCode.ERR_CantChangeTypeOnOverride, overridingMemberLocation, overridingMember, overriddenMember, overriddenMemberType.Type);
1127diagnostics.Add(ErrorCode.ERR_CantChangeInitOnlyOnOverride, overridingMemberLocation, overridingProperty, overriddenProperty);
1142diagnostics.Add(ErrorCode.ERR_NoGetToOverride, overridingMemberLocation, overridingProperty, overriddenProperty);
1148diagnostics.Add(ErrorCode.ERR_NoSetToOverride, overridingMemberLocation, overridingProperty, overriddenProperty);
1174ErrorCode.ERR_ScopedMismatchInParameterOfOverrideOrImplementation :
1175ErrorCode.WRN_ScopedMismatchInParameterOfOverrideOrImplementation,
1220ErrorCode.WRN_TopLevelNullabilityMismatchInReturnTypeOnOverride :
1221ErrorCode.WRN_NullabilityMismatchInReturnTypeOnOverride,
1227topLevel ? ErrorCode.WRN_TopLevelNullabilityMismatchInParameterTypeOnOverride : ErrorCode.WRN_NullabilityMismatchInParameterTypeOnOverride,
1254diagnostics.Add(ErrorCode.WRN_DoesNotReturnMismatch, overrideMethod.Locations[0], new FormattedSymbol(overrideMethod, SymbolDisplayFormat.MinimallyQualifiedFormat));
1540diagnostics.Add(ErrorCode.WRN_NewNotRequired, hidingMemberLocation, hidingMember);
1561diagnostics.Add(ErrorCode.WRN_NewOrOverrideExpected, hidingMemberLocation, hidingMember, hiddenMember);
1568diagnostics.Add(ErrorCode.ERR_RequiredMemberCannotBeHidden, hidingMemberLocation, hiddenMember, hidingMember);
1581diagnostics.Add(ErrorCode.WRN_NewRequired, hidingMemberLocation, hidingMember, hiddenMembers[0]);
1634diagnostics.Add(ErrorCode.ERR_HidingAbstractMethod, associatedPropertyOrEvent.Locations[0], associatedPropertyOrEvent, hiddenMember);
1649diagnostics.Add(ErrorCode.ERR_HidingAbstractMethod, hidingMemberLocation, hidingMember, hiddenMember);
1728diagnostics.Add(ErrorCode.ERR_UnifyingInterfaceInstantiations, this.Locations[0], this, interface1, interface2);
1753if (diagnostic.Severity == DiagnosticSeverity.Error && diagnostic.Code is not ((int)ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember or (int)ErrorCode.ERR_ImplicitImplementationOfInaccessibleInterfaceMember))
Symbols\Source\SourceMemberFieldSymbol.cs (25)
51diagnostics.Add(ErrorCode.ERR_FileTypeDisallowedInSignature, this.ErrorLocation, type, ContainingType);
56diagnostics.Add(ErrorCode.ERR_VarDeclIsStaticClass, this.ErrorLocation, type);
60diagnostics.Add(ErrorCode.ERR_FieldCantHaveVoidType, TypeSyntax?.Location ?? this.Locations[0]);
64diagnostics.Add(ErrorCode.ERR_FieldCantBeRefAny, TypeSyntax?.Location ?? this.Locations[0], type);
68diagnostics.Add(ErrorCode.ERR_FieldAutoPropCantBeByRefLike, TypeSyntax?.Location ?? this.Locations[0], type);
83diagnostics.Add(ErrorCode.ERR_BadConstType, constToken.GetLocation(), type);
88diagnostics.Add(ErrorCode.ERR_VolatileStruct, this.ErrorLocation, this, type);
95diagnostics.Add(ErrorCode.ERR_BadVisFieldType, this.ErrorLocation, this, type);
190diagnostics.Add(ErrorCode.ERR_AbstractField, errorLocation);
217diagnostics.Add(ErrorCode.ERR_StaticConstant, errorLocation, firstIdentifier.ValueText);
236diagnostics.Add(ErrorCode.ERR_BadMemberFlag, errorLocation, SyntaxFacts.GetText(SyntaxKind.RequiredKeyword));
262diagnostics.Add(ErrorCode.ERR_BadMemberFlag, errorLocation, ModifierUtils.ConvertSingleModifierToSyntaxText(modifier));
360diagnostics.Add(ErrorCode.ERR_RuntimeDoesNotSupportDefaultInterfaceImplementation, ErrorLocation);
365diagnostics.Add(ErrorCode.ERR_InterfacesCantContainFields, ErrorLocation);
452diagnostics.Add(ErrorCode.ERR_BadMemberFlag, ErrorLocation, SyntaxFacts.GetText(SyntaxKind.ScopedKeyword));
491diagnostics.Add(ErrorCode.ERR_RuntimeDoesNotSupportRefFields, ErrorLocation);
494diagnostics.Add(ErrorCode.ERR_RefFieldInNonRefStruct, ErrorLocation);
497diagnostics.Add(ErrorCode.ERR_RefFieldCannotReferToRefStruct, typeSyntax.SkipScoped(out _).Location);
511diagnosticsForFirstDeclarator.Add(ErrorCode.ERR_ImplicitlyTypedVariableCannotBeConst, typeSyntax.Location);
516diagnostics.Add(ErrorCode.ERR_RecursivelyTypedVariable, this.ErrorLocation, this);
521diagnosticsForFirstDeclarator.Add(ErrorCode.ERR_ImplicitlyTypedVariableMultipleDeclarator, typeSyntax.Location);
561diagnostics.Add(ErrorCode.ERR_FixedNotInStruct, ErrorLocation);
566diagnostics.Add(ErrorCode.ERR_FixedFieldMustNotBeRef, ErrorLocation);
574diagnostics.Add(ErrorCode.ERR_IllegalFixedType, loc);
579diagnosticsForFirstDeclarator.Add(ErrorCode.ERR_UnsafeNeeded, declarator.Location);
Symbols\Source\SourceMemberMethodSymbol.cs (11)
248ErrorCode code = (this.MethodKind == MethodKind.Conversion || this.MethodKind == MethodKind.UserDefinedOperator) ?
249ErrorCode.ERR_BadVisOpReturn :
250ErrorCode.ERR_BadVisReturnType;
260ErrorCode.ERR_BadVisOpParam :
261ErrorCode.ERR_BadVisParamType;
284diagnostics.Add(ErrorCode.ERR_FileTypeDisallowedInSignature, Locations[0], returnType.Type, ContainingType);
291diagnostics.Add(ErrorCode.ERR_FileTypeDisallowedInSignature, Locations[0], param.Type, ContainingType);
973diagnostics.Add(ErrorCode.ERR_ExternHasBody, location, this);
977diagnostics.Add(ErrorCode.ERR_AbstractHasBody, location, this);
995diagnostics.Add(ErrorCode.ERR_RuntimeDoesNotSupportDefaultInterfaceImplementation, location);
1000diagnostics.Add(ErrorCode.ERR_RuntimeDoesNotSupportStaticAbstractMembersInInterfaces, location);
Symbols\Source\SourceMethodSymbolWithAttributes.cs (32)
553diagnostics.Add(ErrorCode.ERR_SecurityCriticalOrSecuritySafeCriticalOnAsync, arguments.AttributeSyntaxOpt.Location, arguments.AttributeSyntaxOpt.GetErrorDisplayName());
591diagnostics.Add(ErrorCode.ERR_UnscopedRefAttributeUnsupportedMemberTarget, arguments.AttributeSyntaxOpt.Location);
640diagnostics.Add(ErrorCode.ERR_AttributeNotOnEventAccessor, arguments.AttributeSyntaxOpt.Name.Location, description.FullName, attributeUsage.GetValidTargetsErrorArgument());
662diagnostics.Add(ErrorCode.ERR_AttributeNotOnAccessor, node.Name.Location, node.GetErrorDisplayName(), attributeUsage.GetValidTargetsErrorArgument());
667diagnostics.Add(ErrorCode.ERR_ConditionalOnInterfaceMethod, node.Location);
672diagnostics.Add(ErrorCode.ERR_ConditionalOnOverride, node.Location, this);
677diagnostics.Add(ErrorCode.ERR_ConditionalOnSpecialMethod, node.Location, this);
682diagnostics.Add(ErrorCode.ERR_ConditionalMustReturnVoid, node.Location, this);
687diagnostics.Add(ErrorCode.ERR_ConditionalWithOutParam, node.Location, this);
691diagnostics.Add(ErrorCode.ERR_ConditionalOnLocalFunction, node.Location, this);
701diagnostics.Add(ErrorCode.ERR_BadArgumentToAttribute, attributeArgumentSyntax.Location, node.GetErrorDisplayName());
769diagnostics.Add(ErrorCode.ERR_DllImportOnInvalidMethod, arguments.AttributeSyntaxOpt.Name.Location);
785diagnostics.Add(ErrorCode.ERR_DllImportOnGenericMethod, arguments.AttributeSyntaxOpt.Name.Location);
794diagnostics.Add(ErrorCode.ERR_InvalidAttributeArgument, attributeArgumentSyntax.Location, arguments.AttributeSyntaxOpt.GetErrorDisplayName());
823diagnostics.Add(ErrorCode.ERR_InvalidNamedArgument, arguments.AttributeSyntaxOpt.ArgumentList.Arguments[position].Location, namedArg.Key);
890diagnostics.Add(ErrorCode.ERR_ModuleInitializerMethodMustBeOrdinary, arguments.AttributeSyntaxOpt.Location);
900diagnostics.Add(ErrorCode.ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType, arguments.AttributeSyntaxOpt.Location, Name);
908diagnostics.Add(ErrorCode.ERR_ModuleInitializerMethodMustBeStaticParameterlessVoid, arguments.AttributeSyntaxOpt.Location, Name);
914diagnostics.Add(ErrorCode.ERR_ModuleInitializerMethodAndContainingTypesMustNotBeGeneric, arguments.AttributeSyntaxOpt.Location, Name);
922diagnostics.Add(ErrorCode.ERR_ModuleInitializerCannotBeUnmanagedCallersOnly, arguments.AttributeSyntaxOpt.Location);
964diagnostics.Add(ErrorCode.ERR_CannotUseRefInUnmanagedCallersOnly, syntax.Location);
980diagnostics.Add(ErrorCode.ERR_CannotUseManagedTypeInUnmanagedCallersOnly, syntax.Location, type, (isParam ? MessageID.IDS_Parameter : MessageID.IDS_Return).Localize());
1039diagnostics.Add(ErrorCode.ERR_ComImportWithUserCtor, this.Locations[0]);
1048diagnostics.Add(ErrorCode.ERR_ComImportWithImpl, this.Locations[0], this, ContainingType);
1062var errorCode = (this.MethodKind == MethodKind.Constructor || this.MethodKind == MethodKind.StaticConstructor) ?
1063ErrorCode.WRN_ExternCtorNoImplementation :
1064ErrorCode.WRN_ExternMethodNoImplementation;
1100diagnostics.Add(ErrorCode.ERR_BadAsyncReturn, errorLocation);
1120diagnostics.Add(ErrorCode.ERR_SecurityCriticalOrSecuritySafeCriticalOnAsyncInClassOrStruct, errorLocation);
1129diagnostics.Add(ErrorCode.ERR_SynchronizedAsyncMethod, errorLocation);
1149diagnostics.Add(ErrorCode.WRN_UndecoratedCancellationTokenParameter, errorLocation, this);
1155diagnostics.Add(ErrorCode.ERR_MultipleEnumeratorCancellationAttributes, errorLocation);
Symbols\Source\SourceNamedTypeSymbol.cs (18)
196diagnostics.Add(ErrorCode.ERR_IllegalVarianceSyntax, tp.VarianceKeyword.GetLocation());
219diagnostics.Add(ErrorCode.ERR_DuplicateTypeParameter, location, name);
230diagnostics.Add(ErrorCode.WRN_TypeParameterSameAsOuterTypeParameter, location, name, tpEnclosing.ContainingType);
246ErrorCode.ERR_PartialWrongTypeParamsVariance,
254ErrorCode.ERR_PartialWrongTypeParams,
530diagnostics.Add(ErrorCode.ERR_PartialWrongConstraints, Locations[0], this, typeParameters[i]);
1119diagnostics.Add(ErrorCode.ERR_CantUseRequiredAttribute, arguments.AttributeSyntaxOpt.Name.Location);
1224diagnosticsOpt.Add(ErrorCode.ERR_AttributeUsageOnNonAttributeClass, node.Name.Location, node.GetErrorDisplayName());
1240diagnosticsOpt.Add(ErrorCode.ERR_InvalidAttributeArgument, attributeArgumentSyntax.Location, node.GetErrorDisplayName());
1294diagnostics.Add(ErrorCode.ERR_ConditionalOnNonAttributeClass, node.Location, node.GetErrorDisplayName());
1304diagnostics.Add(ErrorCode.ERR_BadArgumentToAttribute, attributeArgumentSyntax.Location, node.GetErrorDisplayName());
1482diagnostics.Add(ErrorCode.ERR_ComImportWithoutUuidAttribute, allAttributeSyntaxNodes[index].Name.Location);
1491diagnostics.Add(ErrorCode.ERR_ComImportWithBase, this.Locations[0], this.Name);
1504diagnostics.Add(ErrorCode.ERR_ComImportWithInitializers, singleInitializer.Syntax.GetLocation(), this.Name);
1518diagnostics.Add(ErrorCode.ERR_ComImportWithInitializers, singleInitializer.Syntax.GetLocation(), this.Name);
1530diagnostics.Add(ErrorCode.WRN_CoClassWithoutComImport, allAttributeSyntaxNodes[index].Location, this.Name);
1539diagnostics.Add(ErrorCode.ERR_DefaultMemberOnIndexedType, allAttributeSyntaxNodes[index].Name.Location);
1703diagnostics.Add(ErrorCode.WRN_ObsoleteMembersShouldNotBeRequired, member.Locations[0], member);
Symbols\Source\SourceNamedTypeSymbol_Bases.cs (29)
131diagnostics.Add(ErrorCode.ERR_BadRecordBase, baseLocation);
136diagnostics.Add(ErrorCode.ERR_BadInheritanceFromRecord, baseLocation);
192diagnostics.Add(ErrorCode.WRN_DuplicateInterfaceWithNullabilityMismatchInBaseList, location, @interface, this);
197diagnostics.Add(ErrorCode.ERR_DuplicateInterfaceWithTupleNamesInBaseList, location, @interface, other, this);
201diagnostics.Add(ErrorCode.ERR_DuplicateInterfaceWithDifferencesInBaseList, location, @interface, other, this);
340var info = diagnostics.Add(ErrorCode.ERR_PartialMultipleBases, Locations[0], this);
385diagnostics.Add(ErrorCode.ERR_StaticBaseClass, baseTypeLocation, baseType, this);
391diagnostics.Add(ErrorCode.ERR_BadVisBaseClass, baseTypeLocation, this, baseType);
396diagnostics.Add(ErrorCode.ERR_FileTypeBase, baseTypeLocation, baseType, this);
408diagnostics.Add(ErrorCode.ERR_BadVisBaseInterface, interfaceLocations[i], this, i);
413diagnostics.Add(ErrorCode.ERR_FileTypeBase, interfaceLocations[i], i, this);
461diagnostics.Add(ErrorCode.ERR_BadBaseType, typeSyntax.GetLocation());
489diagnostics.Add(ErrorCode.ERR_DeriveFromEnumOrValueType, location, this, baseType);
496diagnostics.Add(ErrorCode.ERR_CantDeriveFromSealedType, location, this, baseType);
530var info = diagnostics.Add(ErrorCode.ERR_StaticDerivedFromNonObject, location, this, localBase);
554diagnostics.Add(ErrorCode.ERR_DuplicateInterfaceInBaseList, location, baseType);
559diagnostics.Add(ErrorCode.WRN_DuplicateInterfaceWithNullabilityMismatchInBaseList, location, baseType, this);
566diagnostics.Add(ErrorCode.ERR_StaticClassInterfaceImpl, location, this);
572diagnostics.Add(ErrorCode.ERR_RefStructInterfaceImpl, location, this);
577diagnostics.Add(ErrorCode.ERR_DeriveFromConstructedDynamic, location, this, baseType);
589diagnostics.Add(ErrorCode.ERR_BaseClassMustBeFirst, location, baseType);
594diagnostics.Add(ErrorCode.ERR_NoMultipleInheritance, location, this, localBase, baseType);
601diagnostics.Add(ErrorCode.ERR_DerivingFromATyVar, location, baseType);
610diagnostics.Add(ErrorCode.ERR_DeriveFromDynamic, location, this);
617diagnostics.Add(ErrorCode.ERR_NonInterfaceInInterfaceList, location, baseType);
625diagnostics.Add(ErrorCode.ERR_ObjectCantHaveBases, new SourceLocation(name));
635diagnostics.Add(ErrorCode.ERR_UnexpectedArgumentList, primaryConstructorBaseType.ArgumentList.Location);
679diagnostics.Add(ErrorCode.ERR_CycleInInterfaceInheritance, Locations[0], this, t)));
757diagnostics.Add(ErrorCode.ERR_CircularBase, Locations[0], declaredBase, this));
Symbols\Source\SourceNamespaceSymbol.AliasesAndUsings.cs (19)
290diagnostics.Add(ErrorCode.ERR_DuplicateAlias, pair.Value.Alias.Locations[0], pair.Key);
323diagnostics.Add(ErrorCode.HDN_DuplicateWithGlobalUsing, namespaceOrType.UsingDirective!.NamespaceOrType.Location, namespaceOrType.NamespaceOrType);
359diagnostics.Add(ErrorCode.ERR_DuplicateAlias, externAlias.Alias.Locations[0], externAlias.Alias.Name);
471diagnostics.Add(ErrorCode.ERR_ExternAliasNotAllowed, aliasSyntax.Location);
481diagnostics.Add(ErrorCode.ERR_DuplicateAlias, existingAlias.Alias.Locations[0], existingAlias.Alias.Name);
488diagnostics.Add(ErrorCode.ERR_GlobalExternAlias, aliasSyntax.Identifier.GetLocation());
656diagnostics.Add(ErrorCode.WRN_GlobalAliasDefn, location);
661diagnostics.Add(ErrorCode.ERR_NoAliasHere, location);
677diagnostics.Add(ErrorCode.ERR_DuplicateAlias, location, identifierValueText);
688diagnostics.Add(ErrorCode.ERR_DuplicateAlias, usingDirective.Location, identifierValueText);
725diagnostics.Add(ErrorCode.ERR_BadUnsafeInUsingDirective, usingDirective.UnsafeKeyword.GetLocation());
740diagnostics.Add(ErrorCode.ERR_BadUsingType, usingDirective.NamespaceOrType.Location, imported);
745ErrorCode.HDN_DuplicateWithGlobalUsing :
746ErrorCode.WRN_DuplicateUsing,
758diagnostics.Add(ErrorCode.ERR_BadUsingNamespace, usingDirective.NamespaceOrType.Location, imported);
765diagnostics.Add(ErrorCode.ERR_GlobalUsingStaticFileType, usingDirective.NamespaceOrType.Location, imported);
771ErrorCode.HDN_DuplicateWithGlobalUsing :
772ErrorCode.WRN_DuplicateUsing,
788diagnostics.Add(ErrorCode.ERR_BadSKknown, usingDirective.NamespaceOrType.Location,
Symbols\Source\SourceOrdinaryMethodSymbol.cs (27)
161diagnostics.Add(ErrorCode.ERR_MethodReturnCantBeRefAny, syntax.ReturnType.Location, returnType.Type);
229diagnostics.Add(ErrorCode.ERR_BadTypeforThis, loc, parameter0Type.Type);
233diagnostics.Add(ErrorCode.ERR_RefExtensionMustBeValueTypeOrConstrainedToOne, location, Name);
237diagnostics.Add(ErrorCode.ERR_InExtensionMustBeValueType, location, Name);
241diagnostics.Add(ErrorCode.ERR_ExtensionMethodsDecl, location, ContainingType.Name);
250diagnostics.Add(ErrorCode.ERR_BadExtensionAgg, loc);
254diagnostics.Add(ErrorCode.ERR_BadExtensionMeth, location);
266ErrorCode.ERR_ExtensionAttrNotFound,
555diagnostics.Add(ErrorCode.ERR_IllegalVarianceSyntax, parameter.VarianceKeyword.GetLocation());
568diagnostics.Add(ErrorCode.ERR_DuplicateTypeParameter, location, name);
579diagnostics.Add(ErrorCode.WRN_TypeParameterSameAsOuterTypeParameter, location, name, tpEnclosing.ContainingType);
659diagnostics.Add(ErrorCode.ERR_PartialMethodReturnTypeDifference, implementation.Locations[0]);
664diagnostics.Add(ErrorCode.ERR_PartialMethodInconsistentTupleNames, implementation.Locations[0], definition, implementation);
669diagnostics.Add(ErrorCode.ERR_PartialMethodRefReturnDifference, implementation.Locations[0]);
674diagnostics.Add(ErrorCode.ERR_PartialMethodStaticDifference, implementation.Locations[0]);
679diagnostics.Add(ErrorCode.ERR_PartialMethodReadOnlyDifference, implementation.Locations[0]);
684diagnostics.Add(ErrorCode.ERR_PartialMethodExtensionDifference, implementation.Locations[0]);
689diagnostics.Add(ErrorCode.ERR_PartialMethodUnsafeDifference, implementation.Locations[0]);
694diagnostics.Add(ErrorCode.ERR_PartialMethodParamsDifference, implementation.Locations[0]);
700diagnostics.Add(ErrorCode.ERR_PartialMethodAccessibilityDifference, implementation.Locations[0]);
708diagnostics.Add(ErrorCode.ERR_PartialMethodExtendedModDifference, implementation.Locations[0]);
719diagnostics.Add(ErrorCode.ERR_ScopedMismatchInParameterOfPartial, implementingMethod.Locations[0], new FormattedSymbol(implementingParameter, SymbolDisplayFormat.ShortFormat));
736diagnostics.Add(ErrorCode.WRN_NullabilityMismatchInReturnTypeOnPartial, implementingMethod.Locations[0]);
740diagnostics.Add(ErrorCode.WRN_NullabilityMismatchInParameterTypeOnPartial, implementingMethod.Locations[0], new FormattedSymbol(implementingParameter, SymbolDisplayFormat.ShortFormat));
750diagnostics.Add(ErrorCode.WRN_PartialMethodTypeDifference, implementation.Locations[0],
788diagnostics.Add(ErrorCode.ERR_PartialMethodInconsistentConstraints, implementation.Locations[0], implementation, typeParameter2.Name);
792diagnostics.Add(ErrorCode.WRN_NullabilityMismatchInConstraintsOnPartialImplementation, implementation.Locations[0], implementation, typeParameter2.Name);
Symbols\Source\SourceOrdinaryMethodSymbolBase.cs (25)
93ErrorCode report;
100report = ErrorCode.ERR_OverrideRefConstraintNotSatisfied;
107report = ErrorCode.ERR_OverrideValConstraintNotSatisfied;
114report = ErrorCode.ERR_OverrideDefaultConstraintNotSatisfied;
333diagnostics.Add(ErrorCode.ERR_PartialMethodInvalidModifier, location);
337diagnostics.Add(ErrorCode.ERR_PartialMethodWithNonVoidReturnMustHaveAccessMods, location, this);
341diagnostics.Add(ErrorCode.ERR_PartialMethodWithExtendedModMustHaveAccessMods, location, this);
345diagnostics.Add(ErrorCode.ERR_PartialMethodWithOutParamMustHaveAccessMods, location, this);
349diagnostics.Add(ErrorCode.ERR_VirtualPrivate, location, this);
354diagnostics.Add(ErrorCode.ERR_OverrideNotNew, location, this);
359diagnostics.Add(ErrorCode.ERR_SealedNonOverride, location, this);
364diagnostics.Add(ErrorCode.ERR_BadMemberFlag, location, SyntaxFacts.GetText(SyntaxKind.SealedKeyword));
373diagnostics.Add(ErrorCode.ERR_AbstractAndExtern, location, this);
377diagnostics.Add(ErrorCode.ERR_AbstractAndSealed, location, this);
381diagnostics.Add(ErrorCode.ERR_AbstractNotVirtual, location, this.Kind.Localize(), this);
386diagnostics.Add(ErrorCode.ERR_BadMemberFlag, location, SyntaxFacts.GetText(SyntaxKind.AbstractKeyword));
391diagnostics.Add(ErrorCode.ERR_BadMemberFlag, location, SyntaxFacts.GetText(SyntaxKind.VirtualKeyword));
396diagnostics.Add(ErrorCode.ERR_StaticMemberCantBeReadOnly, location, this);
401diagnostics.Add(ErrorCode.ERR_AbstractInConcreteClass, location, this, ContainingType);
406diagnostics.Add(ErrorCode.ERR_NewVirtualInSealed, location, this, ContainingType);
410diagnostics.Add(ErrorCode.ERR_BadAsyncLacksBody, location);
414diagnostics.Add(ErrorCode.ERR_ConcreteMissingBody, location, this);
422diagnostics.Add(ErrorCode.ERR_InstanceMemberInStaticClass, location, Name);
426diagnostics.Add(ErrorCode.ERR_BadVarargs, location);
430diagnostics.Add(ErrorCode.ERR_VarargsAsync, location);
Symbols\Source\SourcePropertyAccessorSymbol.cs (8)
531diagnostics.Add(ErrorCode.ERR_AbstractInConcreteClass, location, this, ContainingType);
536diagnostics.Add(ErrorCode.ERR_NewVirtualInSealed, location, this, ContainingType);
540diagnostics.Add(ErrorCode.ERR_ConcreteMissingBody, location, this);
549diagnostics.Add(ErrorCode.ERR_InvalidPropertyReadOnlyMods, location, _property);
554diagnostics.Add(ErrorCode.ERR_StaticMemberCantBeReadOnly, location, this);
559diagnostics.Add(ErrorCode.ERR_InitCannotBeReadonly, location, _property);
564diagnostics.Add(ErrorCode.ERR_AutoSetterCantBeReadOnly, location, this);
569diagnostics.Add(ErrorCode.ERR_BadInitAccessor, location);
Symbols\Source\SourcePropertySymbol.cs (15)
194diagnostics.Add(ErrorCode.ERR_DuplicateAccessor, accessor.Keyword.GetLocation());
209diagnostics.Add(ErrorCode.ERR_DuplicateAccessor, accessor.Keyword.GetLocation());
214diagnostics.Add(ErrorCode.ERR_GetOrSetExpected, accessor.Keyword.GetLocation());
368diagnostics.Add(ErrorCode.ERR_BadMemberFlag, location, SyntaxFacts.GetText(SyntaxKind.RequiredKeyword));
459diagnostics.Add((this.IsIndexer ? ErrorCode.ERR_BadVisIndexerReturn : ErrorCode.ERR_BadVisPropertyType), Location, this, type.Type);
464diagnostics.Add(ErrorCode.ERR_FileTypeDisallowedInSignature, Location, type.Type, ContainingType);
473diagnostics.Add(ErrorCode.ERR_IndexerCantHaveVoidType, Location);
477diagnostics.Add(ErrorCode.ERR_PropertyCantHaveVoidType, Location, this);
494diagnostics.Add(ErrorCode.ERR_IndexerNeedsParam, parameterSyntaxOpt.GetLastToken().GetLocation());
507diagnostics.Add(ErrorCode.ERR_IllegalVarArgs, arglistToken.GetLocation());
518diagnostics.Add(ErrorCode.WRN_DefaultValueForUnconsumedLocation, paramNameToken.GetLocation(), paramNameToken.ValueText);
542diagnostics.Add(ErrorCode.ERR_BadVisIndexerParam, Location, this, param.Type);
546diagnostics.Add(ErrorCode.ERR_FileTypeDisallowedInSignature, Location, param.Type, this.ContainingType);
550diagnostics.Add(ErrorCode.ERR_DuplicateGeneratedName, param.Locations.FirstOrDefault() ?? Location, param.Name);
Symbols\Source\SourcePropertySymbolBase.cs (38)
274diagnostics.Add(ErrorCode.ERR_InstancePropertyInitializerInInterface, location);
278diagnostics.Add(ErrorCode.ERR_InitializerOnNonAutoProperty, location);
673diagnostics.Add(ErrorCode.ERR_RefReturningPropertiesCannotBeRequired, Location);
684diagnostics.Add(ErrorCode.ERR_AutoPropsInRoStruct, Location);
688diagnostics.Add(ErrorCode.ERR_AutoPropertyWithSetterCantBeReadOnly, Location, this);
698diagnostics.Add(ErrorCode.ERR_AutoPropertyCannotBeRefReturning, Location);
704diagnostics.Add(ErrorCode.ERR_AutoPropertyMustOverrideSet, Location);
720diagnostics.Add(ErrorCode.ERR_RefPropertyCannotHaveSetAccessor, _setMethod.Locations[0]);
726diagnostics.Add(ErrorCode.ERR_DuplicatePropertyAccessMods, Location, this);
730diagnostics.Add(ErrorCode.ERR_DuplicatePropertyReadOnlyMods, Location, this);
743diagnostics.Add(ErrorCode.ERR_PropertyWithNoAccessors, Location, this);
749diagnostics.Add(ErrorCode.ERR_RefPropertyMustHaveGetAccessor, Location);
754diagnostics.Add(ErrorCode.ERR_AutoPropertyMustHaveGetAccessor, _setMethod!.Locations[0]);
765diagnostics.Add(ErrorCode.ERR_AccessModMissingAccessor, Location, this);
771diagnostics.Add(ErrorCode.ERR_ReadOnlyModMissingAccessor, Location, this);
853diagnostics.Add(ErrorCode.ERR_VirtualPrivate, location, this);
858diagnostics.Add(ErrorCode.ERR_StaticMemberCantBeReadOnly, location, this);
863diagnostics.Add(ErrorCode.ERR_OverrideNotNew, location, this);
868diagnostics.Add(ErrorCode.ERR_SealedNonOverride, location, this);
873diagnostics.Add(ErrorCode.ERR_BadMemberFlag, location, SyntaxFacts.GetText(SyntaxKind.AbstractKeyword));
878diagnostics.Add(ErrorCode.ERR_BadMemberFlag, location, SyntaxFacts.GetText(SyntaxKind.VirtualKeyword));
882diagnostics.Add(ErrorCode.ERR_AbstractAndExtern, location, this);
886diagnostics.Add(ErrorCode.ERR_AbstractAndSealed, location, this);
890diagnostics.Add(ErrorCode.ERR_AbstractNotVirtual, location, this.Kind.Localize(), this);
898ErrorCode errorCode = isIndexer ? ErrorCode.ERR_IndexerInStaticClass : ErrorCode.ERR_InstanceMemberInStaticClass;
908diagnostics.Add(ErrorCode.ERR_InvalidPropertyAccessMod, accessor.Locations[0], accessor, this);
930diagnostics.Add(ErrorCode.ERR_PrivateAbstractAccessor, accessor.Locations[0], accessor);
949diagnostics.Add(ErrorCode.ERR_ExplicitPropertyMissingAccessor, this.Location, this, otherAccessor);
953diagnostics.Add(ErrorCode.ERR_ExplicitPropertyAddingAccessor, thisAccessor.Locations[0], thisAccessor, explicitlyImplementedProperty);
958diagnostics.Add(ErrorCode.ERR_ExplicitPropertyMismatchInitOnly, thisAccessor.Locations[0], thisAccessor, otherAccessor);
1267diagnostics.Add(ErrorCode.ERR_ExplicitDynamicAttr, arguments.AttributeSyntaxOpt.Location);
1314diagnostics.Add(ErrorCode.ERR_UnscopedRefAttributeUnsupportedMemberTarget, arguments.AttributeSyntaxOpt.Location);
1410diagnostics.Add(ErrorCode.ERR_BadIndexerNameAttr, node.Name.Location, node.GetErrorDisplayName());
1417diagnostics.Add(ErrorCode.ERR_BadArgumentToAttribute, node.ArgumentList.Arguments[0].Location, node.GetErrorDisplayName());
1528diagnostics.Add(ErrorCode.ERR_FieldCantBeRefAny, TypeLocation, type);
1532diagnostics.Add(ErrorCode.ERR_FieldAutoPropCantBeByRefLike, TypeLocation, type);
Symbols\Source\SourceUserDefinedOperatorSymbolBase.cs (36)
56diagnostics.Add(ErrorCode.ERR_InterfacesCantContainConversionOrEqualityOperators, this.Locations[0]);
66diagnostics.Add(ErrorCode.ERR_OperatorInStaticClass, location, this);
76diagnostics.Add(ErrorCode.ERR_ExplicitImplementationOfOperatorsMustBeStatic, this.Locations[0], this);
82diagnostics.Add(ErrorCode.ERR_OperatorsMustBeStatic, this.Locations[0], this);
91diagnostics.Add(ErrorCode.ERR_AbstractAndExtern, location, this);
95diagnostics.Add(ErrorCode.ERR_AbstractNotVirtual, location, this.Kind.Localize(), this);
102diagnostics.Add(ErrorCode.ERR_ExternHasBody, location, this);
106diagnostics.Add(ErrorCode.ERR_AbstractHasBody, location, this);
114diagnostics.Add(ErrorCode.ERR_ConcreteMissingBody, location, this);
162diagnostics.Add(ErrorCode.ERR_BadMemberFlag, location, ModifierUtils.ConvertSingleModifierToSyntaxText(DeclarationModifiers.Sealed));
208diagnostics.Add(ErrorCode.ERR_InvalidModifierForLanguageVersion, location,
243diagnostics.Add(ErrorCode.ERR_IllegalVarArgs, new SourceLocation(arglistToken));
256diagnostics.Add(ErrorCode.ERR_MethodReturnCantBeRefAny, returnTypeSyntax.Location, returnType.Type);
333diagnostics.Add(ErrorCode.ERR_IllegalRefParam, this.Locations[0]);
453diagnostics.Add(ErrorCode.ERR_ConversionWithInterface, this.Locations[0], this);
467diagnostics.Add(IsAbstract || IsVirtual ? ErrorCode.ERR_AbstractConversionNotInvolvingContainedType : ErrorCode.ERR_ConversionNotInvolvingContainedType, this.Locations[0]);
478diagnostics.Add(ErrorCode.ERR_IdentityConversion, this.Locations[0]);
546diagnostics.Add(ErrorCode.ERR_BadDynamicConversion, this.Locations[0], this);
574diagnostics.Add(ErrorCode.ERR_ConversionWithBase, this.Locations[0], this);
579diagnostics.Add(ErrorCode.ERR_ConversionWithDerived, this.Locations[0], this);
591diagnostics.Add(ErrorCode.ERR_OperatorCantReturnVoid, this.Locations[0]);
603diagnostics.Add((IsAbstract || IsVirtual) ? ErrorCode.ERR_BadAbstractUnaryOperatorSignature : ErrorCode.ERR_BadUnaryOperatorSignature, this.Locations[0]);
617diagnostics.Add(ErrorCode.ERR_OpTFRetType, this.Locations[0]);
623diagnostics.Add((IsAbstract || IsVirtual) ? ErrorCode.ERR_BadAbstractUnaryOperatorSignature : ErrorCode.ERR_BadUnaryOperatorSignature, this.Locations[0]);
673diagnostics.Add((IsAbstract || IsVirtual) ? ErrorCode.ERR_BadAbstractIncDecSignature : ErrorCode.ERR_BadIncDecSignature, this.Locations[0]);
682diagnostics.Add((IsAbstract || IsVirtual) ? ErrorCode.ERR_BadAbstractIncDecRetType : ErrorCode.ERR_BadIncDecRetType, this.Locations[0]);
722diagnostics.Add((IsAbstract || IsVirtual) ? ErrorCode.ERR_BadAbstractShiftOperatorSignature : ErrorCode.ERR_BadShiftOperatorSignature, this.Locations[0]);
741diagnostics.Add((IsAbstract || IsVirtual) ? ErrorCode.ERR_BadAbstractBinaryOperatorSignature : ErrorCode.ERR_BadBinaryOperatorSignature, this.Locations[0]);
752diagnostics.Add(ErrorCode.ERR_BadAbstractEqualityOperatorSignature, this.Locations[0], this.ContainingType);
Symbols\Symbol.cs (15)
1040if (info.Code == (int)ErrorCode.WRN_UnifyReferenceBldRev ||
1041info.Code == (int)ErrorCode.WRN_UnifyReferenceMajMin ||
1042info.Code == (int)ErrorCode.ERR_AssemblyMatchBadVersion)
1062if (info.DiagnosticInfo?.Code == (int)ErrorCode.ERR_BogusType)
1078info = info.AdjustDiagnosticInfo(new CSDiagnosticInfo(ErrorCode.ERR_BindToBogus, this));
1085var useSiteInfo = new UseSiteInfo<AssemblySymbol>(new CSDiagnosticInfo(ErrorCode.ERR_BogusType, string.Empty));
1349ErrorCode.ERR_ConstraintOnlyAllowedOnGenericDecl,
1362diagnostics.Add(ErrorCode.ERR_BlockBodyAndExpressionBody, syntax.GetLocation());
1393diagnostics.Add(ErrorCode.ERR_ExplicitDynamicAttr, arguments.AttributeSyntaxOpt.Location);
1410diagnostics.Add(ErrorCode.ERR_ExplicitTupleElementNamesAttribute, arguments.AttributeSyntaxOpt.Location);
1416diagnostics.Add(ErrorCode.ERR_ExplicitNullableAttribute, arguments.AttributeSyntaxOpt.Location);
1434diagnostics.Add(ErrorCode.ERR_ExplicitExtension, arguments.AttributeSyntaxOpt.Location);
1440diagnostics.Add(ErrorCode.ERR_ExplicitRequiredMember, arguments.AttributeSyntaxOpt.Location);
1446diagnostics.Add(ErrorCode.ERR_ExplicitScopedRef, arguments.AttributeSyntaxOpt.Location);
1463diagnostics.Add(ErrorCode.ERR_ExplicitReservedAttr, arguments.AttributeSyntaxOpt.Location, attributeDescription.FullName);
Symbols\Symbol_Attributes.cs (8)
221arguments.Diagnostics.DiagnosticBag.Add(ErrorCode.ERR_ExplicitReservedAttr, arguments.AttributeSyntaxOpt.Location, AttributeDescription.CompilerFeatureRequiredAttribute.FullName);
677diagnostics.Add(ErrorCode.WRN_NonECMAFeature, targetOpt.GetLocation(), MessageID.IDS_FeatureModuleAttrLoc);
689diagnostics.Add(ErrorCode.WRN_InvalidAttributeLocation,
708diagnostics.Add(ErrorCode.ERR_GlobalAttributesNotAllowed, targetOpt.Identifier.GetLocation());
718diagnostics.Add(ErrorCode.WRN_AttributeLocationOnBadDeclaration,
881diagnostics.Add(ErrorCode.ERR_DuplicateAttribute, node.Name.Location, node.GetErrorDisplayName());
901diagnostics.Add(ErrorCode.ERR_AttributeOnBadSymbolType, node.Name.Location, node.GetErrorDisplayName(), attributeUsageInfo.GetValidTargetsErrorArgument());
916diagnostics.Add(ErrorCode.ERR_SecurityAttributeInvalidTarget, node.Name.Location, node.GetErrorDisplayName());
Symbols\TypeSymbol.cs (43)
518=> code is (int)ErrorCode.ERR_UnsupportedCompilerFeature or (int)ErrorCode.ERR_BogusType;
525return (object)info != null && info.Code is (int)ErrorCode.ERR_UnsupportedCompilerFeature or (int)ErrorCode.ERR_BogusType;
854diagnostics.Add(ErrorCode.ERR_DuplicateExplicitImpl, implementingType.Locations[0], interfaceMember);
1008diagnostics.Add(ErrorCode.ERR_ImplicitImplementationOfInaccessibleInterfaceMember, GetImplicitImplementationDiagnosticLocation(interfaceMember, implementingType, implicitImpl), implementingType, interfaceMember, implicitImpl);
1017diagnostics.Add(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, GetImplicitImplementationDiagnosticLocation(interfaceMember, implementingType, implicitImpl),
1069diagnostics.Add(ErrorCode.ERR_MostSpecificImplementationIsNotFound, GetInterfaceLocation(interfaceMember, implementingType),
1095return !symbolAndDiagnostics.Diagnostics.Diagnostics.Any(static d => d.Code == (int)ErrorCode.ERR_MostSpecificImplementationIsNotFound);
1632diagnostics.Add(ErrorCode.ERR_LanguageVersionDoesNotSupportInterfaceImplementationForMember,
1645ErrorCode.ERR_RuntimeDoesNotSupportStaticAbstractMembersInInterfacesForMember :
1646ErrorCode.ERR_RuntimeDoesNotSupportDefaultInterfaceImplementationForMember,
1669diagnostics.Add(ErrorCode.ERR_MethodImplementingAccessor, GetImplicitImplementationDiagnosticLocation(interfaceMember, implementingType, implicitImpl), implicitImpl, interfaceMethod, implementingType);
1673diagnostics.Add(ErrorCode.ERR_AccessorImplementingMethod, GetImplicitImplementationDiagnosticLocation(interfaceMember, implementingType, implicitImpl), implicitImpl, interfaceMethod, implementingType);
1682diagnostics.Add(ErrorCode.ERR_InterfaceImplementedByConditional, GetImplicitImplementationDiagnosticLocation(interfaceMember, implementingType, implicitImpl), implicitImpl, interfaceMethod, implementingType);
1686diagnostics.Add(ErrorCode.ERR_InterfaceImplementedByUnmanagedCallersOnlyMethod, GetImplicitImplementationDiagnosticLocation(interfaceMember, implementingType, implicitImpl), implicitImpl, interfaceMethod, implementingType);
1698diagnostics.Add(ErrorCode.ERR_ImplBadTupleNames, GetImplicitImplementationDiagnosticLocation(interfaceMember, implementingType, implicitImpl), implicitImpl, interfaceMember);
1721diagnostics.Add(ErrorCode.WRN_MultipleRuntimeImplementationMatches, GetImplicitImplementationDiagnosticLocation(interfaceMember, implementingType, member), member, interfaceMember, implementingType);
1732diagnostics.Add(ErrorCode.ERR_LanguageVersionDoesNotSupportInterfaceImplementationForMember,
1742diagnostics.Add(ErrorCode.ERR_RuntimeDoesNotSupportStaticAbstractMembersInInterfacesForMember,
1764diagnostics.Add(ErrorCode.WRN_NullabilityMismatchInTypeOnExplicitImplementation,
1769diagnostics.Add(ErrorCode.WRN_NullabilityMismatchInTypeOnImplicitImplementation,
1796ErrorCode.WRN_TopLevelNullabilityMismatchInReturnTypeOnExplicitImplementation :
1797ErrorCode.WRN_NullabilityMismatchInReturnTypeOnExplicitImplementation,
1803ErrorCode.WRN_TopLevelNullabilityMismatchInReturnTypeOnImplicitImplementation :
1804ErrorCode.WRN_NullabilityMismatchInReturnTypeOnImplicitImplementation,
1817ErrorCode.WRN_TopLevelNullabilityMismatchInParameterTypeOnExplicitImplementation :
1818ErrorCode.WRN_NullabilityMismatchInParameterTypeOnExplicitImplementation,
1826ErrorCode.WRN_TopLevelNullabilityMismatchInParameterTypeOnImplicitImplementation :
1827ErrorCode.WRN_NullabilityMismatchInParameterTypeOnImplicitImplementation,
1856ErrorCode.ERR_ScopedMismatchInParameterOfOverrideOrImplementation :
1857ErrorCode.WRN_ScopedMismatchInParameterOfOverrideOrImplementation,
1869ErrorCode.ERR_UnscopedRefAttributeInterfaceImplementation,
1946diagnostics.Add(closestMismatch.IsStatic ? ErrorCode.ERR_CloseUnimplementedInterfaceMemberStatic : ErrorCode.ERR_CloseUnimplementedInterfaceMemberNotStatic,
1951ErrorCode errorCode = interfaceMember.IsAccessor() ? ErrorCode.ERR_UnimplementedInterfaceAccessor : ErrorCode.ERR_CloseUnimplementedInterfaceMemberNotPublic;
1956diagnostics.Add(ErrorCode.ERR_CloseUnimplementedInterfaceMemberWrongInitOnly, interfaceLocation, implementingType, interfaceMember, closestMismatch);
2002diagnostics.Add(ErrorCode.ERR_CloseUnimplementedInterfaceMemberWrongRefReturn, interfaceLocation, implementingType, interfaceMember, closestMismatch);
2006diagnostics.Add(ErrorCode.ERR_CloseUnimplementedInterfaceMemberWrongReturnType, interfaceLocation, implementingType, interfaceMember, closestMismatch, interfaceMemberReturnType);
2075diagnostics.Add(ErrorCode.ERR_ImplBadConstraints, GetImplicitImplementationDiagnosticLocation(interfaceMethod, implementingType, implicitImpl), typeParameter2.Name, implicitImpl, typeParameter1.Name, interfaceMethod);
2079diagnostics.Add(ErrorCode.WRN_NullabilityMismatchInConstraintsOnImplicitImplementation, GetImplicitImplementationDiagnosticLocation(interfaceMethod, implementingType, implicitImpl),
Symbols\VarianceSafety.cs (3)
92diagnostics.Add(ErrorCode.ERR_VarianceInterfaceNesting, member.Locations[0]);
474diagnostics.Add(ErrorCode.ERR_UnexpectedVarianceStaticMember, location, context, unsafeTypeParameter, actualVariance.Localize(), expectedVariance.Localize(),
479diagnostics.Add(ErrorCode.ERR_UnexpectedVariance, location, context, unsafeTypeParameter, actualVariance.Localize(), expectedVariance.Localize());
Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator.ExpressionCompiler.UnitTests (27)