dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.04k stars 4.03k forks source link

QuickInfo showing the wrong info #46799

Closed 333fred closed 4 years ago

333fred commented 4 years ago

image

I've seen a number of pictures like this, where some type (always a primitive type as far as I remember) shows the documentation comments for Win32.Registry instead of the actual docs for that type. I've never seen it happen personally and have absolutely no idea what scenario could cause it, but I've seen pictures of it in enough contexts (mainly as users in the discord server post images of it) that we should be tracking it.

333fred commented 4 years ago

And to be clear, every example that I've seen that I can remember has been on a primitive type, and all examples specifically show the docs for https://docs.microsoft.com/en-us/dotnet/api/microsoft.win32.registry?view=dotnet-plat-ext-3.1.

333fred commented 4 years ago

Anoter other example I was able to pull out of the C# discord: image

sharwell commented 4 years ago

https://developercommunity.visualstudio.com/content/problem/1104342/incorrect-code-suggestions.html

Erapchu commented 4 years ago

I have the same issue too. Code suggestions is incorrect mostly in old projects for me.

vaz-rodrigo commented 4 years ago

image

@sharwell I'm the one who posted the above image on the C# Discord. Is there some dump/info I can provide to help debug the problem? Unfortunately I can't provide the project because it is closed source but I can provide dependencies/framework versions and also any information regarding my VS copy! Thanks.

Xymanek commented 4 years ago

Repro (webforms project/web site): https://github.com/Xymanek/StringIsRegistryKeyRepro

Open TestString.aspx and TestString.aspx.cs. Observe:

image

image

image

Notes:

Microsoft Visual Studio Community 2019
Version 16.6.2
VisualStudio.16.Release/16.6.2+30204.135
Microsoft .NET Framework
Version 4.8.03761

Installed Version: Community

Visual C++ 2019   00435-60000-00000-AA776
Microsoft Visual C++ 2019

ASP.NET and Web Tools 2019   16.6.948.25768
ASP.NET and Web Tools 2019

ASP.NET Core Razor Language Services   16.1.0.2020603+b3ac44798c16fff5b95dbcfe62dea84aa9a1bd72
Provides languages services for ASP.NET Core Razor.

ASP.NET Web Frameworks and Tools 2019   16.6.948.25768
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0   16.6.948.25768
Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools   16.6.948.25768
Azure Functions and Web Jobs Tools

C# Tools   3.6.0-4.20251.5+910223b64f108fcf039012e0849befb46ace6e66
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

GitHub.VisualStudio   2.11.104.25275
A Visual Studio Extension that brings the GitHub Flow into Visual Studio.

IntelliCode Extension   1.0
IntelliCode Visual Studio Extension Detailed Info

Microsoft Azure Tools   2.9
Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.30212.1

Microsoft Continuous Delivery Tools for Visual Studio   0.4
Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Library Manager   2.1.50+g25aae5a24a.R
Install client-side libraries easily to any web project

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards   1.0
Microsoft Visual C++ Wizards

Microsoft Visual Studio Tools for Containers   1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

Microsoft Visual Studio VC Package   1.0
Microsoft Visual Studio VC Package

NuGet Package Manager   5.6.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

ProjectServicesPackage Extension   1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

SQL Server Data Tools   16.0.62006.03190
Microsoft SQL Server Data Tools

Test Adapter for Boost.Test   1.0
Enables Visual Studio's testing tools with unit tests written for Boost.Test.  The use terms and Third Party Notices are available in the extension installation directory.

Test Adapter for Google Test   1.0
Enables Visual Studio's testing tools with unit tests written for Google Test.  The use terms and Third Party Notices are available in the extension installation directory.

TypeScript Tools   16.0.20417.2002
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   3.6.0-4.20251.5+910223b64f108fcf039012e0849befb46ace6e66
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 10.9.1.0 for F# 4.7   16.6.0-beta.20217.4+1c969cac25e2d38d71872efe6c8226029e42bb59
Microsoft Visual F# Tools 10.9.1.0 for F# 4.7

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Container Tools Extensions (Preview)   1.0
View, manage, and diagnose containers within Visual Studio.

Visual Studio Tools for CMake   1.0
Visual Studio Tools for CMake

Visual Studio Tools for Containers   1.0
Visual Studio Tools for Containers
svick commented 4 years ago

I can reproduce the issue using @xymanek's repo. As far as I can tell, the problem is here:

https://github.com/dotnet/roslyn/blob/50d38db0bfac3c87e20a78505ca060070f6926d7/src/VisualStudio/Core/Def/Implementation/DocumentationComments/VisualStudioDocumentationProvider.cs#L42-L50

ParseMemberSignature produces 0 for methodID and GetMemberXML then in turn produces the documentation for Registry (presumably because it's the first type in mscorlib). Though memberIndex is IVsXMLMemberIndex, which is a native VS component, so I can't diagnose this further.

Erapchu commented 4 years ago

Ok, this project is simple and i can share it with some one who wants.

image

CyrusNajmabadi commented 4 years ago

@Erapchu please do share it. I can take a look.

Erapchu commented 4 years ago

WindowChromeExample.zip @CyrusNajmabadi There's.

CyrusNajmabadi commented 4 years ago

Reproes for me. investigating now.

CyrusNajmabadi commented 4 years ago

@jasonmalinowski @olegtk do you know who owns the IVsXMLMemberInder code? This appears to be an issue with it. In the example given we are asked to get the docs for E:System.Windows.Window.StateChanged (correct).

We first ask for what the memberId is here:

https://github.com/dotnet/roslyn/blob/fc4249d51723d8837ba951fd611420130a544c61/src/VisualStudio/Core/Def/Implementation/DocumentationComments/VisualStudioDocumentationProvider.cs#L42

This does not error, but also returns a value of 0 (likely indicating it failed internally, is returning a default value, but still indicating success). We then ask for the docs for methodId=0, getting these bogus docs returned.

One of two things is happening:

  1. the docs are unavailable, or cannot be found and IVsXMLMemberIndex is incorrectly succeeding when it should be failing.
  2. the docs have been found and hte functoin is succeeding, but inappropriately returning '0' as hte memberId, leading to bogus xml docs for this member.

This should be moved into VS as an important issue. But i need to know what path/user/group to assign to. Please advise on that. Thanks!

olegtk commented 4 years ago

Editor team owns IVsXMLMemberIndexer, please route the bug, @jinujoseph. CC @gundermanc

jasonmalinowski commented 4 years ago

The public feedback issue was https://developercommunity.visualstudio.com/content/problem/1104342/incorrect-code-suggestions.html -- thanks @CyrusNajmabadi for tracking this down. I saw it repro myself...but not under a debugger. 😦

CyrusNajmabadi commented 4 years ago

Tracking internally with https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1152642/