vscode-csharp icon indicating copy to clipboard operation
vscode-csharp copied to clipboard

C# intellisense not getting triggered for the simplest of Uno application

Open explorest opened this issue 5 years ago • 3 comments

Issue Description

Default Uno template application creation in a folder does not trigger C# intellisense. This despite the root folder having a *.sln file and subfolders with .csproject files. When the same exact solution is opened in Visual Studio Community on windows --- C# intellisense does get generated.

[Note: Although closing the root folder (the one with *.sln file) and opening one of its the subfolders with .csproj in VSCode, does trigger intellisense normally. ]

Steps to Reproduce

On the main command line :

  1. $ mkdir UnoAppFolder
  2. $ cd UnoAppFolder
  3. $ code .
    Now on the integrated terminal :
  4. $ dotnet new -i Uno.ProjectTemplates.Dotnet
  5. $ dotnet new unoapp
  6. A solution gets created inside the "UnoAppFolder" with a .sln and global.json file. Many subfolders created. One of them represents a Shared project with a .shproj and .projitems file. Rest of the subfolders are all platform heads -- each of which contains a .csproj file.

Expected Behavior

C# intellisense should get triggered for all .cs files -- both in the root folder as well as subfolders.

Actual Behavior

No C# intellisense anywhere.

Logs

OmniSharp log

Starting OmniSharp server at 3/24/2021, 6:34:53 AM Target: /home/[username]/temp/UnoAppFolder/UnoAppFolder.sln

OmniSharp server started. Path: /home/[username]/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.6/run PID: 237829

Starting OmniSharp on ubuntu 20.4 (x64) info: OmniSharp.Services.DotNetCliService DotNetPath set to dotnet info: OmniSharp.MSBuild.Discovery.MSBuildLocator Located 1 MSBuild instance(s) 1: StandAlone 16.8.0 - "/home/[username]/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.6/omnisharp/.msbuild/Current/Bin" info: OmniSharp.MSBuild.Discovery.MSBuildLocator MSBUILD_EXE_PATH environment variable set to '/home/[username]/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.6/omnisharp/.msbuild/Current/Bin/MSBuild.exe' info: OmniSharp.MSBuild.Discovery.MSBuildLocator Registered MSBuild instance: StandAlone 16.8.0 - "/home/[username]/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.6/omnisharp/.msbuild/Current/Bin" CscToolExe = csc.exe MSBuildToolsPath = /home/[username]/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.6/omnisharp/.msbuild/Current/Bin CscToolPath = /home/[username]/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.6/omnisharp/.msbuild/Current/Bin/Roslyn BypassFrameworkInstallChecks = true MSBuildExtensionsPath = /home/[username]/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.6/omnisharp/.msbuild info: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0 info: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionOptionsProvider, Order: 0 info: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100 info: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110 info: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140 info: OmniSharp.Cake.CakeProjectSystem Detecting Cake files in '/home/[username]/temp/UnoAppFolder'. info: OmniSharp.Cake.CakeProjectSystem Could not find any Cake files info: OmniSharp.MSBuild.ProjectSystem Detecting projects in '/home/[username]/temp/UnoAppFolder/UnoAppFolder.sln'. [fail]: OmniSharp.WorkspaceInitializer The project system 'OmniSharp.MSBuild.ProjectSystem' threw exception during initialization. System.ArgumentException: An item with the same key has already been added. Key: Debug|Any CPU.ActiveCfg at System.Collections.Generic.Dictionary2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) [0x0015a] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0 at System.Collections.Generic.Dictionary2[TKey,TValue].Add (TKey key, TValue value) [0x00000] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0 at OmniSharp.MSBuild.ProjectSystem.GetProjectPathsAndIdsFromSolution (System.String solutionFilePath) [0x00104] in :0 at OmniSharp.MSBuild.ProjectSystem.GetInitialProjectPathsAndIds () [0x0002f] in :0 at OmniSharp.MSBuild.ProjectSystem.Initalize (Microsoft.Extensions.Configuration.IConfiguration configuration) [0x00158] in :0 at OmniSharp.WorkspaceInitializer.Initialize (System.IServiceProvider serviceProvider, System.Composition.Hosting.CompositionHost compositionHost) [0x00139] in :0 info: OmniSharp.Script.ScriptProjectSystem Detecting CSX files in '/home/[username]/temp/UnoAppFolder'. info: OmniSharp.Script.ScriptProjectSystem Could not find any CSX files info: OmniSharp.WorkspaceInitializer Configuration finished. info: OmniSharp.Stdio.Host Omnisharp server running using Stdio at location '/home/[username]/temp/UnoAppFolder' on host 237729.

C# log

No C# log gets generated in the output window

Environment information

VSCode version: 1.54.3 C# Extension: 1.23.9

Mono Information OmniSharp using built-in mono
Dotnet Information .NET SDK (reflecting any global.json): Version: 5.0.201 Commit: a09bd5c86c

Runtime Environment: OS Name: ubuntu OS Version: 20.04 OS Platform: Linux RID: ubuntu.20.04-x64 Base Path: /usr/share/dotnet/sdk/5.0.201/

Host (useful for support): Version: 5.0.4 Commit: f27d337295

.NET SDKs installed: 3.1.407 [/usr/share/dotnet/sdk] 5.0.201 [/usr/share/dotnet/sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 3.1.13 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.4 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.13 [/usr/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.4 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download

Visual Studio Code Extensions
Extension Author Version
cpptools ms-vscode 1.2.2
csharp ms-dotnettools 1.23.9
emulate DiemasMichiels 1.4.0
js-debug-nightly ms-vscode 2021.3.2317
jupyter ms-toolsai 2021.3.619093157
mono-debug ms-vscode 0.16.2
pdf tomoki1207 1.1.0
prettier-vscode esbenp 6.3.1
python ms-python 2021.3.658691958
vscode-sqlite alexcvzz 0.11.1

explorest avatar Mar 24 '21 02:03 explorest

Using "omnisharp.path": "1.37.0", on settings solve this for me. BUUUT, today with the release of a new version of the extension v1.37.0 does not work anymore 😢.

Starting OmniSharp server at 4/9/2021, 3:30:50 PM
    Target: c:\Users\mpro3\source\Documentation\Documentation.sln

OmniSharp server started.
    Path: c:\Users\mpro3\.vscode-insiders\extensions\ms-dotnettools.csharp-1.23.10\.omnisharp\1.37.0\OmniSharp.exe
    PID: 18352

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 3 MSBuild instance(s)
            1: Visual Studio Build Tools 2017 15.9.28307.1401 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
            2: Visual Studio Community 2019 16.10.31025.218 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin"
            3: StandAlone 16.8.0 - "c:\Users\mpro3\.vscode-insiders\extensions\ms-dotnettools.csharp-1.23.10\.omnisharp\1.37.0\.msbuild\Current\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Visual Studio Community 2019 16.10.31025.218 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin"
System.InvalidCastException: Specified cast is not valid.
   at Roslyn.Utilities.EventMap.GetRegistries_NoLock[TEventHandler](String eventName)
   at Roslyn.Utilities.EventMap.AddEventHandler[TEventHandler](String eventName, TEventHandler eventHandler)
   at lambda_method(Closure , LifetimeContext , CompositionOperation )
   at System.Composition.Hosting.Core.LifetimeContext.GetOrCreate(Int32 sharingId, CompositionOperation operation, CompositeActivator creator)
   at System.Composition.Hosting.Providers.ImportMany.ImportManyExportDescriptorProvider.<>c__DisplayClass3_2`1.<GetImportManyDescriptor>b__4(ExportDescriptor e)
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at lambda_method(Closure , LifetimeContext , CompositionOperation )
   at System.Composition.Hosting.Core.LifetimeContext.GetOrCreate(Int32 sharingId, CompositionOperation operation, CompositeActivator creator)
   at System.Composition.Hosting.Providers.ImportMany.ImportManyExportDescriptorProvider.<>c__DisplayClass3_2`1.<GetImportManyDescriptor>b__4(ExportDescriptor e)
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at System.Composition.Hosting.Core.CompositionOperation.Run(LifetimeContext outermostLifetimeContext, CompositeActivator compositionRootActivator)
   at System.Composition.Hosting.Core.LifetimeContext.TryGetExport(CompositionContract contract, Object& export)
   at System.Composition.CompositionContext.GetExport(CompositionContract contract)
   at System.Composition.CompositionContext.GetExports(Type exportType, String contractName)
   at System.Composition.CompositionContext.GetExports[TExport](String contractName)
   at OmniSharp.Stdio.Host.Initialize() in D:\a\1\s\src\OmniSharp.Stdio\Host.cs:line 57
   at OmniSharp.Stdio.Host..ctor(TextReader input, ISharedTextWriter writer, IOmniSharpEnvironment environment, IServiceProvider serviceProvider, CompositionHostBuilder compositionHostBuilder, ILoggerFactory loggerFactory, CancellationTokenSource cancellationTokenSource) in D:\a\1\s\src\OmniSharp.Stdio\Host.cs:line 51
   at OmniSharp.Stdio.Driver.Program.<>c__DisplayClass0_1.<Main>b__1() in D:\a\1\s\src\OmniSharp.Stdio.Driver\Program.cs:line 70
   at OmniSharp.HostHelpers.Start(Func`1 action) in D:\a\1\s\src\OmniSharp.Host\HostHelpers.cs:line 29
[ERROR] Error: OmniSharp server load timed out. Use the 'omnisharp.projectLoadTimeout' setting to override the default delay (one minute).

It remains to go back to the previous version, which I hate to have to recommend.

microhobby avatar Apr 09 '21 18:04 microhobby

Related: https://github.com/OmniSharp/omnisharp-roslyn/issues/2133

microhobby avatar Apr 09 '21 21:04 microhobby

The fix in the related issue https://github.com/OmniSharp/omnisharp-roslyn/issues/2133 worked for me as well. Closing this issue. Thanks a lot.

explorest avatar Apr 09 '21 22:04 explorest