提交 5142d3a5 编写于 作者: J Julien 提交者: GitHub

Compacting C# 7 error codes (#12884)

上级 7925946b
......@@ -15,7 +15,7 @@ internal enum ErrorCode
//ERR_MissingOptionArg = 5,
ERR_NoMetadataFile = 6,
//FTL_ComPlusInit = 7,
//FTL_MetadataImportFailure = 8, no longer used in Roslyn.
//FTL_MetadataImportFailure = 8, no longer used in Roslyn.
FTL_MetadataCantOpenFile = 9,
//ERR_FatalError = 10,
//ERR_CantImportBase = 11,
......@@ -123,7 +123,7 @@ internal enum ErrorCode
ERR_ConstantExpected = 150,
// ERR_V6SwitchGoverningTypeValueExpected shares the same error code (CS0151) with ERR_IntegralTypeValueExpected in Dev10 compiler.
// However ERR_IntegralTypeValueExpected is currently unused and hence being removed. If we need to generate this error in future
// we can use error code CS0166. CS0166 was originally reserved for ERR_SwitchFallInto in Dev10, but was never used.
// we can use error code CS0166. CS0166 was originally reserved for ERR_SwitchFallInto in Dev10, but was never used.
ERR_V6SwitchGoverningTypeValueExpected = 151,
ERR_DuplicateCaseLabel = 152,
ERR_InvalidGotoCase = 153,
......@@ -1293,8 +1293,6 @@ internal enum ErrorCode
ERR_BlockBodyAndExpressionBody = 8057,
ERR_FeatureIsExperimental = 8058,
ERR_FeatureNotAvailableInVersion6 = 8059,
ERR_FeatureIsUnimplemented = 8060,
ERR_FeatureNotAvailableInVersion7 = 8061,
// available 8062-8069
ERR_SwitchFallOut = 8070,
// ERR_UnexpectedBoundGenericName = 8071, // for nameof - used in an early prototype
......@@ -1338,12 +1336,14 @@ internal enum ErrorCode
ERR_OptionMustBeAbsolutePath = 8106,
#endregion diagnostics introduced in C# 6 updates
ERR_FeatureNotAvailableInVersion7 = 8107,
#region diagnostics for local functions introduced in C# 7
ERR_DynamicLocalFunctionParamsParameter = 8108,
ERR_ExpressionTreeContainsLocalFunction = 8110,
#endregion diagnostics for local functions introduced in C# 7
// gap here; available 8111-8115
// Available = 8111, 8112, 8113, 8114, 8115
#region diagnostics for pattern-matching introduced in C# 7
ERR_PatternNullableType = 8116,
......@@ -1353,87 +1353,86 @@ internal enum ErrorCode
ERR_PatternWrongType = 8121,
#endregion diagnostics for pattern-matching introduced in C# 7
// gap here; available 8122-8199
// Available = 8122, 8123
#region tuple diagnostics introduced in C# 7
ERR_TupleTooFewElements = 8124,
ERR_TupleReservedMemberName = 8125,
ERR_TupleReservedMemberNameAnyPosition = 8126,
ERR_TupleDuplicateMemberName = 8127,
ERR_PredefinedTypeMemberNotFoundInAssembly = 8128,
ERR_MissingDeconstruct = 8129,
ERR_DeconstructCouldNotInferMergedType = 8130,
ERR_DeconstructRequiresExpression = 8131,
ERR_DeconstructWrongCardinality = 8132,
ERR_CannotDeconstructDynamic = 8133,
ERR_DeconstructTooFewElements = 8134,
ERR_TupleTooFewElements = 8200,
ERR_TupleReservedMemberName = 8201,
ERR_TupleReservedMemberNameAnyPosition = 8202,
ERR_TupleDuplicateMemberName = 8203,
// 8204 available
ERR_PredefinedTypeMemberNotFoundInAssembly = 8205,
ERR_MissingDeconstruct = 8206,
ERR_DeconstructCouldNotInferMergedType = 8209,
ERR_DeconstructRequiresExpression = 8210,
ERR_DeconstructWrongCardinality = 8211,
ERR_CannotDeconstructDynamic = 8212,
ERR_DeconstructTooFewElements = 8213,
ERR_ConversionNotTupleCompatible = 8135,
ERR_DeconstructionVarFormDisallowsSpecificType = 8136,
ERR_ConversionNotTupleCompatible = 8214,
ERR_DeconstructionVarFormDisallowsSpecificType = 8215,
ERR_TupleElementNamesAttributeMissing = 8216,
ERR_ExplicitTupleElementNames = 8217,
ERR_CantChangeTupleNamesOnOverride = 8218,
ERR_DuplicateInterfaceWithTupleNamesInBaseList = 8219,
ERR_ImplBadTupleNames = 8220,
ERR_PartialMethodInconsistentTupleNames = 8221,
ERR_TupleElementNamesAttributeMissing = 8137,
ERR_ExplicitTupleElementNames = 8138,
ERR_CantChangeTupleNamesOnOverride = 8139,
ERR_DuplicateInterfaceWithTupleNamesInBaseList = 8140,
ERR_ImplBadTupleNames = 8141,
ERR_PartialMethodInconsistentTupleNames = 8142,
#endregion tuple diagnostics introduced in C# 7
// huge gap here; available 8222-8889
// Available = 8143, 8144
#region diagnostics for ref locals and ref returns introduced in C# 7
ERR_AutoPropertyCannotBeRefReturning = 8890,
ERR_RefPropertyMustHaveGetAccessor = 8891,
ERR_RefPropertyCannotHaveSetAccessor = 8892,
ERR_CantChangeRefReturnOnOverride = 8893,
ERR_MustNotHaveRefReturn = 8894,
ERR_MustHaveRefReturn = 8895,
ERR_RefReturnMustHaveIdentityConversion = 8896,
ERR_CloseUnimplementedInterfaceMemberWrongRefReturn = 8897,
ERR_VoidReturningMethodCannotReturnByRef = 8898,
ERR_BadIteratorReturnRef = 8899,
ERR_BadRefReturnExpressionTree = 8900,
ERR_RefReturningCallInExpressionTree = 8901,
ERR_AutoPropertyCannotBeRefReturning = 8145,
ERR_RefPropertyMustHaveGetAccessor = 8146,
ERR_RefPropertyCannotHaveSetAccessor = 8147,
ERR_CantChangeRefReturnOnOverride = 8148,
ERR_MustNotHaveRefReturn = 8149,
ERR_MustHaveRefReturn = 8150,
ERR_RefReturnMustHaveIdentityConversion = 8151,
ERR_CloseUnimplementedInterfaceMemberWrongRefReturn = 8152,
ERR_VoidReturningMethodCannotReturnByRef = 8153,
ERR_BadIteratorReturnRef = 8154,
ERR_BadRefReturnExpressionTree = 8155,
ERR_RefReturningCallInExpressionTree = 8156,
ERR_RefReturnLvalueExpected = 8910,
ERR_RefReturnNonreturnableLocal = 8911,
ERR_RefReturnNonreturnableLocal2 = 8912,
ERR_RefReturnRangeVariable = 8913,
ERR_RefReturnRangeVariable2 = 8914,
ERR_RefReturnReadonly = 8916,
ERR_RefReturnReadonlyStatic = 8917,
ERR_RefReturnReadonly2 = 8918,
ERR_RefReturnReadonlyStatic2 = 8919,
ERR_RefReturnCall = 8920,
ERR_RefReturnCall2 = 8921,
ERR_RefReturnParameter = 8922,
ERR_RefReturnParameter2 = 8923,
ERR_RefReturnLocal = 8924,
ERR_RefReturnLocal2 = 8925,
ERR_RefReturnStructThis = 8926,
ERR_RefReturnLvalueExpected = 8157,
ERR_RefReturnNonreturnableLocal = 8158,
ERR_RefReturnNonreturnableLocal2 = 8159,
ERR_RefReturnRangeVariable = 8160,
ERR_RefReturnRangeVariable2 = 8170,
ERR_RefReturnReadonly = 8171,
ERR_RefReturnReadonlyStatic = 8172,
ERR_RefReturnReadonly2 = 8173,
ERR_RefReturnReadonlyStatic2 = 8174,
ERR_RefReturnCall = 8175,
ERR_RefReturnCall2 = 8176,
ERR_RefReturnParameter = 8177,
ERR_RefReturnParameter2 = 8178,
ERR_RefReturnLocal = 8179,
ERR_RefReturnLocal2 = 8180,
ERR_RefReturnStructThis = 8181,
// Available = 8927-8929,
// Available = 8182, 8183
ERR_MustBeRefAssignable = 8930,
ERR_MustBeRefAssignableLocal = 8931,
ERR_InitializeByValueVariableWithReference = 8932,
ERR_InitializeByReferenceVariableWithValue = 8933,
ERR_RefAssignmentMustHaveIdentityConversion = 8934,
ERR_ByReferenceVariableMustBeInitialized = 8935,
ERR_MustBeRefAssignable = 8184,
ERR_MustBeRefAssignableLocal = 8185,
ERR_InitializeByValueVariableWithReference = 8186,
ERR_InitializeByReferenceVariableWithValue = 8187,
ERR_RefAssignmentMustHaveIdentityConversion = 8188,
ERR_ByReferenceVariableMustBeInitialized = 8189,
ERR_AnonDelegateCantUseLocal = 8940,
ERR_BadIteratorLocalType = 8941,
ERR_BadAsyncLocalType = 8942,
ERR_RefReturningCallAndAwait = 8943,
ERR_AnonDelegateCantUseLocal = 8190,
ERR_BadIteratorLocalType = 8191,
ERR_BadAsyncLocalType = 8192,
ERR_RefReturningCallAndAwait = 8193,
#endregion diagnostics for ref locals and ref returns introduced in C# 7
// Available = 8194, 8195
#region diagnostics for out var
ERR_ImplicitlyTypedOutVariableUsedInTheSameArgumentList = 8944,
ERR_TypeInferenceFailedForImplicitlyTypedOutVariable = 8945,
ERR_ImplicitlyTypedOutVariableUsedInTheSameArgumentList = 8196,
ERR_TypeInferenceFailedForImplicitlyTypedOutVariable = 8197,
#endregion diagnostics for out var
}
}
......@@ -3611,7 +3611,7 @@ namespace global::((System.Linq.Expressions.Expression<System.Func<B>>)(() => B
// (2,19): error CS1001: Identifier expected
// namespace global::((System.Linq.Expressions.Expression<System.Func<B>>)(() => B )).Compile()(){}
Diagnostic(ErrorCode.ERR_IdentifierExpected, "(").WithLocation(2, 19),
// (2,20): error CS8200: Tuple must contain at least two elements.
// (2,20): error CS8124: Tuple must contain at least two elements.
// namespace global::((System.Linq.Expressions.Expression<System.Func<B>>)(() => B )).Compile()(){}
Diagnostic(ErrorCode.ERR_TupleTooFewElements, "(System.Linq.Expressions.Expression<System.Func<B>>)").WithLocation(2, 20),
// (2,76): error CS1026: ) expected
......@@ -3635,7 +3635,7 @@ namespace global::((System.Linq.Expressions.Expression<System.Func<B>>)(() => B
// (2,93): error CS1002: ; expected
// namespace global::((System.Linq.Expressions.Expression<System.Func<B>>)(() => B )).Compile()(){}
Diagnostic(ErrorCode.ERR_SemicolonExpected, "(").WithLocation(2, 93),
// (2,93): error CS8200: Tuple must contain at least two elements.
// (2,93): error CS8124: Tuple must contain at least two elements.
// namespace global::((System.Linq.Expressions.Expression<System.Func<B>>)(() => B )).Compile()(){}
Diagnostic(ErrorCode.ERR_TupleTooFewElements, "()").WithLocation(2, 93),
// (2,93): error CS8059: Feature 'tuples' is not available in C# 6. Please use language version 7 or greater.
......
......@@ -876,7 +876,7 @@ class C : I
";
var comp2 = CreateCompilation(source2, new[] { MscorlibRef, SystemCoreRef, ilRef, ValueTupleRef, SystemRuntimeFacadeRef, CSharpRef });
comp2.VerifyDiagnostics(
// (4,28): error CS8220: The tuple element names in the signature of method 'C.M((object, object))' must match the tuple element names of interface method 'I.M((object c, object d))' (including on the return type).
// (4,28): error CS8141: The tuple element names in the signature of method 'C.M((object, object))' must match the tuple element names of interface method 'I.M((object c, object d))' (including on the return type).
// (object a, object b) I.M((object, object) x) { return x; }
Diagnostic(ErrorCode.ERR_ImplBadTupleNames, "M").WithArguments("C.M((object, object))", "I.M((object c, object d))").WithLocation(4, 28),
// (2,11): error CS0535: 'C' does not implement interface member 'I.M((object c, object d))'
......@@ -898,7 +898,7 @@ class C : I
";
var comp3 = CreateCompilation(source3, new[] { MscorlibRef, SystemCoreRef, ilRef, ValueTupleRef, SystemRuntimeFacadeRef, CSharpRef });
comp3.VerifyDiagnostics(
// (4,24): error CS8220: The tuple element names in the signature of method 'C.M((object c, object d))' must match the tuple element names of interface method 'I.M((object c, object d))' (including on the return type).
// (4,24): error CS8141: The tuple element names in the signature of method 'C.M((object c, object d))' must match the tuple element names of interface method 'I.M((object c, object d))' (including on the return type).
// (object, object) I.M((object c, object d) x) { return x; }
Diagnostic(ErrorCode.ERR_ImplBadTupleNames, "M").WithArguments("C.M((object c, object d))", "I.M((object c, object d))").WithLocation(4, 24),
// (2,11): error CS0535: 'C' does not implement interface member 'I.M((object c, object d))'
......@@ -994,7 +994,7 @@ class C : I
";
var comp2 = CreateCompilation(source2, new[] { MscorlibRef, SystemCoreRef, ilRef, ValueTupleRef, SystemRuntimeFacadeRef, CSharpRef });
comp2.VerifyDiagnostics(
// (4,24): error CS8220: The tuple element names in the signature of method 'C.P' must match the tuple element names of interface method 'I.P' (including on the return type).
// (4,24): error CS8141: The tuple element names in the signature of method 'C.P' must match the tuple element names of interface method 'I.P' (including on the return type).
// (object, object) I.P { get; set; }
Diagnostic(ErrorCode.ERR_ImplBadTupleNames, "P").WithArguments("C.P", "I.P").WithLocation(4, 24),
// (2,11): error CS0535: 'C' does not implement interface member 'I.P'
......@@ -1161,16 +1161,16 @@ class C : Base
";
var comp2 = CreateCompilation(source2, new[] { MscorlibRef, SystemCoreRef, ilRef, ValueTupleRef, SystemRuntimeFacadeRef, CSharpRef });
comp2.VerifyDiagnostics(
// (5,38): error CS8218: 'C.M((object c, object d))': cannot change tuple element names when overriding inherited member 'Base.M((object c, object d))'
// (5,38): error CS8139: 'C.M((object c, object d))': cannot change tuple element names when overriding inherited member 'Base.M((object c, object d))'
// public override (object, object) M((object c, object d) y) { return y; }
Diagnostic(ErrorCode.ERR_CantChangeTupleNamesOnOverride, "M").WithArguments("C.M((object c, object d))", "Base.M((object c, object d))").WithLocation(5, 38),
// (4,38): error CS8218: 'C.P': cannot change tuple element names when overriding inherited member 'Base.P'
// (4,38): error CS8139: 'C.P': cannot change tuple element names when overriding inherited member 'Base.P'
// public override (object, object) P { get; set; }
Diagnostic(ErrorCode.ERR_CantChangeTupleNamesOnOverride, "P").WithArguments("C.P", "Base.P").WithLocation(4, 38),
// (4,42): error CS8218: 'C.P.get': cannot change tuple element names when overriding inherited member 'Base.P.get'
// (4,42): error CS8139: 'C.P.get': cannot change tuple element names when overriding inherited member 'Base.P.get'
// public override (object, object) P { get; set; }
Diagnostic(ErrorCode.ERR_CantChangeTupleNamesOnOverride, "get").WithArguments("C.P.get", "Base.P.get").WithLocation(4, 42),
// (4,47): error CS8218: 'C.P.set': cannot change tuple element names when overriding inherited member 'Base.P.set'
// (4,47): error CS8139: 'C.P.set': cannot change tuple element names when overriding inherited member 'Base.P.set'
// public override (object, object) P { get; set; }
Diagnostic(ErrorCode.ERR_CantChangeTupleNamesOnOverride, "set").WithArguments("C.P.set", "Base.P.set").WithLocation(4, 47)
);
......@@ -1196,7 +1196,7 @@ class C : Base
";
var comp3 = CreateCompilation(source3, new[] { MscorlibRef, SystemCoreRef, ilRef, ValueTupleRef, SystemRuntimeFacadeRef, CSharpRef });
comp3.VerifyDiagnostics(
// (5,42): error CS8218: 'C.M((object, object))': cannot change tuple element names when overriding inherited member 'Base.M((object c, object d))'
// (5,42): error CS8139: 'C.M((object, object))': cannot change tuple element names when overriding inherited member 'Base.M((object c, object d))'
// public override (object a, object b) M((object, object) y) { return y; }
Diagnostic(ErrorCode.ERR_CantChangeTupleNamesOnOverride, "M").WithArguments("C.M((object, object))", "Base.M((object c, object d))").WithLocation(5, 42)
);
......
......@@ -289,7 +289,7 @@ class A
// (5,37): error CS1002: ; expected
// protected virtual void Finalize const () { }
Diagnostic(ErrorCode.ERR_SemicolonExpected, "const").WithLocation(5, 37),
// (5,43): error CS8200: Tuple must contain at least two elements.
// (5,43): error CS8124: Tuple must contain at least two elements.
// protected virtual void Finalize const () { }
Diagnostic(ErrorCode.ERR_TupleTooFewElements, "()").WithLocation(5, 43),
// (5,46): error CS1001: Identifier expected
......@@ -313,7 +313,7 @@ class A
// (5,46): error CS0102: The type 'A' already contains a definition for ''
// protected virtual void Finalize const () { }
Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "").WithArguments("A", "").WithLocation(5, 46),
// (5,43): error CS8200: Tuple must contain at least two elements.
// (5,43): error CS8124: Tuple must contain at least two elements.
// protected virtual void Finalize const () { }
Diagnostic(ErrorCode.ERR_TupleTooFewElements, "()").WithLocation(5, 43),
// (5,23): error CS0670: Field cannot have void type
......@@ -354,7 +354,7 @@ class A
// (5,37): error CS1002: ; expected
// protected virtual void Finalize const () { }
Diagnostic(ErrorCode.ERR_SemicolonExpected, "const").WithLocation(5, 37),
// (5,43): error CS8200: Tuple must contain at least two elements.
// (5,43): error CS8124: Tuple must contain at least two elements.
// protected virtual void Finalize const () { }
Diagnostic(ErrorCode.ERR_TupleTooFewElements, "()").WithLocation(5, 43),
// (5,43): error CS8059: Feature 'tuples' is not available in C# 6. Please use language version 7 or greater.
......@@ -381,7 +381,7 @@ class A
// (5,46): error CS0102: The type 'A' already contains a definition for ''
// protected virtual void Finalize const () { }
Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "").WithArguments("A", "").WithLocation(5, 46),
// (5,43): error CS8200: Tuple must contain at least two elements.
// (5,43): error CS8124: Tuple must contain at least two elements.
// protected virtual void Finalize const () { }
Diagnostic(ErrorCode.ERR_TupleTooFewElements, "()").WithLocation(5, 43),
// (5,23): error CS0670: Field cannot have void type
......
......@@ -1053,7 +1053,7 @@ class C
// (5,15): error CS1003: Syntax error, ',' expected
// int F<int>() { } // CS0081
Diagnostic(ErrorCode.ERR_SyntaxError, "(").WithArguments(",", "(").WithLocation(5, 15),
// (5,15): error CS8200: Tuple must contain at least two elements.
// (5,15): error CS8124: Tuple must contain at least two elements.
// int F<int>() { } // CS0081
Diagnostic(ErrorCode.ERR_TupleTooFewElements, "()").WithLocation(5, 15),
// (5,18): error CS1001: Identifier expected
......@@ -1062,7 +1062,7 @@ class C
// (5,18): error CS1026: ) expected
// int F<int>() { } // CS0081
Diagnostic(ErrorCode.ERR_CloseParenExpected, "{").WithLocation(5, 18),
// (5,15): error CS8200: Tuple must contain at least two elements.
// (5,15): error CS8124: Tuple must contain at least two elements.
// int F<int>() { } // CS0081
Diagnostic(ErrorCode.ERR_TupleTooFewElements, "()").WithLocation(5, 15),
// (5,9): error CS0161: 'C.F<>(int, ?)': not all code paths return a value
......@@ -1104,7 +1104,7 @@ class C
// (5,15): error CS1003: Syntax error, ',' expected
// int F<int>() { } // CS0081
Diagnostic(ErrorCode.ERR_SyntaxError, "(").WithArguments(",", "(").WithLocation(5, 15),
// (5,15): error CS8200: Tuple must contain at least two elements.
// (5,15): error CS8124: Tuple must contain at least two elements.
// int F<int>() { } // CS0081
Diagnostic(ErrorCode.ERR_TupleTooFewElements, "()").WithLocation(5, 15),
// (5,15): error CS8059: Feature 'tuples' is not available in C# 6. Please use language version 7 or greater.
......@@ -1116,7 +1116,7 @@ class C
// (5,18): error CS1026: ) expected
// int F<int>() { } // CS0081
Diagnostic(ErrorCode.ERR_CloseParenExpected, "{").WithLocation(5, 18),
// (5,15): error CS8200: Tuple must contain at least two elements.
// (5,15): error CS8124: Tuple must contain at least two elements.
// int F<int>() { } // CS0081
Diagnostic(ErrorCode.ERR_TupleTooFewElements, "()").WithLocation(5, 15),
// (5,9): error CS0161: 'C.F<>(int, ?)': not all code paths return a value
......
......@@ -2111,7 +2111,7 @@ public static void Main()
// (8,21): error CS1002: ; expected
// e = new this; // CS1031, not a type
Diagnostic(ErrorCode.ERR_SemicolonExpected, "this").WithLocation(8, 21),
// (9,21): error CS8200: Tuple must contain at least two elements.
// (9,21): error CS8124: Tuple must contain at least two elements.
// e = new (); // CS1031, not a type
Diagnostic(ErrorCode.ERR_TupleTooFewElements, "()").WithLocation(9, 21),
// (9,21): error CS8059: Feature 'tuples' is not available in C# 6. Please use language version 7 or greater.
......@@ -2248,7 +2248,7 @@ public static A operator ()
// (4,32): error CS1041: Identifier expected; 'operator' is a keyword
// public static int explicit operator ()
Diagnostic(ErrorCode.ERR_IdentifierExpectedKW, "operator").WithArguments("", "operator").WithLocation(4, 32),
// (4,41): error CS8200: Tuple must contain at least two elements.
// (4,41): error CS8124: Tuple must contain at least two elements.
// public static int explicit operator ()
Diagnostic(ErrorCode.ERR_TupleTooFewElements, "()").WithLocation(4, 41),
// (4,41): error CS8059: Feature 'tuples' is not available in C# 6. Please use language version 7 or greater.
......@@ -3628,7 +3628,7 @@ public static int Main ()
// (3,32): error CS1041: Identifier expected; 'operator' is a keyword
// public static int implicit operator (foo f) { return 6; } // Error
Diagnostic(ErrorCode.ERR_IdentifierExpectedKW, "operator").WithArguments("", "operator").WithLocation(3, 32),
// (3,41): error CS8200: Tuple must contain at least two elements.
// (3,41): error CS8124: Tuple must contain at least two elements.
// public static int implicit operator (foo f) { return 6; } // Error
Diagnostic(ErrorCode.ERR_TupleTooFewElements, "(foo f)").WithLocation(3, 41),
// (3,41): error CS8059: Feature 'tuples' is not available in C# 6. Please use language version 7 or greater.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册