dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.85k stars 668 forks source link

Generated XML documentation for C# not working as expected #4378

Closed sethreidnz closed 3 years ago

sethreidnz commented 3 years ago

Issue Description

I have been following this PR here that is supposed to add suport for C# XML comment generation using /// if the setting editor.formatOnType is set to true.

https://github.com/OmniSharp/omnisharp-vscode/pull/4261

I've done this and it appears to not do anything. I've checked for updates on both the C# extension and vscode. See video below for what's happening:

https://drive.google.com/file/d/1j3jZgbR3R0ByN4eHWod35_5JvHL_KTM_/view?usp=sharing

Steps to Reproduce

Install C# extension, set editor.formatOnType: true, try to add xml comments to a class using ///.

Expected Behavior

The XML comments are generated

Actual Behavior

Nothing happens when you type ///

Logs

OmniSharp log

Post the output from Output-->OmniSharp log here

C# log

Post the output from Output-->C# here

Environment information

VSCode version: 1.52.1 C# Extension: 1.23.9

Mono Information OmniSharp using built-in mono
Dotnet Information .NET Core SDK (reflecting any global.json): Version: 3.1.402 Commit: 9b5de826fd Runtime Environment: OS Name: Mac OS X OS Version: 10.16 OS Platform: Darwin RID: osx.10.16-x64 Base Path: /usr/local/share/dotnet/sdk/3.1.402/ Host (useful for support): Version: 3.1.8 Commit: 9c1330dedd .NET Core SDKs installed: 2.2.207 [/usr/local/share/dotnet/sdk] 3.1.300 [/usr/local/share/dotnet/sdk] 3.1.402 [/usr/local/share/dotnet/sdk] .NET Core runtimes installed: Microsoft.AspNetCore.All 2.2.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.2.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.2.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download
Visual Studio Code Extensions |Extension|Author|Version| |---|---|---| |addDocComments|stevencl|0.0.8| |code-spell-checker|streetsidesoftware|1.10.2| |csharp|ms-dotnettools|1.23.9| |go|golang|0.22.0| |mdx|silvenon|0.1.0| |postcss|csstools|1.0.9| |prettier-vscode|esbenp|5.8.0| |quicktype|quicktype|12.0.46| |remote-containers|ms-vscode-remote|0.155.1| |spellright|ban|3.0.56| |vscode-docker|ms-azuretools|1.9.1| |vscode-eslint|dbaeumer|2.1.14| |vscode-jest-runner|firsttris|0.4.31| |vscode-react-native|msjsdiag|1.3.0| |vscode-sort-json|richie5um2|1.19.2| |vscode-tailwindcss|bradlc|0.5.8|;
filipw commented 3 years ago

can you set "omnisharp.loggingLevel": "debug" and post the OmniSharp log when this problem occurs? It definitely should be working.

333fred commented 3 years ago

It does not look like there is a loaded workspace in that video. There's no breadcrumbs at the top to say what namespace/class/member the cursor is currently in, and highlighting is using syntactic highlighting, not semantic highlighting. I suspect that once you figure that out, this feature will work fine.

sethreidnz commented 3 years ago

Okay so in one codebase I have it works just fine. But in another one it doesn't. Here is the omnisharp loggs for it and another video.

Pastebin (for not working project): https://pastebin.com/DDEPx8Di Pastebin (for working project): https://pastebin.com/tSjfKv3A Video including both: https://drive.google.com/file/d/1j3jZgbR3R0ByN4eHWod35_5JvHL_KTM_/view?usp=sharing

I don't really understand @333fred comment but in this video is there not a breadcrumb? IS it more complex than the following sudo logic?

if ("is C# and cursor is above a method/property/etc){ /// create the xml docs }

There is no real fundamental difference from an end-user perspective between these two projects. In fact the working one is on an old non-supported version of .net core even.

filipw commented 3 years ago

you need to post the full log, from the start of the server, the current version is abbreviated. But it looks like the project doesn't load and the failure should be somewhere around the start

sethreidnz commented 3 years ago

Sorry about that. Here it is, I did actually see a "failed to load" just a moment ago. But this paste is from cold start load of the project folder after closing vscode. I suspect your right perhaps there is something wrong with this project causing omnisharp to fail...

https://pastebin.com/WKjuf7vB

sethreidnz commented 3 years ago

Yeah looks like a bunch of Failure to load dotnet tools. Sorry if this is now qickly becoming the wrong place to discuss this, but don't really understand why this project is failing like that but the other is fine..

FAILURE: Could not locate '/Users/seth.reid/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.6/omnisharp/.msbuild/Current/Bin/Microsoft.Build.resources.dll'.
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Attempting to resolve 'Microsoft.Build.Tasks.Core.resources, Version=15.1.0.0, Culture=en-NZ, PublicKeyToken=b03f5f7f11d50a3a'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        FAILURE: Could not locate '/Users/seth.reid/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.6/omnisharp/.msbuild/Current/Bin/Microsoft.Build.Tasks.Core.resources.dll'.
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Attempting to resolve 'NuGet.Build.Tasks.resources, Version=5.8.0.6930, Culture=en-NZ, PublicKeyToken=31bf3856ad364e35'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        FAILURE: Could not locate '/Users/seth.reid/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.6/omnisharp/.msbuild/Current/Bin/NuGet.Build.Tasks.resources.dll'.
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Attempting to resolve 'NuGet.Build.Tasks.resources, Version=5.8.0.6930, Culture=en, PublicKeyToken=31bf3856ad364e35'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        FAILURE: Could not locate '/Users/seth.reid/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.6/omnisharp/.msbuild/Current/Bin/NuGet.Build.Tasks.resources.dll'.
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Attempting to resolve 'Microsoft.NET.Build.Tasks.resources, Version=3.1.2.37309, Culture=en-NZ, PublicKeyToken=31bf3856ad364e35'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        FAILURE: Could not locate '/Users/seth.reid/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.6/omnisharp/.msbuild/Current/Bin/Microsoft.NET.Build.Tasks.resources.dll'.
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Attempting to resolve 'Microsoft.NET.Build.Tasks.resources, Version=3.1.2.37309, Culture=en, PublicKeyToken=31bf3856ad364e35'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        FAILURE: Could not locate '/Users/seth.reid/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.6/omnisharp/.msbuild/Current/Bin/Microsoft.NET.Build.Tasks.resources.dll'.
333fred commented 3 years ago

The resource dlls are a red herring, they're unrelated. The real failure is this:

[warn]: OmniSharp.MSBuild.ProjectLoader
        The SDK resolver "Microsoft.DotNet.MSBuildSdkResolver" failed to run. Method not found: 'Microsoft.Build.Framework.SdkResult Microsoft.Build.Framework.SdkResultFactory.IndicateSuccess(System.String, System.String, System.Collections.Generic.IDictionary`2<System.String,System.String>, System.Collections.Generic.IDictionary`2<System.String,Microsoft.Build.Framework.SdkResultItem>, System.Collections.Generic.IEnumerable`1<System.String>)'.
[warn]: OmniSharp.MSBuild.ProjectLoader
        The SDK resolver "Microsoft.DotNet.MSBuildSdkResolver" failed to run. Method not found: 'Microsoft.Build.Framework.SdkResult Microsoft.Build.Framework.SdkResultFactory.IndicateSuccess(System.String, System.String, System.Collections.Generic.IDictionary`2<System.String,System.String>, System.Collections.Generic.IDictionary`2<System.String,Microsoft.Build.Framework.SdkResultItem>, System.Collections.Generic.IEnumerable`1<System.String>)'.
[warn]: OmniSharp.MSBuild.ProjectLoader
        The SDK resolver "Microsoft.DotNet.MSBuildSdkResolver" failed to run. Method not found: 'Microsoft.Build.Framework.SdkResult Microsoft.Build.Framework.SdkResultFactory.IndicateSuccess(System.String, System.String, System.Collections.Generic.IDictionary`2<System.String,System.String>, System.Collections.Generic.IDictionary`2<System.String,Microsoft.Build.Framework.SdkResultItem>, System.Collections.Generic.IEnumerable`1<System.String>)'.
[warn]: OmniSharp.MSBuild.ProjectLoader
        The SDK resolver "Microsoft.DotNet.MSBuildSdkResolver" failed to run. Method not found: 'Microsoft.Build.Framework.SdkResult Microsoft.Build.Framework.SdkResultFactory.IndicateSuccess(System.String, System.String, System.Collections.Generic.IDictionary`2<System.String,System.String>, System.Collections.Generic.IDictionary`2<System.String,Microsoft.Build.Framework.SdkResultItem>, System.Collections.Generic.IEnumerable`1<System.String>)'.
[warn]: OmniSharp.MSBuild.ProjectLoader
        The SDK resolver "Microsoft.DotNet.MSBuildSdkResolver" failed to run. Method not found: 'Microsoft.Build.Framework.SdkResult Microsoft.Build.Framework.SdkResultFactory.IndicateSuccess(System.String, System.String, System.Collections.Generic.IDictionary`2<System.String,System.String>, System.Collections.Generic.IDictionary`2<System.String,Microsoft.Build.Framework.SdkResultItem>, System.Collections.Generic.IEnumerable`1<System.String>)'.
[warn]: OmniSharp.MSBuild.ProjectLoader
        The SDK resolver "Microsoft.DotNet.MSBuildSdkResolver" failed to run. Method not found: 'Microsoft.Build.Framework.SdkResult Microsoft.Build.Framework.SdkResultFactory.IndicateSuccess(System.String, System.String, System.Collections.Generic.IDictionary`2<System.String,System.String>, System.Collections.Generic.IDictionary`2<System.String,Microsoft.Build.Framework.SdkResultItem>, System.Collections.Generic.IEnumerable`1<System.String>)'.

Can you share the project source?


As to the breadcrumbs, this is what I mean:

image

The project in the video didn't have those, which indicates that O# doesn't really know anything about the file. You probably don't get completion or other similar features.

JoeRobich commented 3 years ago

@sethreidnz As @333fred said, we do not ship localizations with our packaged build tools to keep the download size small. However, the Assembly loader will still try to resolve them and report these warnings.

I found this MSBuild issue where they fixed a breaking change with the SdkResultFactory.IndicateSuccess method (https://github.com/dotnet/msbuild/pull/5534). Try upgrading to the latest dotnet core 3.1405 sdk (https://dotnet.microsoft.com/download/dotnet-core/thank-you/sdk-3.1.405-macos-x64-installer) and see if you still get this error.

sethreidnz commented 3 years ago

Ahh I see, thanks for clarification. And unfortunately I cannot share the source. This is actually a project I don't work on a lot since I'm the UI engineer on the team and this is the API. I will have to just try to figure out why this is happening.

Any suspicions on why I would get an error like that? I'm wondering if its something to do with the version of .net the project has and what I'm running locally... But this happens to another engineer on our team but has just been ignoring it (the error from omnisharp about failing to load a project). Is it easy to tell from the errors which project is failling? I'm having trouble being able to tell..

Anyway, thanks for you help, if I figure this out I will reply to the thread. I'll close out the issue for now.

sethreidnz commented 3 years ago

@sethreidnz As @333fred said, we do not ship localizations with our packaged build tools to keep the download size small. However, the Assembly loader will still try to resolve them and report these warnings.

I found this MSBuild issue where they fixed a breaking change with the SdkResultFactory.IndicateSuccess method (dotnet/msbuild#5534). Try upgrading to the latest dotnet core 3.1405 sdk (https://dotnet.microsoft.com/download/dotnet-core/thank-you/sdk-3.1.405-macos-x64-installer) and see if you still get this error.

Okay thanks for that I will investigate that!