提交 b4fa09a4 编写于 作者: C Charles Stoner 提交者: GitHub

Merge pull request #13072 from cston/ref-errors

Remove unused ref return error codes
......@@ -6118,24 +6118,6 @@ internal class CSharpResources {
}
}
/// <summary>
/// Looks up a localized string similar to &apos;{0}&apos; cannot be assigned a reference because it is not a by-reference local.
/// </summary>
internal static string ERR_MustBeRefAssignable {
get {
return ResourceManager.GetString("ERR_MustBeRefAssignable", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Expected a by-reference local.
/// </summary>
internal static string ERR_MustBeRefAssignableLocal {
get {
return ResourceManager.GetString("ERR_MustBeRefAssignableLocal", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to In order for &apos;{0}&apos; to be applicable as a short circuit operator, its declaring type &apos;{1}&apos; must define operator true and operator false.
/// </summary>
......
......@@ -4804,12 +4804,6 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<data name="ERR_RefReturnStructThis" xml:space="preserve">
<value>Struct members cannot return 'this' or other instance members by reference</value>
</data>
<data name="ERR_MustBeRefAssignable" xml:space="preserve">
<value>'{0}' cannot be assigned a reference because it is not a by-reference local</value>
</data>
<data name="ERR_MustBeRefAssignableLocal" xml:space="preserve">
<value>Expected a by-reference local</value>
</data>
<data name="ERR_InitializeByValueVariableWithReference" xml:space="preserve">
<value>Cannot initialize a by-value variable with a reference</value>
</data>
......
......@@ -1390,44 +1390,35 @@ internal enum ErrorCode
ERR_MustHaveRefReturn = 8150,
ERR_RefReturnMustHaveIdentityConversion = 8151,
ERR_CloseUnimplementedInterfaceMemberWrongRefReturn = 8152,
ERR_VoidReturningMethodCannotReturnByRef = 8153,
ERR_RefReturningCallInExpressionTree = 8153,
ERR_BadIteratorReturnRef = 8154,
ERR_BadRefReturnExpressionTree = 8155,
ERR_RefReturningCallInExpressionTree = 8156,
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 = 8182, 8183
ERR_MustBeRefAssignable = 8184,
ERR_MustBeRefAssignableLocal = 8185,
ERR_InitializeByValueVariableWithReference = 8186,
ERR_InitializeByReferenceVariableWithValue = 8187,
ERR_RefAssignmentMustHaveIdentityConversion = 8188,
ERR_ByReferenceVariableMustBeInitialized = 8189,
ERR_AnonDelegateCantUseLocal = 8190,
ERR_BadIteratorLocalType = 8191,
ERR_BadAsyncLocalType = 8192,
ERR_RefReturningCallAndAwait = 8193,
ERR_RefReturnLvalueExpected = 8156,
ERR_RefReturnNonreturnableLocal = 8157,
ERR_RefReturnNonreturnableLocal2 = 8158,
ERR_RefReturnRangeVariable = 8159,
ERR_RefReturnReadonly = 8160,
ERR_RefReturnReadonlyStatic = 8161,
ERR_RefReturnReadonly2 = 8162,
ERR_RefReturnReadonlyStatic2 = 8163,
ERR_RefReturnCall = 8164,
ERR_RefReturnCall2 = 8165,
ERR_RefReturnParameter = 8166,
ERR_RefReturnParameter2 = 8167,
ERR_RefReturnLocal = 8168,
ERR_RefReturnLocal2 = 8169,
ERR_RefReturnStructThis = 8170,
ERR_InitializeByValueVariableWithReference = 8171,
ERR_InitializeByReferenceVariableWithValue = 8172,
ERR_RefAssignmentMustHaveIdentityConversion = 8173,
ERR_ByReferenceVariableMustBeInitialized = 8174,
ERR_AnonDelegateCantUseLocal = 8175,
ERR_BadIteratorLocalType = 8176,
ERR_BadAsyncLocalType = 8177,
ERR_RefReturningCallAndAwait = 8178,
#endregion diagnostics for ref locals and ref returns introduced in C# 7
// Available = 8194, 8195
// Available = 8179-8195
#region diagnostics for out var
ERR_ImplicitlyTypedOutVariableUsedInTheSameArgumentList = 8196,
......
......@@ -1193,13 +1193,13 @@ static void M()
";
CreateCompilationWithMscorlib45(text).VerifyDiagnostics(
// (11,22): error CS8083: By-reference returns may only be used in by-reference returning methods.
// (11,22): error CS8149: By-reference returns may only be used in by-reference returning methods.
// ME(() => ref i);
Diagnostic(ErrorCode.ERR_MustNotHaveRefReturn, "i").WithLocation(11, 22),
// (12,20): error CS8083: By-reference returns may only be used in by-reference returning methods.
// (12,20): error CS8149: By-reference returns may only be used in by-reference returning methods.
// ME(() => { return ref i; });
Diagnostic(ErrorCode.ERR_MustNotHaveRefReturn, "return").WithLocation(12, 20),
// (13,23): error CS8083: By-reference returns may only be used in by-reference returning methods.
// (13,23): error CS8149: By-reference returns may only be used in by-reference returning methods.
// ME(delegate { return ref i; });
Diagnostic(ErrorCode.ERR_MustNotHaveRefReturn, "return").WithLocation(13, 23));
}
......@@ -1223,13 +1223,13 @@ static void M()
";
CreateCompilationWithMscorlib45(text).VerifyDiagnostics(
// (9,33): error CS8083: By-reference returns may only be used in by-reference returning methods.
// (9,33): error CS8149: By-reference returns may only be used in by-reference returning methods.
// var e = new E(() => ref i);
Diagnostic(ErrorCode.ERR_MustNotHaveRefReturn, "i").WithLocation(9, 33),
// (10,27): error CS8083: By-reference returns may only be used in by-reference returning methods.
// (10,27): error CS8149: By-reference returns may only be used in by-reference returning methods.
// e = new E(() => { return ref i; });
Diagnostic(ErrorCode.ERR_MustNotHaveRefReturn, "return").WithLocation(10, 27),
// (11,30): error CS8083: By-reference returns may only be used in by-reference returning methods.
// (11,30): error CS8149: By-reference returns may only be used in by-reference returning methods.
// e = new E(delegate { return ref i; });
Diagnostic(ErrorCode.ERR_MustNotHaveRefReturn, "return").WithLocation(11, 30));
}
......@@ -1268,10 +1268,10 @@ static void M()
";
CreateCompilationWithMscorlib45(text).VerifyDiagnostics(
// (18,13): error CS8084: By-value returns may only be used in by-value returning methods.
// (18,13): error CS8150: By-value returns may only be used in by-value returning methods.
// return i;
Diagnostic(ErrorCode.ERR_MustHaveRefReturn, "return").WithLocation(18, 13),
// (23,17): error CS8083: By-reference returns may only be used in by-reference returning methods.
// (23,17): error CS8149: By-reference returns may only be used in by-reference returning methods.
// return ref i;
Diagnostic(ErrorCode.ERR_MustNotHaveRefReturn, "return").WithLocation(23, 17));
}
......
......@@ -293,7 +293,7 @@ class Test<T>
// (28,20): error CS0103: The name 'List2' does not exist in the current context
// s = nameof(List2<>.Add);
Diagnostic(ErrorCode.ERR_NameNotInContext, "List2<>").WithArguments("List2").WithLocation(28, 20),
// (31,20): error CS8083: An alias-qualified name is not an expression.
// (31,20): error CS8149: An alias-qualified name is not an expression.
// s = nameof(global::Program); // not an expression
Diagnostic(ErrorCode.ERR_AliasQualifiedNameNotAnExpression, "global::Program").WithLocation(31, 20),
// (32,20): error CS0305: Using the generic type 'Test<T>' requires 1 type arguments
......@@ -305,7 +305,7 @@ class Test<T>
// (33,20): error CS0841: Cannot use local variable 'b' before it is declared
// s = nameof(b); // cannot use before declaration
Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "b").WithArguments("b").WithLocation(33, 20),
// (35,20): error CS8084: Type parameters are not allowed on a method group as an argument to 'nameof'.
// (35,20): error CS8150: Type parameters are not allowed on a method group as an argument to 'nameof'.
// s = nameof(System.Linq.Enumerable.Select<int, int>); // type parameters not allowed on method group in nameof
Diagnostic(ErrorCode.ERR_NameofMethodGroupWithTypeParameters, "System.Linq.Enumerable.Select<int, int>").WithLocation(35, 20),
// (43,13): error CS0103: The name 'nameof' does not exist in the current context
......
......@@ -11822,7 +11822,7 @@ static object Test1(out int x, out int x2)
parseOptions: TestOptions.Regular);
compilation.VerifyDiagnostics(
// (7,23): error CS8927: Reference to an implicitly-typed out variable 'x1' is not permitted in the same argument list.
// (7,23): error CS8181: Reference to an implicitly-typed out variable 'x1' is not permitted in the same argument list.
// out x1);
Diagnostic(ErrorCode.ERR_ImplicitlyTypedOutVariableUsedInTheSameArgumentList, "x1").WithArguments("x1").WithLocation(7, 23)
);
......@@ -11863,7 +11863,7 @@ static object Test1(out int x, int x2)
parseOptions: TestOptions.Regular);
compilation.VerifyDiagnostics(
// (7,25): error CS8927: Reference to an implicitly-typed out variable 'x1' is not permitted in the same argument list.
// (7,25): error CS8181: Reference to an implicitly-typed out variable 'x1' is not permitted in the same argument list.
// Test1(out x1,
Diagnostic(ErrorCode.ERR_ImplicitlyTypedOutVariableUsedInTheSameArgumentList, "x1").WithArguments("x1").WithLocation(7, 25)
);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册