Skip to content

supporting types from params in intellisense#36040

Merged
ivanbasov merged 2 commits intodotnet:masterfrom
ivanbasov:params
Jun 3, 2019
Merged

supporting types from params in intellisense#36040
ivanbasov merged 2 commits intodotnet:masterfrom
ivanbasov:params

Conversation

@ivanbasov
Copy link
Copy Markdown
Contributor

Fixes #36029

@ivanbasov ivanbasov added Bug Regression IDE-IntelliSense Completion, Signature Help, Quick Info labels May 29, 2019
@ivanbasov
Copy link
Copy Markdown
Contributor Author

ivanbasov commented May 29, 2019

Thank you for reporting this, @matoushan! #Resolved

@ivanbasov ivanbasov added this to the 16.2.P3 milestone May 29, 2019
@ivanbasov
Copy link
Copy Markdown
Contributor Author

ivanbasov commented May 29, 2019

This seems to be a regression introduced by #34312 #Resolved

@ivanbasov
Copy link
Copy Markdown
Contributor Author

ivanbasov commented May 31, 2019

@jasonmalinowski , @genlu , @dpoeschl , @CyrusNajmabadi , please review #Resolved

if (expressionSymbol != null &&
type is INamedTypeSymbol expressionSymbolNamedTypeCandidate &&
expressionSymbolNamedTypeCandidate.OriginalDefinition.Equals(expressionSymbol))
var arrayType = method.Parameters.LastOrDefault().Type;
Copy link
Copy Markdown
Contributor

@CyrusNajmabadi CyrusNajmabadi May 31, 2019

Choose a reason for hiding this comment

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

LastOrDefault().? #Resolved

type is INamedTypeSymbol expressionSymbolNamedTypeCandidate &&
expressionSymbolNamedTypeCandidate.OriginalDefinition.Equals(expressionSymbol))
var arrayType = method.Parameters.LastOrDefault().Type;
type = ((IArrayTypeSymbol)arrayType).ElementType;
Copy link
Copy Markdown
Contributor

@CyrusNajmabadi CyrusNajmabadi May 31, 2019

Choose a reason for hiding this comment

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

i don't know if it's guaranteed that it will be an array. can you test something like params int i? #Resolved

Copy link
Copy Markdown
Contributor

@CyrusNajmabadi CyrusNajmabadi May 31, 2019

Choose a reason for hiding this comment

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

also, the compiler/language may not always provide an array here in the future (for example: params IEnumerable). So best to actually explicitly check for the array case and bail otherwise. #Resolved

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

param int i is not an allowed syntax: The params parameter must be a single dimensional array.

I agree that we should check if it is an array and bail out otherwise. However, I do not think we should have a test case for the incorrect syntax.


In reply to: 289223266 [](ancestors = 289223266)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

param int i is not an allowed syntax: The params parameter must be a single dimensional array.

I don't think that's strictly true. Namely, the parser totally allows this (though later passes may error if they see somethin that was a non-array).

I agree that we should check if it is an array and bail out otherwise. However, I do not think we should have a test case for the incorrect syntax.

The test case just validates we dont crash :) I don't expect the user experience to be one we cater to. I just want us to not crash, and to have a test that prevents us from regressing in the future :)

var arrayType = method.Parameters.LastOrDefault().Type;
type = ((IArrayTypeSymbol)arrayType).ElementType;
}
else if (method.Parameters.Length > ordinalInInvocation)
Copy link
Copy Markdown
Contributor

@CyrusNajmabadi CyrusNajmabadi May 31, 2019

Choose a reason for hiding this comment

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

can you flip this? this just reads weird to me :) #Resolved

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

CyrusNajmabadi commented May 31, 2019

Note to reviewers. Turn off whitespace changes. it wil lmake it much easier to review :) #Resolved

Copy link
Copy Markdown
Contributor

@CyrusNajmabadi CyrusNajmabadi left a comment

Choose a reason for hiding this comment

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

LGTM with a couple of suggestions/tests to look into.

Approve
Submit feedback approving these changes.

@ivanbasov
Copy link
Copy Markdown
Contributor Author

ivanbasov commented May 31, 2019

@jasonmalinowski , @dpoeschl , @genlu , please review. #Resolved

1 similar comment
@ivanbasov
Copy link
Copy Markdown
Contributor Author

ivanbasov commented Jun 3, 2019

@jasonmalinowski , @dpoeschl , @genlu , please review. #Resolved

Copy link
Copy Markdown
Member

@JoeRobich JoeRobich left a comment

Choose a reason for hiding this comment

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

LGTM


if (type.IsDelegateType())
{
var methods = type.GetMembers(WellKnownMemberNames.DelegateInvokeName);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we also support params in the case of delegates?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you, @JoeRobich !

Let us consider the following delegate:

        public delegate void Delegate1(Guid g, params Uri[] u);
        public void M(Delegate1 d) { }
  1. M((g, u) => { u.$$ }) - here the compiler would consider u as an array not as the first element.
  2. M((g, u, v) => { $$ }) - the delegate does not take 3 arguments.
  3. M((Guid g, params Uri[] u) => { }) - params is not valid in the context.
  4. M((Guid g, Uri[] u) => { u.$$ }) - here the compiler would consider u as an array not as the first element.

If you see an example, please let me know. Then, we will make a separate fix for it.

@ivanbasov ivanbasov merged commit 1e8d4d2 into dotnet:master Jun 3, 2019
@ivanbasov ivanbasov deleted the params branch June 3, 2019 23:46
JoeRobich added a commit that referenced this pull request Jun 5, 2019
@ivanbasov ivanbasov mentioned this pull request Jun 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug IDE-IntelliSense Completion, Signature Help, Quick Info Regression

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vs16.1.0 can not find navigation properties in the Completion preview list

3 participants