Permalink
Browse files

Merge pull request #31041 from dotnet/merges/dev16.0-preview2-to-master

Merge dev16.0-preview2 to master
  • Loading branch information...
dotnet-automerge-bot committed Nov 8, 2018
2 parents e9fef7e + b20f0bf commit e20ee16f7fac2fb7b4723da61e9d993fc3f920be
View
@@ -154,3 +154,6 @@ csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
# Blocks are allowed
csharp_prefer_braces = true:silent
@@ -11,7 +11,7 @@
-->
<PropertyGroup>
<VersionPrefix>2.11.0</VersionPrefix>
<PreReleaseVersionLabel>beta1</PreReleaseVersionLabel>
<PreReleaseVersionLabel>beta2</PreReleaseVersionLabel>
<SemanticVersioningV1>true</SemanticVersioningV1>
<!--
@@ -433,7 +433,7 @@ public async Task MethodIsUnused_Abstract()
await TestDiagnosticMissingAsync(
@"class C
{
private abstract void [|M|]();
protected abstract void [|M|]();
}");
}
@@ -477,6 +477,52 @@ class C : I
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsRemoveUnusedMembers)]
[WorkItem(30965, "https://github.com/dotnet/roslyn/issues/30965")]
public async Task EventIsUnused_ExplicitInterfaceImplementation()
{
await TestDiagnosticMissingAsync(
@"interface I
{
event System.Action E;
}
class C : I
{
event System.Action [|I.E|]
{
add { }
remove { }
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsRemoveUnusedMembers)]
[WorkItem(30894, "https://github.com/dotnet/roslyn/issues/30894")]
public async Task WriteOnlyProperty_NotWritten()
{
await TestInRegularAndScriptAsync(
@"class C
{
int [|P|] { set { } }
}",
@"class C
{
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsRemoveUnusedMembers)]
[WorkItem(30894, "https://github.com/dotnet/roslyn/issues/30894")]
public async Task WriteOnlyProperty_Written()
{
await TestDiagnosticMissingAsync(
@"class C
{
int [|P|] { set { } }
void M(int i) => P = i;
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsRemoveUnusedMembers)]
public async Task FieldIsUnused_Const()
{
@@ -2365,5 +2365,34 @@ int Goo(object x)
await TestAsync(markup, expectedOrderedItems, usePreviousCharAsTrigger: true);
}
[Fact, Trait(Traits.Feature, Traits.Features.SignatureHelp)]
public async Task PickCorrectOverload_WithCorrectSelectionAfterFilteringOutNoApplicableItems()
{
var markup = @"
class Comparer
{
public static bool Equals(object x, object y) => true;
public bool Equals(object x) => true;
public bool Equals(string x, string y) => true;
}
class Program
{
static void Main(string x, string y)
{
var comparer = new Comparer();
comparer.Equals(x, y$$);
}
}";
var expectedOrderedItems = new List<SignatureHelpTestItem>
{
new SignatureHelpTestItem("bool Comparer.Equals(object x)", currentParameterIndex: 1),
new SignatureHelpTestItem("bool Comparer.Equals(string x, string y)", currentParameterIndex: 1, isSelected: true),
};
await TestAsync(markup, expectedOrderedItems);
}
}
}
@@ -931,6 +931,71 @@ End Class")
End Class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsRemoveUnusedMembers)>
<WorkItem(30895, "https://github.com/dotnet/roslyn/issues/30895")>
Public Async Function MethodWithHandlesClause() As Task
Await TestDiagnosticMissingAsync(
"Public Interface I
Event M()
End Interface
Public Class C
Private WithEvents _field1 As I
Private Sub [|M|]() Handles _field1.M
End Sub
End Class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsRemoveUnusedMembers)>
<WorkItem(30895, "https://github.com/dotnet/roslyn/issues/30895")>
Public Async Function FieldReferencedInHandlesClause() As Task
Await TestDiagnosticMissingAsync(
"Public Interface I
Event M()
End Interface
Public Class C
Private WithEvents [|_field1|] As I
Private Sub M() Handles _field1.M
End Sub
End Class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsRemoveUnusedMembers)>
<WorkItem(30895, "https://github.com/dotnet/roslyn/issues/30895")>
Public Async Function FieldReferencedInHandlesClause_02() As Task
Await TestDiagnosticMissingAsync(
"Public Interface I
Event M()
End Interface
Public Class C
Private WithEvents _field1 As I
Private WithEvents [|_field2|] As I
Private Sub M() Handles _field1.M, _field2.M
End Sub
End Class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsRemoveUnusedMembers)>
<WorkItem(30895, "https://github.com/dotnet/roslyn/issues/30895")>
Public Async Function EventReferencedInHandlesClause() As Task
Await TestDiagnosticMissingAsync(
"Public Class B
Private Event [|M|]()
Public Class C
Private WithEvents _field1 As B
Private Sub M() Handles _field1.M
End Sub
End Class
End Class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsRemoveUnusedMembers)>
Public Async Function PropertyIsArg() As Task
Await TestDiagnosticMissingAsync(
@@ -95,10 +95,11 @@ protected override async Task<SignatureHelpItems> GetItemsWorkerAsync(Document d
if (methodGroup.Any())
{
var selectedItem = TryGetSelectedIndex(methodGroup, symbolInfo);
var (items, selectedItem) =
GetMethodGroupItemsAndSelection(invocationExpression, semanticModel, symbolDisplayService, anonymousTypeDisplayService, documentationCommentFormattingService, within, methodGroup, symbolInfo, cancellationToken);
return CreateSignatureHelpItems(
GetMethodGroupItems(invocationExpression, semanticModel, symbolDisplayService, anonymousTypeDisplayService, documentationCommentFormattingService, within, methodGroup, cancellationToken),
items,
textSpan,
GetCurrentArgumentState(root, position, syntaxFacts, textSpan, cancellationToken),
selectedItem);
@@ -16,14 +16,15 @@ namespace Microsoft.CodeAnalysis.CSharp.SignatureHelp
{
internal partial class InvocationExpressionSignatureHelpProvider
{
private IList<SignatureHelpItem> GetMethodGroupItems(
private (IList<SignatureHelpItem>, int?) GetMethodGroupItemsAndSelection(
InvocationExpressionSyntax invocationExpression,
SemanticModel semanticModel,
ISymbolDisplayService symbolDisplayService,
IAnonymousTypeDisplayService anonymousTypeDisplayService,
IDocumentationCommentFormattingService documentationCommentFormattingService,
ISymbol within,
IEnumerable<IMethodSymbol> methodGroup,
SymbolInfo currentSymbol,
CancellationToken cancellationToken)
{
ITypeSymbol throughType = null;
@@ -58,17 +59,18 @@ internal partial class InvocationExpressionSignatureHelpProvider
methodGroup = methodGroup.Where(m => m.IsStatic);
}
var accessibleMethods = methodGroup.Where(m => m.IsAccessibleWithin(within, throughTypeOpt: throughType)).ToList();
if (accessibleMethods.Count == 0)
var accessibleMethods = methodGroup.Where(m => m.IsAccessibleWithin(within, throughTypeOpt: throughType)).ToImmutableArrayOrEmpty();
if (accessibleMethods.Length == 0)
{
return null;
return default;
}
var methodSet = accessibleMethods.ToSet();
accessibleMethods = accessibleMethods.Where(m => !IsHiddenByOtherMethod(m, methodSet)).ToList();
accessibleMethods = accessibleMethods.Where(m => !IsHiddenByOtherMethod(m, methodSet)).ToImmutableArrayOrEmpty();
return accessibleMethods.Select(m =>
ConvertMethodGroupMethod(m, invocationExpression, semanticModel, symbolDisplayService, anonymousTypeDisplayService, documentationCommentFormattingService, cancellationToken)).ToList();
return (accessibleMethods.Select(m =>
ConvertMethodGroupMethod(m, invocationExpression, semanticModel, symbolDisplayService, anonymousTypeDisplayService, documentationCommentFormattingService, cancellationToken)).ToList(),
TryGetSelectedIndex(accessibleMethods, currentSymbol));
}
private bool IsHiddenByOtherMethod(IMethodSymbol method, ISet<IMethodSymbol> methodSet)
Oops, something went wrong.

0 comments on commit e20ee16

Please sign in to comment.