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

Interface completion provider shows objects fix #18574

Closed
wants to merge 2 commits into from
Closed

Interface completion provider shows objects fix #18574

wants to merge 2 commits into from

Conversation

SeanFarrow
Copy link

@SeanFarrow SeanFarrow commented Apr 10, 2017

Fixing issue #15988 to prevent methods from the object base class showing up when the completion list is requested from the ExplicitInterfaceCompletionProvider.

…a list of completions is requested from the ExplicitInterfaceCompletionProvider.
@CyrusNajmabadi
Copy link
Member

Hi Sean,

I pulled down your branch and had no problem exercising your test. As it doesn't do much, it passes simply. If i add something like an Assert.True(false); call in it, then it fails as expected.

What are you seeing yourself?

@CyrusNajmabadi
Copy link
Member

Example of the error i get when i add a failing assert to your test:

Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Completion.CompletionProviders.ExplicitInterfaceCompletionProviderTests.EnsureNoObjectMembersAreShown FAILED:
	Exception type: 'Xunit.Sdk.TrueException', number: '0', parent: '-1'
	Exception message:
Assert.True() Failure
Expected: True
Actual:   False
	Exception stacktrace
   at Xunit.Assert.True(Nullable`1 condition, String userMessage) in C:\BuildAgent\work\cb37e9acf085d108\src\xunit.assert\Asserts\BooleanAsserts.cs:line 95
   at Xunit.Assert.True(Boolean condition) in C:\BuildAgent\work\cb37e9acf085d108\src\xunit.assert\Asserts\BooleanAsserts.cs:line 62
   at Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Completion.CompletionProviders.ExplicitInterfaceCompletionProviderTests.<EnsureNoObjectMembersAreShown>d__5.MoveNext() in C:\GitHub\roslyn-internal\Open\src\EditorFeatures\CSharpTest\Completion\CompletionProviders\ExplicitInterfaceCompletionProviderTests.cs:line 116
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Xunit.Sdk.TestInvoker`1.<>c__DisplayClass48_1.<<InvokeTestMethodAsync>b__1>d.MoveNext() in C:\BuildAgent\work\cb37e9acf085d108\src\xunit.execution\Sdk\Frameworks\Runners\TestInvoker.cs:line 260
...

@SeanFarrow
Copy link
Author

SeanFarrow commented Apr 10, 2017 via email

@CyrusNajmabadi
Copy link
Member

Hi Sean! How are you currently executing tests? If you use xunit.runner.console you should be able to pass certain args to get it to test only a specific test, or a set of tests with a provided "trait". Let me see if i can hunt down some specific instructions on how to do this!

@SeanFarrow
Copy link
Author

SeanFarrow commented Apr 10, 2017 via email

@CyrusNajmabadi
Copy link
Member

I see. Here's what you can do from teh command line to make things a lot easier:

xunit.console.x86.exe C:\GitHub\roslyn-internal\Open\Binaries\Debug\UnitTests\CSharpEditorServicesTest\Roslyn.Ser
vices.Editor.CSharp.UnitTests.dll  -method Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Completion.CompletionProviders
.ExplicitInterfaceCompletionProviderTests.EnsureNoObjectMembersAreShown
xUnit.net Console Runner (32-bit .NET 4.0.30319.42000)
  Discovering: Roslyn.Services.Editor.CSharp.UnitTests
  Discovered:  Roslyn.Services.Editor.CSharp.UnitTests
  Starting:    Roslyn.Services.Editor.CSharp.UnitTests
Period index is 41
    Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Completion.CompletionProviders.ExplicitInterfaceCompletionProviderTests.EnsureNoObjectMembersAreShown [FAIL]
      Assert.True() Failure
      Expected: True
      Actual:   False
      Stack Trace:
        src\EditorFeatures\CSharpTest\Completion\CompletionProviders\ExplicitInterfaceCompletionProviderTests.cs(116,0): at Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Completion.CompletionProviders.ExplicitInterfaceCompletionProviderTests.<EnsureNoObjectMembersAreShown>d__5.MoveNext()

Here i'm just asking xunit to run the tests for this particular assembly, and i'm only asking it to run that specific test in that assembly.

@CyrusNajmabadi
Copy link
Member

It would be nice if we could filter out what test/assemblies would run using this infrastructure, perhaps a new issue is required?

That sounds like a totally reasonable suggestion. I'm unfamiliar with that part of our infrastructure, but maybe someone would be able to make that happen. In the meantime though, i hope that the specific xunit.runner instructions will be able to unblock you!

@SeanFarrow
Copy link
Author

SeanFarrow commented Apr 10, 2017 via email

@CyrusNajmabadi
Copy link
Member

Hi Sean! I'm not really the best person to answer those types of questions. :-) I recommend raising the issue, and tagging dotnet/roslyn-infrastructure and jaredpar to discuss things with.

I will say that changing our infrastructure is non trivial. But if significant value can be demonstrated, it may be possible!

@SeanFarrow
Copy link
Author

SeanFarrow commented Apr 10, 2017 via email

@CyrusNajmabadi
Copy link
Member

Hey Sean,

The original suggestion that a test be written in ExplicitInterfaceCompletionProviderTests.cs was based on the supposition that the problem lies in the ExplicitInterfaceCompletionProvider itself. This supposition may be incorrect.

In order to figure out where the right test would go, you'll actually need to figure out where the problem is arising that's causing the errant members to be shown. My psychic debugging hat tells me that it's highly likely that the extra entries would be created by either the ExplicitInterfaceCompletionProvider or the SymbolCompletionProvider. As we've tentatively eliminated the former, the latter is probably the most likely cause of the issue.

I recommend actually trying to debug through the scenario to see what is producing this errant item. That will then help us determine the right fix, which will finally help direct where the tests should go.

Also, I’m unable to debug this as there is an OperationCancelledException in one of the diagnostic tests being thrown, so my test never gets to the stage where I can debug it.

I'm not quite understanding that. Cancellation-exceptions shouldn't prevent a test from being debuggable.

@SeanFarrow
Copy link
Author

SeanFarrow commented Apr 15, 2017 via email

@CyrusNajmabadi
Copy link
Member

What makes you think it’s in the SymbolCompletionProvider?

Just a gut feeling, given that you said that the ExplicitInterfaceMemberCompletionProvider did not report any results.

However, when i debug through here, i see that it is the ExplicitInterfaceMemberCompletionProvider returning these:

>	Microsoft.CodeAnalysis.CSharp.Completion.Providers.ExplicitInterfaceMemberCompletionProvider.ProvideCompletionsAsync(context)	C#
 	Microsoft.CodeAnalysis.Completion.CompletionServiceWithProviders.GetContextAsync(provider, document, position, triggerInfo, options, defaultSpan, cancellationToken)	C#
 	Microsoft.CodeAnalysis.Completion.CompletionServiceWithProviders.ComputeNonEmptyCompletionContextsAsync(document, caretPosition, trigger, options, defaultItemSpan, providers, cancellationToken)	C#
 	Microsoft.CodeAnalysis.Completion.CompletionServiceWithProviders.GetCompletionsAsync(document, caretPosition, trigger, roles, options, cancellationToken)	C#
 	Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.Completion.Controller.Session.ModelComputer.GetCompletionListAsync(completionService, trigger, cancellationToken)	C#

When we call:

            var members = semanticModel.LookupSymbols(
                position: name.SpanStart,
                container: symbol)
                    .WhereAsArray(s => !s.IsStatic)
                    .FilterToVisibleAndBrowsableSymbols(options.GetOption(CompletionOptions.HideAdvancedMembers, semanticModel.Language), semanticModel.Compilation);

We get a list back with 5 members, including members of object.

IMO, it's wrong for us to even be calling LookupMembers here. We've got the interface symbol already in the "symbol" variable. What we can do at that point is simply call .GetMembers on that, filtering down to just events, properties and methods.

@jaredpar
Copy link
Member

We apologize, but we are closing this PR due to code drift. We regret letting this PR go so long without attention, but at this point the code base has changed too much for us to revisit older PRs. Going forward, we will manage PRs better under an SLA currently under draft in issue #26266 – we encourage you to add comments to that draft as you see fit. Although that SLA is still in draft form, we nevertheless want to move forward with the identification of older PRs to give contributors as much early notice as possible to review and update them.

If you are interested in pursuing this PR, please reset it against the head of master and we will reopen it. Thank you!

@jaredpar jaredpar closed this Apr 24, 2018
@jaredpar jaredpar added the Resolution-Expired The request is closed due to inactivity under our contribution review policy. label Apr 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE cla-already-signed Resolution-Expired The request is closed due to inactivity under our contribution review policy.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants