提交 fe69c449 编写于 作者: C CyrusNajmabadi

Merge remote-tracking branch 'upstream/master'

......@@ -354,13 +354,17 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
CollectTupleFieldMemberNames(name, i + 1, numElements, elementNames)
Dim boundArgument As BoundExpression = BindValue(argumentSyntax.Expression, diagnostics)
boundArguments.Add(boundArgument)
Dim elementType = GetTupleFieldType(boundArgument, argumentSyntax, diagnostics, hasNaturalType, hasErrors)
If elementType Is Nothing Then
hasInferredType = False
End If
If boundArgument.Type IsNot Nothing Then
boundArgument = MakeRValue(boundArgument, diagnostics)
End If
boundArguments.Add(boundArgument)
elementTypes.Add(elementType)
Next
......
......@@ -3654,6 +3654,70 @@ System.String
Dim verifier = CompileAndVerify(
<compilation>
<file name="a.vb">
Imports System
Module C
Sub Main()
Dim q = "q"
Dim a As Object = "a"
System.Console.WriteLine(Test((q, a)))
System.Console.WriteLine(q)
System.Console.WriteLine(a)
System.Console.WriteLine(Test((Ps, Po)))
System.Console.WriteLine(q)
System.Console.WriteLine(a)
End Sub
Function Test(Of T)(ByRef x As (T, T)) As (T, T)
Console.WriteLine(GetType(T))
x.Item1 = x.Item2
Return x
End Function
Public Property Ps As String
Get
Return "q"
End Get
Set(value As String)
System.Console.WriteLine("written1 !!!")
End Set
End Property
Public Property Po As Object
Get
Return "a"
End Get
Set(value As Object)
System.Console.WriteLine("written2 !!!")
End Set
End Property
End Module
</file>
</compilation>, additionalRefs:=s_valueTupleRefs, expectedOutput:=<![CDATA[
System.Object
(a, a)
q
a
System.Object
(a, a)
q
a
]]>)
End Sub
<Fact>
Public Sub MethodTypeInference004a()
Dim verifier = CompileAndVerify(
<compilation>
<file name="a.vb">
Imports System
Module C
Sub Main()
......@@ -3696,7 +3760,9 @@ Module C
Dim q = "q"
Dim a as object = "a"
System.Console.WriteLine(Test((q, a)))
Dim t = (q, a)
System.Console.WriteLine(Test(t))
System.Console.WriteLine(q)
System.Console.WriteLine(a)
......@@ -3716,7 +3782,7 @@ End Module
comp.AssertTheseDiagnostics(
<errors>
BC36651: Data type(s) of the type parameter(s) in method 'Public Function Test(Of T)(ByRef x As (T, T)) As (T, T)' cannot be inferred from these arguments because more than one type is possible. Specifying the data type(s) explicitly might correct this error.
System.Console.WriteLine(Test((q, a)))
System.Console.WriteLine(Test(t))
~~~~
</errors>)
......@@ -17907,6 +17973,96 @@ BC42024: Unused local variable: 'x6'.
End Sub
<Fact>
<WorkItem(15198, "https://github.com/dotnet/roslyn/issues/15198")>
Public Sub TuplePropertyArgs001()
Dim comp = CreateCompilationWithMscorlibAndVBRuntime(
<compilation>
<file name="a.vb">
Imports System
Imports System.Collections.Generic
Public Class C
Shared Sub Main()
dim inst = new C
dim f As (Integer, Integer) = (inst.P1, inst.P1)
System.Console.WriteLine(f)
End Sub
public readonly Property P1 as integer
Get
return 42
End Get
end Property
End Class
</file>
</compilation>,
options:=TestOptions.ReleaseExe, additionalRefs:=s_valueTupleRefs)
CompileAndVerify(comp, expectedOutput:="(42, 42)")
End Sub
<Fact>
<WorkItem(15198, "https://github.com/dotnet/roslyn/issues/15198")>
Public Sub TuplePropertyArgs002()
Dim comp = CreateCompilationWithMscorlibAndVBRuntime(
<compilation>
<file name="a.vb">
Imports System
Imports System.Collections.Generic
Public Class C
Shared Sub Main()
dim inst = new C
dim f As IComparable(of (Integer, Integer)) = (inst.P1, inst.P1)
System.Console.WriteLine(f)
End Sub
public readonly Property P1 as integer
Get
return 42
End Get
end Property
End Class
</file>
</compilation>,
options:=TestOptions.ReleaseExe, additionalRefs:=s_valueTupleRefs)
CompileAndVerify(comp, expectedOutput:="(42, 42)")
End Sub
<Fact>
<WorkItem(15198, "https://github.com/dotnet/roslyn/issues/15198")>
Public Sub TuplePropertyArgs003()
Dim comp = CreateCompilationWithMscorlibAndVBRuntime(
<compilation>
<file name="a.vb">
Imports System
Imports System.Collections.Generic
Public Class C
Shared Sub Main()
dim inst as Object = new C
dim f As (Integer, Integer) = (inst.P1, inst.P1)
System.Console.WriteLine(f)
End Sub
public readonly Property P1 as integer
Get
return 42
End Get
end Property
End Class
</file>
</compilation>,
options:=TestOptions.ReleaseExe, additionalRefs:=s_valueTupleRefs)
CompileAndVerify(comp, expectedOutput:="(42, 42)")
End Sub
End Class
End Namespace
......
......@@ -553,8 +553,10 @@ private ITextBuffer CreateNewPlainTextBuffer(TextDocument document, Cancellation
document.GetTextAsync(cancellationToken).WaitAndGetResult(cancellationToken).ToString(), contentType);
}
private async Task<object> CreateNewDifferenceViewerAsync(PreviewWorkspace leftWorkspace, PreviewWorkspace rightWorkspace,
IProjectionBuffer originalBuffer, IProjectionBuffer changedBuffer, double zoomLevel, CancellationToken cancellationToken)
private async Task<object> CreateNewDifferenceViewerAsync(
PreviewWorkspace leftWorkspace, PreviewWorkspace rightWorkspace,
IProjectionBuffer originalBuffer, IProjectionBuffer changedBuffer,
double zoomLevel, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
......@@ -564,24 +566,27 @@ private ITextBuffer CreateNewPlainTextBuffer(TextDocument document, Cancellation
Contract.ThrowIfTrue((leftWorkspace == null) && (rightWorkspace == null));
var diffBuffer = _differenceBufferService.CreateDifferenceBuffer(
originalBuffer, changedBuffer,
new StringDifferenceOptions(), disableEditing: true);
originalBuffer, changedBuffer,
new StringDifferenceOptions(), disableEditing: true);
var diffViewer = _differenceViewerService.CreateDifferenceView(diffBuffer, _previewRoleSet);
diffViewer.Closed += (s, e) =>
{
if (leftWorkspace != null)
{
leftWorkspace.Dispose();
leftWorkspace = null;
}
if (rightWorkspace != null)
{
rightWorkspace.Dispose();
rightWorkspace = null;
}
// Workaround Editor bug. The editor has an issue where they sometimes crash when
// trying to apply changes to projection buffer. So, when the user actually invokes
// a SuggestedAction we may then edit a text buffer, which the editor will then
// try to propagate through the projections we have here over that buffer. To ensure
// that that doesn't happen, we clear out the projections first so that this crash
// won't happen.
originalBuffer.DeleteSpans(0, originalBuffer.CurrentSnapshot.SpanCount);
changedBuffer.DeleteSpans(0, changedBuffer.CurrentSnapshot.SpanCount);
leftWorkspace?.Dispose();
leftWorkspace = null;
rightWorkspace?.Dispose();
rightWorkspace = null;
};
const string DiffOverviewMarginName = "deltadifferenceViewerOverview";
......@@ -615,15 +620,8 @@ private ITextBuffer CreateNewPlainTextBuffer(TextDocument document, Cancellation
// We use ConfigureAwait(true) to stay on the UI thread.
await diffViewer.SizeToFitAsync().ConfigureAwait(true);
if (leftWorkspace != null)
{
leftWorkspace.EnableDiagnostic();
}
if (rightWorkspace != null)
{
rightWorkspace.EnableDiagnostic();
}
leftWorkspace?.EnableDiagnostic();
rightWorkspace?.EnableDiagnostic();
return new DifferenceViewerPreview(diffViewer);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册