Skip to main content

Code Fixes for Compiler Diagnostics

IdTitle
CS0019Operator 'operator' cannot be applied to operands of type 'type' and 'type'.
CS0021Cannot apply indexing with [] to an expression of type 'type'.
CS0023Operator 'operator' cannot be applied to operand of type 'type'.
CS0029Cannot implicitly convert type 'type' to 'type'.
CS0030Cannot convert type 'type' to 'type'.
CS0037Cannot convert null to 'type' because it is a non-nullable value type.
CS0069An event in an interface cannot have add or remove accessors.
CS0077The as operator must be used with a reference type or nullable type ('type' is a non-nullable value type).
CS0080Constraints are not allowed on non-generic declarations.
CS0101The namespace 'namespace' already contains a definition for 'type'.
CS0102The type 'type name' already contains a definition for 'identifier'.
CS0103The name 'identifier' does not exist in the current context.
CS0107More than one protection modifier.
CS0109The member 'member' does not hide an inherited member. The new keyword is not required.
CS0112A static member 'function' cannot be marked as override, virtual or abstract.
CS0114'function1' hides inherited member 'function2'. To make the current method override that implementation, add the override keyword. Otherwise add the new keyword.
CS0115'function': no suitable method found to override.
CS0119'identifier' is a 'construct', which is not valid in the given context.
CS0120An object reference is required for the nonstatic field, method, or property 'member'.
CS0123No overload for 'method' matches delegate 'delegate'.
CS0126An object of a type convertible to 'type' is required.
CS0127Since 'function' returns void, a return keyword must not be followed by an object expression.
CS0128A local variable named 'variable' is already defined in this scope.
CS0131The left-hand side of an assignment must be a variable, property or indexer.
CS0132'constructor': a static constructor must be parameterless.
CS0133The expression being assigned to 'variable' must be constant.
CS0136A local variable named 'var' cannot be declared in this scope because it would give a different meaning to 'var', which is already used in a 'parent or current/child' scope to denote something else.
CS0139No enclosing loop out of which to break or continue.
CS0152The switch statement contains multiple cases with same label value.
CS0161'method': not all code paths return a value.
CS0162Unreachable code detected.
CS0163Control cannot fall through from one case label ('label') to another.
CS0164This label has not been referenced.
CS0165Use of unassigned local variable 'name'.
CS0168The variable 'var' is declared but never used.
CS0173Type of conditional expression cannot be determined because there is no implicit conversion between 'class1' and 'class2'.
CS0177The out parameter 'parameter' must be assigned to before control leaves the current method.
CS0191A readonly field cannot be assigned to (except in a constructor or a variable initializer).
CS0192Readonly field 'name' cannot be used as ref or out value (except in a constructor).
CS0201Only assignment, call, increment, decrement, and new object expressions can be used as a statement.
CS0214Pointers and fixed size buffers may only be used in an unsafe context.
CS0216The operator 'operator' requires a matching operator 'missing_operator' to also be defined.
CS0219The variable 'variable' is assigned but its value is never used.
CS0221Constant value 'value' cannot be converted to a 'type' (use 'unchecked' syntax to override).
CS0225The params parameter must be a single dimensional array.
CS0238'identifier' cannot be sealed because it is not an override.
CS0246The type or namespace name 'type/namespace' could not be found (are you missing a using directive or an assembly reference?).
CS0260Missing partial modifier on declaration of type 'type'; another partial declaration of this type exists.
CS0262Partial declarations of 'type' have conflicting accessibility modifiers.
CS0266Cannot implicitly convert type 'type1' to 'type2'. An explicit conversion exists (are you missing a cast?).
CS0267The partial modifier can only appear immediately before 'class', 'struct', or 'interface'.
CS0275'accessor': accessibility modifiers may not be used on accessors in an interface.
CS0305Using the generic type 'generic type' requires 'number' type arguments.
CS0401The new() constraint must be the last constraint specified.
CS0403Cannot convert null to type parameter 'name' because it could be a non-nullable value type. Consider using default('T') instead.
CS0405Duplicate constraint 'constraint' for type parameter 'type parameter'.
CS0407'return-type method' has the wrong return type.
CS0409A constraint clause has already been specified for type parameter 'type parameter'. All of the constraints for a type parameter must be specified in a single where clause.
CS0428Cannot convert method group 'identifier' to non-delegate type 'type'. Did you intend to invoke the method?
CS0441'class': a class cannot be both static and sealed.
CS0442'property': abstract properties cannot have private accessors.
CS0449The 'class' or 'struct' constraint must come before any other constraints.
CS0450'type parameter name': cannot specify both a constraint class and the 'class' or 'struct' constraint.
CS0451The 'new()' constraint cannot be used with the 'struct' constraint.
CS0472The result of the expression is always 'value1' since a value of type 'value2' is never equal to 'null' of type 'value3'.
CS0500'class member' cannot declare a body because it is marked abstract.
CS0501'member function' must declare a body because it is not marked abstract, extern, or partial.
CS0507'function1': cannot change access modifiers when overriding 'access' inherited member 'function2'.
CS0508'type1': return type must be 'type2' to match overridden member 'member name'.
CS0513'function' is abstract but it is contained in nonabstract class 'class'.
CS0515'function': access modifiers are not allowed on static constructors.
CS0525Interfaces cannot contain fields.
CS0527Type 'type' in interface list is not an interface.
CS0531'member': interface members cannot have a definition.
CS0539'member' in explicit interface declaration is not a member of interface
CS0541'declaration': explicit interface declaration can only be declared in a class or struct.
CS0549New virtual member in sealed class.
CS0558User-defined operator 'operator' must be declared static and public.
CS0567Interfaces cannot contain operators.
CS0568Structs cannot contain explicit parameterless constructors.
CS0573'field declaration': cannot have instance field initializers in structs.
CS0574Name of destructor must match name of class.
CS0575Only class types can contain destructors.
CS0579Duplicate 'attribute' attribute.
CS0592Attribute 'attribute' is not valid on this declaration type. It is valid on 'type' declarations only.
CS0621'member': virtual or abstract members cannot be private.
CS0628member' : new protected member declared in sealed class.
CS0659'class' overrides Object.Equals(object o) but does not override Object.GetHashCode().
CS0660'class' defines operator == or operator != but does not override Object.Equals(object o).
CS0661'class' defines operator == or operator != but does not override Object.GetHashCode().
CS0678'variable': a field can not be both volatile and readonly.
CS0693Type parameter 'type parameter' has the same name as the type parameter from outer type 'type'.
CS0708'field': cannot declare instance members in a static class.
CS0710Static classes cannot have instance constructors
CS0713Static class 'static type' cannot derive from type 'type'. Static classes must derive from object.
CS0714Static class cannot implement interfaces.
CS0718'type': static types cannot be used as type arguments.
CS0750A partial method cannot have access modifiers or the virtual, abstract, override, new, sealed, or extern modifiers.
CS0751A partial method must be declared in a partial class or partial struct.
CS0753Only methods, classes, structs, or interfaces may be partial.
CS0756A partial method may not have multiple defining declarations.
CS0759No defining declaration found for implementing declaration of partial method 'method'.
CS0766Partial methods must have a void return type.
CS0815Cannot assign 'expression' to an implicitly typed local.
CS0819Implicitly typed locals cannot have multiple declarators.
CS0822Implicitly typed locals cannot be const.
CS1003Syntax error, 'char' expected.
CS1004Duplicate 'modifier' modifier.
CS1012Too many characters in character literal.
CS1023Embedded statement cannot be a declaration or labeled statement.
CS1031Type expected.
CS1057'member': static classes cannot contain protected members.
CS1061'type' does not contain a definition for 'member' and no extension method 'name' accepting a first argument of type 'type' could be found (are you missing a using directive or an assembly reference?).
CS1100Method 'name' has a parameter modifier 'this' which is not on the first parameter.
CS1105Extension methods must be static.
CS1106Extension methods must be defined in a non-generic static class.
CS1503Argument 'number' cannot convert from 'type1' to 'type2'.
CS1522Empty switch block.
CS1526A new expression requires (), [], or {} after type.
CS1527Elements defined in a namespace cannot be explicitly declared as private, protected, protected internal or private protected.
CS1591Missing XML comment for publicly visible type or member 'name'.
CS1597Semicolon after method or accessor block is not valid.
CS1609Modifiers cannot be placed on event accessor declarations.
CS1615Argument 'number' should not be passed with the 'keyword' keyword.
CS1620Argument 'number' must be passed with the 'keyword' keyword.
CS1621The yield statement cannot be used inside an anonymous method or lambda expression.
CS1622Cannot return a value from an iterator. Use the yield return statement to return a value, or yield break to end the iteration.
CS1623Iterators cannot have ref or out parameters.
CS1624The body of 'identifier' cannot be an iterator block because 'type' is not an iterator interface type.
CS1643Not all code paths return a value in method of type 'type'.
CS1674'T': type used in a using statement must be implicitly convertible to 'System.IDisposable'.
CS1689Attribute 'attribute' is only valid on methods or attribute classes.
CS1715'type1': type must be 'type2' to match overridden member 'member'.
CS1717Assignment made to same variable; did you mean to assign something else?
CS1722Base class 'class' must come before any interfaces.
CS1737Optional parameters must appear after all required parameters.
CS1741A ref or out parameter cannot have a default value.
CS1743Cannot specify a default value for the 'this' parameter.
CS1750A value of type 'type1' cannot be used as a default parameter because there are no standard conversions to type 'type2.
CS1751Cannot specify a default value for a parameter array.
CS1955Non-invocable member 'name' cannot be used like a method.
CS1983The return type of an async method must be void, Task or Task\<T>.
CS1988Async methods cannot have ref or out parameters.
CS1994The 'async' modifier can only be used in methods that have a body.
CS1997Since 'RemoveReturnKeywordOrReturnExpression.FooAsync()' is an async method that returns 'Task', a return keyword must not be followed by an object expression. Did you intend to return 'Task\<T>>'?
CS3000Methods with variable arguments are not CLS-compliant.
CS3001Argument type 'type' is not CLS-compliant.
CS3002Return type of 'method' is not CLS-compliant.
CS3003Type of 'variable' is not CLS-compliant.
CS3005Identifier 'identifier' differing only in case is not CLS-compliant.
CS3006Overloaded method 'method' differing only in ref or out, or in array rank, is not CLS-compliant.
CS3007Overloaded method 'method' differing only by unnamed array types is not CLS-compliant.
CS3008Identifier 'identifier' is not CLS-compliant.
CS3009Base type 'type' is not CLS-compliant.
CS3016Arrays as attribute arguments is not CLS-compliant.
CS3024Constraint type 'type' is not CLS-compliant.
CS3027'type_1' is not CLS-compliant because base interface 'type_2' is not CLS-compliant.
CS7036There is no argument given that corresponds to the required formal parameter 'parameter' of 'member'.
CS8050Only auto-implemented properties can have initializers.
CS8070Control cannot fall out of switch from final case label ('default').
CS8112'function' is a local function and must therefore always have a body.
CS8139Cannot change tuple element names when overriding inherited member.
CS8340Instance fields of read-only structs must be read-only.
CS8403Method with an iterator block must be 'async' to return 'IAsyncEnumerable\<T>'.
CS8600Converting null literal or possible null value to non-nullable type.
CS8602Dereference of a possibly null reference.
CS8604Possible null reference argument for parameter.
CS8610Nullability of reference types in type of parameter doesn't match overridden member.
CS8618Non-nullable member is uninitialized. Consider declaring the member as nullable.
CS8625Cannot convert null literal to non-nullable reference type.
CS8632The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
CS8765Nullability of type of parameter doesn't match overridden member.
CS8767Nullability of reference types in type of parameter doesn't match implicitly implemented member.