提交 64f940f4 编写于 作者: V vsadov

fixup after merge

上级 1993d900
......@@ -672,7 +672,7 @@ private bool CheckEventValueKind(BoundEventAccess boundEvent, BindValueKind valu
return false;
}
else if (RequiresVariableReceiver(receiver, eventSymbol.AssociatedField) && // NOTE: using field, not event
!CheckIsValidReceiverForVariable(eventSyntax, receiver, BindValueKind.Assignable, diagnostics))
!CheckIsValidReceiverForVariable(eventSyntax, receiver, valueKind, diagnostics))
{
return false;
}
......
......@@ -1544,51 +1544,6 @@ public static IEnumerable<string> ParseConditionalCompilationSymbols(string valu
return defines.AsEnumerable();
}
public static bool TryParseLanguageVersion(string value, out LanguageVersion version)
{
if (value == null)
{
version = LanguageVersion.Default;
return true;
}
switch (value.ToLowerInvariant())
{
case "iso-1":
version = LanguageVersion.CSharp1;
return true;
case "iso-2":
version = LanguageVersion.CSharp2;
return true;
case "default":
version = LanguageVersion.Default;
return true;
case "latest":
version = LanguageVersion.Latest;
return true;
case "7.1":
version = LanguageVersion.CSharp7_1;
return true;
default:
if (int.TryParse(value, NumberStyles.None, CultureInfo.InvariantCulture, out int versionNumber))
{
version = (LanguageVersion)versionNumber;
if (version.IsValid())
{
return true;
}
}
version = LanguageVersion.Default;
return false;
}
}
private static Platform ParsePlatform(string value, IList<Diagnostic> diagnostics)
{
switch (value.ToLowerInvariant())
......
Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp7_2 = 702 -> Microsoft.CodeAnalysis.CSharp.LanguageVersion
\ No newline at end of file
Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp7_2 = 702 -> Microsoft.CodeAnalysis.CSharp.LanguageVersion
Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.ReadOnlyKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken
Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken refKeyword, Microsoft.CodeAnalysis.SyntaxToken readOnlyKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.WithReadOnlyKeyword(Microsoft.CodeAnalysis.SyntaxToken readOnlyKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax
static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.RefType(Microsoft.CodeAnalysis.SyntaxToken refKeyword, Microsoft.CodeAnalysis.SyntaxToken readOnlyKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax
......@@ -386,7 +386,7 @@ private sealed class EndInvokeMethod : SourceDelegateMethodSymbol
InitializeParameters(parameters.ToImmutableAndFree());
}
protected override SourceMethodSymbol BoundAttributesSource => _invoke;
protected override SourceMemberMethodSymbol BoundAttributesSource => _invoke;
public override string Name => WellKnownMemberNames.DelegateEndInvokeName;
......
......@@ -254,7 +254,7 @@ private DeclarationModifiers MakeModifiers(TypeKind typeKind, DiagnosticBag diag
allowedModifiers |= DeclarationModifiers.Partial | DeclarationModifiers.Static | DeclarationModifiers.Sealed | DeclarationModifiers.Abstract | DeclarationModifiers.Unsafe;
break;
case TypeKind.Struct:
allowedModifiers |= DeclarationModifiers.Ref | DeclarationModifiers.ReadOnly | DeclarationModifiers.Unsafe;
allowedModifiers |= DeclarationModifiers.Partial | DeclarationModifiers.Ref | DeclarationModifiers.ReadOnly | DeclarationModifiers.Unsafe;
break;
case TypeKind.Interface:
allowedModifiers |= DeclarationModifiers.Partial | DeclarationModifiers.Unsafe;
......
......@@ -1430,13 +1430,6 @@ public sealed override bool HidesBaseMethodsByName
{
return false;
}
if (_refKind == RefKind.RefReadOnly)
{
this.DeclaringCompilation.EnsureIsReadOnlyAttributeExists(diagnostics, GetSyntax().ReturnType.Location, modifyCompilationForRefReadOnly: true);
}
ParameterHelpers.EnsureIsReadOnlyAttributeExists(Parameters, diagnostics, modifyCompilationForRefReadOnly: true);
}
internal override bool HasRuntimeSpecialName
......
......@@ -148,10 +148,10 @@ interface I1
// (43,9): error CS1604: Cannot assign to 'this' because it is read-only
// e = () => { };
Diagnostic(ErrorCode.ERR_AssgReadonlyLocal, "e").WithArguments("this").WithLocation(43, 9),
// (46,16): error CS1604: Cannot assign to 'this' because it is read-only
// (46,16): error CS1605: Cannot use 'this' as a ref or out value because it is read-only
// M1(ref e);
Diagnostic(ErrorCode.ERR_AssgReadonlyLocal, "e").WithArguments("this").WithLocation(46, 16)
);
Diagnostic(ErrorCode.ERR_RefReadonlyLocal, "e").WithArguments("this").WithLocation(46, 16)
);
}
private static string ilreadonlyStructWithWriteableFieldIL = @"
......
......@@ -629,9 +629,9 @@ public class C
// (46,32): error CS8168: Cannot return local 'M2' by reference because it is not a ref local
// return ref Goo(ref M2).x;
Diagnostic(ErrorCode.ERR_RefReturnLocal, "M2").WithArguments("M2").WithLocation(46, 32),
// (46,24): error CS8165: Cannot return by reference a member of result of 'Test.Foo<Test.S1>(ref Test.S1)' because the argument passed to parameter 'arg' cannot be returned by reference
// return ref Foo(ref M2).x;
Diagnostic(ErrorCode.ERR_RefReturnCall2, "Foo(ref M2)").WithArguments("Test.Foo<Test.S1>(ref Test.S1)", "arg").WithLocation(46, 24),
// (46,24): error CS8165: Cannot return by reference a member of result of 'Test.Goo<Test.S1>(ref Test.S1)' because the argument passed to parameter 'arg' cannot be returned by reference
// return ref Goo(ref M2).x;
Diagnostic(ErrorCode.ERR_RefReturnCall2, "Goo(ref M2)").WithArguments("Test.Goo<Test.S1>(ref Test.S1)", "arg").WithLocation(46, 24),
// (58,24): error CS8170: Struct members cannot return 'this' or other instance members by reference
// return ref this;
Diagnostic(ErrorCode.ERR_RefReturnStructThis, "this").WithArguments("this").WithLocation(58, 24)
......@@ -1885,9 +1885,10 @@ class Program
";
CreateCompilationWithMscorlib46(text).VerifyDiagnostics(
// (8,20): error CS8160: A readonly field cannot be returned by reference
// (8,20): error CS0192: A readonly field cannot be used as a ref or out value (except in a constructor)
// return ref i;
Diagnostic(ErrorCode.ERR_RefReturnReadonly, "i").WithLocation(8, 20));
Diagnostic(ErrorCode.ERR_RefReadonly, "i").WithLocation(8, 20)
);
}
[Fact]
......@@ -2043,9 +2044,10 @@ class Program
";
CreateCompilationWithMscorlib46(text).VerifyDiagnostics(
// (6,20): error CS1605: Cannot use 'this' as a ref or out value because it is read-only
// (6,20): error CS8170: Struct members cannot return 'this' or other instance members by reference
// return ref this;
Diagnostic(ErrorCode.ERR_RefReadonlyLocal, "this").WithArguments("this").WithLocation(6, 20));
Diagnostic(ErrorCode.ERR_RefReturnStructThis, "this").WithArguments("this").WithLocation(6, 20)
);
}
[Fact]
......@@ -2121,7 +2123,11 @@ class Program
CreateCompilationWithMscorlib46(text).VerifyDiagnostics(
// (6,9): error CS8150: By-value returns may only be used in methods that return by value
// return;
Diagnostic(ErrorCode.ERR_MustHaveRefReturn, "return").WithLocation(6, 9));
Diagnostic(ErrorCode.ERR_MustHaveRefReturn, "return").WithLocation(6, 9),
// (6,9): error CS0126: An object of a type convertible to 'int' is required
// return;
Diagnostic(ErrorCode.ERR_RetObjectRequired, "return").WithArguments("int").WithLocation(6, 9)
);
}
[Fact]
......
......@@ -11401,18 +11401,15 @@ public int RetInt(byte b, int k)
var comp = CreateStandardCompilation(text);
comp.VerifyDiagnostics(
// (7,14): error CS0663: 'IFoo<T>' cannot define an overloaded method that differ only on parameter modifiers 'out' and 'ref'
// (7,14): error CS0663: 'IGoo<T>' cannot define an overloaded method that differs only on parameter modifiers 'out' and 'ref'
// void M(out T t);
Diagnostic(ErrorCode.ERR_OverloadRefKind, "M").WithArguments("NS.IFoo<T>", "method", "out", "ref").WithLocation(7, 14),
// (24,20): error CS0663: 'CFoo' cannot define an overloaded method that differ only on parameter modifiers 'ref' and 'out'
Diagnostic(ErrorCode.ERR_OverloadRefKind, "M").WithArguments("NS.IGoo<T>", "method", "out", "ref").WithLocation(7, 14),
// (24,20): error CS0663: 'CGoo' cannot define an overloaded method that differs only on parameter modifiers 'ref' and 'out'
// public int RetInt(byte b, ref int j)
Diagnostic(ErrorCode.ERR_OverloadRefKind, "RetInt").WithArguments("NS.CFoo", "method", "ref", "out").WithLocation(24, 20),
// (16,18): error CS0663: 'CFoo.SFoo' cannot define an overloaded method that differ only on parameter modifiers 'out' and 'ref'
Diagnostic(ErrorCode.ERR_OverloadRefKind, "RetInt").WithArguments("NS.CGoo", "method", "ref", "out").WithLocation(24, 20),
// (16,18): error CS0663: 'CGoo.SGoo' cannot define an overloaded method that differs only on parameter modifiers 'out' and 'ref'
// void M<T>(out T t) { }
Diagnostic(ErrorCode.ERR_OverloadRefKind, "M").WithArguments("NS.CFoo.SFoo", "method", "out", "ref").WithLocation(16, 18),
// Dev10 stops after reporting the overload problems. However, it produces the errors below once those problems are fixed.
Diagnostic(ErrorCode.ERR_OverloadRefKind, "M").WithArguments("NS.CGoo.SGoo", "method", "out", "ref").WithLocation(16, 18),
// (21,20): error CS0269: Use of unassigned out parameter 'i'
// return i;
Diagnostic(ErrorCode.ERR_UseDefViolationOut, "i").WithArguments("i").WithLocation(21, 20),
......@@ -11421,7 +11418,8 @@ public int RetInt(byte b, int k)
Diagnostic(ErrorCode.ERR_ParamUnassigned, "return i;").WithArguments("i").WithLocation(21, 13),
// (16,18): error CS0177: The out parameter 't' must be assigned to before control leaves the current method
// void M<T>(out T t) { }
Diagnostic(ErrorCode.ERR_ParamUnassigned, "M").WithArguments("t").WithLocation(16, 18));
Diagnostic(ErrorCode.ERR_ParamUnassigned, "M").WithArguments("t").WithLocation(16, 18)
);
}
[Fact]
......
......@@ -4893,10 +4893,8 @@ void M()
CreateStandardCompilation(test, options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, allowUnsafe: true)).VerifyDiagnostics(
// (6,15): error CS0283: The type 'int*' cannot be declared const
// const int* p = stackalloc int[1];
Diagnostic(ErrorCode.ERR_BadConstType, "int*").WithArguments("int*").WithLocation(6, 15),
// (6,24): error CS1525: Invalid expression term 'stackalloc'
// const int* p = stackalloc int[1];
Diagnostic(ErrorCode.ERR_InvalidExprTerm, "stackalloc").WithArguments("stackalloc").WithLocation(6, 24));
Diagnostic(ErrorCode.ERR_BadConstType, "int*").WithArguments("int*").WithLocation(6, 15)
);
}
[Fact]
......@@ -4936,9 +4934,13 @@ unsafe public static void Main()
}
";
CreateStandardCompilation(test, options: TestOptions.ReleaseDll.WithAllowUnsafe(true)).VerifyDiagnostics(
// (6,39): error CS0029: Cannot implicitly convert type 'int*' to 'System.IDisposable'
// (6,39): error CS0518: Predefined type 'System.Span`1' is not defined or imported
// using (System.IDisposable v = stackalloc int[1])
Diagnostic(ErrorCode.ERR_PredefinedTypeNotFound, "stackalloc int[1]").WithArguments("System.Span`1").WithLocation(6, 39),
// (6,39): error CS8520: Conversion of a stackalloc expression of type 'int' to type 'IDisposable' is not possible.
// using (System.IDisposable v = stackalloc int[1])
Diagnostic(ErrorCode.ERR_NoImplicitConv, "stackalloc int[1]").WithArguments("int*", "System.IDisposable").WithLocation(6, 39));
Diagnostic(ErrorCode.ERR_StackAllocConversionNotPossible, "stackalloc int[1]").WithArguments("int", "System.IDisposable").WithLocation(6, 39)
);
}
[WorkItem(906993, "DevDiv/Personal")]
......
......@@ -33,6 +33,7 @@ Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.OperationBloc
Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.OperationBlockEndActionsCount.set -> void
Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.OperationBlockStartActionsCount.get -> int
Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.OperationBlockStartActionsCount.set -> void
Microsoft.CodeAnalysis.IMethodSymbol.ReturnsByRefReadonly.get -> bool
Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.IOperation.Accept(Microsoft.CodeAnalysis.Semantics.OperationVisitor visitor) -> void
Microsoft.CodeAnalysis.IOperation.Accept<TArgument, TResult>(Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult> visitor, TArgument argument) -> TResult
......@@ -41,6 +42,7 @@ Microsoft.CodeAnalysis.IOperation.IsInvalid.get -> bool
Microsoft.CodeAnalysis.IOperation.Kind.get -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.IOperation.Syntax.get -> Microsoft.CodeAnalysis.SyntaxNode
Microsoft.CodeAnalysis.IOperation.Type.get -> Microsoft.CodeAnalysis.ITypeSymbol
Microsoft.CodeAnalysis.IPropertySymbol.ReturnsByRefReadonly.get -> bool
Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.AddressOfExpression = 515 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.Argument = 1031 -> Microsoft.CodeAnalysis.OperationKind
......@@ -118,6 +120,7 @@ Microsoft.CodeAnalysis.OperationKind.VariableDeclarationStatement = 3 -> Microso
Microsoft.CodeAnalysis.OperationKind.WithStatement = 82 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.YieldBreakStatement = 12 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.YieldReturnStatement = 16 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.RefKind.RefReadOnly = 3 -> Microsoft.CodeAnalysis.RefKind
Microsoft.CodeAnalysis.SemanticModel.GetOperation(Microsoft.CodeAnalysis.SyntaxNode node, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.ArgumentKind
Microsoft.CodeAnalysis.Semantics.ArgumentKind.DefaultValue = 3 -> Microsoft.CodeAnalysis.Semantics.ArgumentKind
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册