dotnet / project-system

The .NET Project System for Visual Studio
MIT License
968 stars 386 forks source link

F1 context doesn't include TargetFrameworkMoniker #5574

Open terrajobst opened 4 years ago

terrajobst commented 4 years ago

When invoking help in the code editor, the current target framework isn't correctly forwarded.

In a .NET Framework 4.5 (old-CSPROJ) invoking F1 on Console.WriteLine yields this URL:

https://docs.microsoft.com/en-us/dotnet/api/system.console.writeline?f1url=https%3A%2F%2Fmsdn.microsoft.com%2Fquery%2Fdev16.query%3FappId%3DDev16IDEF1%26l%3DEN-US%26k%3Dk(System.Console.WriteLine);k(TargetFrameworkMoniker-.NETFramework,Version%3Dv4.5);k(DevLang-csharp)%26rd%3Dtrue&view=netframework-4.8

Invoking F1 in an SDK-style projects yields this URL:

https://docs.microsoft.com/en-us/dotnet/api/system.console.writeline?f1url=https%3A%2F%2Fmsdn.microsoft.com%2Fquery%2Fdev16.query%3FappId%3DDev16IDEF1%26l%3DEN-US%26k%3Dk(System.Console.WriteLine);k(DevLang-csharp)%26rd%3Dtrue&view=netframework-4.8

Notice how k(TargetFrameworkMoniker-.NETFramework,Version%3Dv4.5); is missing from the query string.

Currently, there is also a bug where the docs ignore the TargetFrameworkMoniker keyword: https://github.com/dotnet/docfx/issues/5183, so we should coordinate the change with them. The end-to-end we're going for is that the help filter on the landing page matches the current target framework. In a multi-targeted project, we probably want to honor whatever is currently selected in the top left drop down (i.e. the IntelliSense context).

VS Version Microsoft Visual Studio Enterprise 2019 Int Preview Version 16.4.0 Preview 2.0 [29402.240.master] VisualStudio.16.IntPreview/16.4.0-pre.2.0+29402.240.master Microsoft .NET Framework Version 4.8.03921 Installed Version: Enterprise Application Insights Tools for Visual Studio Package 9.1.00913.1 Application Insights Tools for Visual Studio ASP.NET and Web Tools 2019 16.4.269.3342 ASP.NET and Web Tools 2019 ASP.NET Web Frameworks and Tools 2019 16.4.269.3342 For additional information, visit https://www.asp.net/ AssemblyInfo Wizard 1.0 AssemblyInfo Wizard Azure App Service Tools v3.0.0 16.4.269.3342 Azure App Service Tools v3.0.0 Azure Functions and Web Jobs Tools 16.4.269.3342 Azure Functions and Web Jobs Tools C# Tools 3.4.0-beta2-19476-01+5ca953892a00380dd9e5d49d13f1d33a240a0005 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.10.7.8114 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 0x10 - v2.9.20905.5 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.0.87+gbb515bf382 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 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. NuGet Package Manager 5.4.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 Snapshot Debugging Extension 1.0 Snapshot Debugging Visual Studio Extension Detailed Info SQL Server Data Tools 16.0.61910.01140 Microsoft SQL Server Data Tools TypeScript Tools 16.0.10926.2001 TypeScript Tools for Microsoft Visual Studio Visual Basic Tools 3.4.0-beta2-19476-01+5ca953892a00380dd9e5d49d13f1d33a240a0005 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.4 for F# 4.6 16.4.0-beta.19475.4+e8b20b093d75f5050d805d10f9fe93dc57701347 Microsoft Visual F# Tools 10.4 for F# 4.6 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 Containers 1.0 Visual Studio Tools for Containers
davkean commented 4 years ago

@swesonga I have absolutely no idea how this works, it may have something to do with IVsUserContext.

davkean commented 4 years ago

@drewnoakes Removed multi-targeting as this isn't a multi-targeting bug, it just needs to be factored in.

davkean commented 4 years ago

It sets it here in particular: https://devdiv.visualstudio.com/DevDiv/_git/VS?path=%2Fsrc%2Fvsproject%2Fvsproject%2FCVsProjBaseFolderNode.cpp&version=GBmaster&line=1754&lineEnd=1755&lineStartColumn=1&lineEndColumn=1&lineStyle=plain.

davkean commented 4 years ago

Okay this is actually a pretty big work item, CPS basically doesn't support setting any "help context" at all, so the feature will be adding the ability to CPS to respond to VSHPROPID_UserContext for all nodes in a tree, and then have each node in the solution tree respond to this in the same way that legacy does, see GetUserContext usage under src/vsproject.

davidwengier commented 4 years ago

Based on the link to the legacy implementation, what we need here is something like the following:

terrajobst commented 3 years ago

Any chance this issue gets fixed in this release? We plan on adding nullable annotations to the API. The experience will be much more useful to our customers if the declaration displayed in the docs matches the project's framework.

drewnoakes commented 3 years ago

@terrajobst I'll pick this up for our current bug bash.

From https://dev.azure.com/ceapex/Engineering/_workitems/edit/130335 it looks like the work item is closed, however it doesn't support the actual TFM.

For example:

drewnoakes commented 3 years ago

Draft PR https://devdiv.visualstudio.com/DevDiv/_git/CPS/pullrequest/290913

drewnoakes commented 3 years ago

It seems support for non-.NET Framework targets was removed from the F1.Help service in this PR:

https://dev.azure.com/ceapex/Engineering/_git/Docs.F1/pullrequest/18986?_a=files&path=%2FSource%2FAPI%2Fappsettings.json&discussionId=285298