-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Local functions not available in intellisense/autocomplete #38074
Comments
I'm not sure that the parser would recognize that there is a local function in your example, preceded as it is by a garbage token. |
static void Main()
{
Loca
switch (Console.BackgroundColor)
{
default:
break;
}
Main();
void Local() { }
} This does not help either. Even in code with no syntax errors, static void Main()
{
Local(4, 2);
void Local(int a, int b) { }
} The Display parameter info command does not show any intellisense at the callsite. |
Hey IDE folks, is there some API not behaving as expected here, or is this just not implemented in the IDE? |
Regression in 16.3 Preview 2 relative to 15.9. Also works in 16.2.2. |
/cc @ivanbasov |
As far as I can tell, this regression was introduced by #35822, which probably explains why the issue happens in |
@gafter the issue is totally on the compiler side. The semantic model does not return local functions defined inside static members. I debugged it and found that local functions are filtered out inside static scopes if is no static modifier provided for it. I would consider this line: https://github.com/dotnet/roslyn/blob/master/src/Compilers/CSharp/Portable/Binder/Binder_Lookup.cs#L1468 Maybe it is worth to change it to |
I have submitted #38117, which fixes the completion issue using the approach suggested by @ivanbasov. But that still leaves the Display parameter info issue. In other words, the following test will still fail, even if that PR is merged: roslyn/src/EditorFeatures/CSharpTest/SignatureHelp/InvocationExpressionSignatureHelpProviderTests.cs Lines 2421 to 2437 in 62918fc
I suspect the problem is here: Lines 56 to 60 in 5551fad
I think this could be resolved by using |
@333fred What do you think is the right approach to address this? |
I like the idea of adding the API, though I'm not sure of the naming. |
Additionally, the docs will need to be clear where the potential differences between these two properties lies, as a naive first glance makes these properties appear identical. |
@svick @ivanbasov, is there a reason that the IDE can't just additionally filter based on |
@333fred not sure I understand you. Do you mean that you want to keep the binder code as is and correct IDE only by explicit adding items with |
That's correct. |
@333fred @ivanbasov i'm a little confused. It appears as if the issue is:
Could you be explicit about where that filtering is happening? Is it in IDE or code or in compiler code? If it's in IDE code, we could certainly fixup teh filtering. If it's compiler code, it's unclear to me what IDE could do as the filtering is happening before we ever see the symbol. |
@CyrusNajmabadi #38074 (comment). This is in the IDE layer, not the compiler. I'm not sure what RequiresInstanceReceiver would even do for you here. The IDE just needs to include all local functions that are in scope. |
Ok... :) But the IDE doesn't have logic for that. All we call is I think the problem is that the compiler is considering this not in scope, when we really want it to be for intellisense purposes in this scenario. IDE def doesn't want to reimpleemnt the "include all XXX in scope" logic. That's basically reimplementing the complex compiler rules that exist here and one of the reason we don't do that and instead use Does that help clear things up? |
I misunderstood the repro. A simpler repro is: static void Foo()
{
void Bar()
{
}
Bar$$ // Bar should appear here but doesn't.
} |
Ok. So i grossly misunderstood things. I think there are two feasible solutions. HOwever, i personally think it's totally ok to just do the expeditious thing here. i.e. we should just update Line 59 in 5551fad
I'm totally amenable to the idea that |
Version Used: 16..3.0 Preview 2.0
Steps to Reproduce:
Expected Behavior: Local function offered in autocomplete list and provided with intellisense support when typing arguments.
Actual Behavior: Local function not in the list and gets colorized only after arguments match the signature.
The text was updated successfully, but these errors were encountered: