Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signature help improvements for C# tuples (renamed to work around jenkins issues) #14289

Merged
merged 5 commits into from Oct 17, 2016

Conversation

rchande
Copy link
Contributor

@rchande rchande commented Oct 5, 2016

  • The invocation/initializer/objectcreation sighelp providers no longer dismiss sighelp if the user starts typing a tuple
  • When the user starts typing a tuple, show signature help for the tuple member types/names if the type of the tuple can be inferred

@rchande
Copy link
Contributor Author

rchande commented Oct 5, 2016

Tag @dotnet/roslyn-ide for review

@rchande
Copy link
Contributor Author

rchande commented Oct 5, 2016

Fixes #14138
Example screenshot:
image

@mattwar
Copy link
Contributor

mattwar commented Oct 5, 2016

@dotnet-bot test windows_release_unit64_prtest please

@mattwar
Copy link
Contributor

mattwar commented Oct 5, 2016

@dotnet-bot test windows_eta_open_prtest please

var expectedOrderedItems = new List<SignatureHelpTestItem>();
expectedOrderedItems.Add(new SignatureHelpTestItem("int C.Foo(object x)", currentParameterIndex: 0));

await TestAsync(markup, expectedOrderedItems, usePreviousCharAsTrigger: true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To verify dismissal locgic, you need to use the CommandHandler test suite. This test framework cannot do it properly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, dismissal happens because the user types a '(' or ',' and the system asks the provider to trigger on that typed char. We used to dismiss because we wouldn't trigger on the start of a tuple. I'll rename the tests to indicate this.

class C
{
(int, int) y = [|($$)
|]}";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the [||] for? Does it indicate the span of sig help? If so, why is the span here going out of the bounds of hte tuple?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, needed to use the expression's Span, not FullSpan.

var expectedOrderedItems = new List<SignatureHelpTestItem>();
expectedOrderedItems.Add(new SignatureHelpTestItem("(int, int)", currentParameterIndex: 1));

await TestAsync(markup, expectedOrderedItems, usePreviousCharAsTrigger: true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typing space triggers sig help?

var expectedOrderedItems = new List<SignatureHelpTestItem>();
expectedOrderedItems.Add(new SignatureHelpTestItem("(int, int)", currentParameterIndex: 1));

await TestAsync(markup, expectedOrderedItems, usePreviousCharAsTrigger: true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previous char is space, not a comma.

</Document>)

state.SendInvokeSignatureHelp()
Await state.AssertSelectedSignatureHelpItem(displayText:="(int a, string b)", selectedParameter:="string b")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the selected paramter "string b"?

if (token.IsKind(SyntaxKind.OpenParenToken) && token.Parent.IsKind(SyntaxKind.ParenthesizedExpression))
{
var parenthesizedExpr = ((ParenthesizedExpressionSyntax)token.Parent).WalkUpParentheses();
return parenthesizedExpr.Parent is ArgumentSyntax &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is expression is too complex and confusing. Can you break it out into simpler cases?

@@ -0,0 +1,192 @@
using System;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copyright.

if (TryGetTupleExpression(SignatureHelpTriggerReason.InvokeSignatureHelpCommand,
root, position, syntaxFacts, cancellationToken, out expression) &&
currentSpan.Start == expression.SpanStart)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too complex. Just have nested if statements.

// This could only have parsed as a parenthesized expression in these two cases:
// ($$)
// (name$$)
string name = 0.ToString(); // This causes the controller to match against the 0th tuple member
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need a name?

string name = 0.ToString(); // This causes the controller to match against the 0th tuple member
if (parenthesizedExpression.Expression is IdentifierNameSyntax)
{
name = ((IdentifierNameSyntax)parenthesizedExpression.Expression).Identifier.ValueText;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understsand what this is for.

return new SignatureHelpState(
argumentIndex: 0,
argumentCount: 0,
argumentName: name,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tuples don't have reorderable named arguments. i.e. if i have:

(int a, int b) = (b: 0, a: 0);

Then even in teh "b:0" case, we're still in the 0th argument that corresponds to 'int a'.

typeParts.Add(new SymbolDisplayPart(SymbolDisplayPartKind.PropertyName, null, elementName));
}

result.Add(new SignatureHelpParameter(parameterItemName, false, c => null, typeParts));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

false?


// The name used by the controller when selecting parameters
// Each element needs a unique name to make selection work property
private string GetParameterName(ImmutableArray<string> tupleElementNames, int i)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i => index

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't these be one-off? Tuple item names start at Item1 not Item0.

return tupleElementNames[i] ?? string.Empty;
}

private bool TryGetTupleExpression(SignatureHelpTriggerReason triggerReason, SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, CancellationToken cancellationToken, out TupleExpressionSyntax tupleExpression)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrap long lines that don't fit in github PR.

@rchande
Copy link
Contributor Author

rchande commented Oct 13, 2016

@333fred tests failed with:

hudson.util.HudsonFailedToLoad: java.io.IOException: Failed to create a temporary file in /jenkins
at hudson.WebAppMain$3.run(WebAppMain.java:237)
Caused by: java.io.IOException: Failed to create a temporary file in /jenkins
at hudson.util.AtomicFileWriter.(AtomicFileWriter.java:68)
at hudson.util.AtomicFileWriter.(AtomicFileWriter.java:55)
at hudson.util.TextFile.write(TextFile.java:118)
at jenkins.model.Jenkins.(Jenkins.java:794)
at hudson.model.Hudson.(Hudson.java:83)
at hudson.model.Hudson.(Hudson.java:79)
at hudson.WebAppMain$3.run(WebAppMain.java:225)
Caused by: java.io.IOException: Permission denied
at java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.io.File.createTempFile(File.java:2001)
at hudson.util.AtomicFileWriter.(AtomicFileWriter.java:66)
... 6 more

Another known issue?

@rchande
Copy link
Contributor Author

rchande commented Oct 13, 2016

test closed-perf please

@rchande
Copy link
Contributor Author

rchande commented Oct 13, 2016

test perf-closed

@rchande
Copy link
Contributor Author

rchande commented Oct 13, 2016

test perf-closed please

2 similar comments
@rchande
Copy link
Contributor Author

rchande commented Oct 13, 2016

test perf-closed please

@rchande
Copy link
Contributor Author

rchande commented Oct 13, 2016

test perf-closed please

@rchande
Copy link
Contributor Author

rchande commented Oct 13, 2016

retest this please

@rchande
Copy link
Contributor Author

rchande commented Oct 13, 2016

test closed-perf please

@333fred
Copy link
Member

333fred commented Oct 13, 2016

@rchande do you know which test is the one that failed? I'm attempting to find the build, but I don't know which one broke.

@rchande
Copy link
Contributor Author

rchande commented Oct 13, 2016

Sorry, @333fred, I didn't record which build that was.

@rchande
Copy link
Contributor Author

rchande commented Oct 13, 2016

@333fred FWIW, it looks like the tests are actually getting run now (not that that helps your investigation).

@rchande
Copy link
Contributor Author

rchande commented Oct 13, 2016

@dotnet-bot test perf please

@rchande
Copy link
Contributor Author

rchande commented Oct 13, 2016

test perf-closed please

@rchande
Copy link
Contributor Author

rchande commented Oct 13, 2016

retest vsi please

@rchande rchande changed the title Signature help improvements for C# tuples Signature help improvements for C# tuples (renamed to work around jenkins issues) Oct 17, 2016
@rchande
Copy link
Contributor Author

rchande commented Oct 17, 2016

@333fred Looks like a bunch of unit tests are failing with:

MESSAGE:
System.IO.FileLoadException : Could not load file or assembly 'Microsoft.VisualStudio.Language.Intellisense, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Known issue?

@rchande
Copy link
Contributor Author

rchande commented Oct 17, 2016

test internal-perf please

@rchande
Copy link
Contributor Author

rchande commented Oct 17, 2016

@dotnet-bot test internal-perf please

@333fred
Copy link
Member

333fred commented Oct 17, 2016

@rchande, that's a not a known issue.

@333fred
Copy link
Member

333fred commented Oct 17, 2016

Actually, @rchande, I believe they ran on one of the nodes that we just deleted as it had the wrong image. I'd try running it again and see if it's still failing.

@rchande
Copy link
Contributor Author

rchande commented Oct 17, 2016

Thanks @333fred will retest

@rchande
Copy link
Contributor Author

rchande commented Oct 17, 2016

retest this please

@rchande
Copy link
Contributor Author

rchande commented Oct 17, 2016

retest eta please

@rchande rchande merged commit c9f2edf into dotnet:master Oct 17, 2016
rchande pushed a commit to rchande/roslyn that referenced this pull request Oct 24, 2016
Signature help improvements for C# tuples (renamed to work around jenkins issues)
rchande pushed a commit that referenced this pull request Oct 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants