dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.84k stars 666 forks source link

Document how to use with bare cs files #3420

Open xobs opened 4 years ago

xobs commented 4 years ago

Issue Description

The documentation states:

IntelliSense is not working
This is typically as a result of the current project type not being supported. You can see an indication in the OmniSharp flame in the bottom left hand side of the status bar.

I am working with Renode, where extensions are written in C# (much in the same way I gather Unity works). When I open these files, I don't see a flame, but I do get some C# features such as reference counting and autocomplete for System assemblies.

There is no documentation on how to add project-specific assemblies such as Renode's.

Steps to Reproduce

  1. Open a bare C# file (these aren't part of any project)
  2. Add some C# code that imports other assemblies, such as:

using System;
using System.Linq;
using Antmicro.Renode.Backends.Display;
using Antmicro.Renode.Core;
using Antmicro.Renode.Core.Structure.Registers;
using Antmicro.Renode.Logging;
using Antmicro.Renode.Peripherals.Bus;
using Antmicro.Renode.Peripherals.Memory;
using Antmicro.Renode.Utilities;

Expected Behavior

IntelliSense should either auto-complete the AntMicro packages, or give a warning that such packages cannot be found.

Actual Behavior

IntelliSense does nothing with the Antmicro packages. System packages auto-complete, however.

Logs

OmniSharp log

Starting OmniSharp server at 20/11/2019, 11:46:16 am
    Target: d:\Code\Renode\renode\betrusted

OmniSharp server started.
    Path: C:\Users\smcro\.vscode\extensions\ms-vscode.csharp-1.21.7\.omnisharp\1.34.7\OmniSharp.exe
    PID: 149372

[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.905 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
            2: Visual Studio Community 2017 15.9.28307.586 - "D:\Software\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin"
            3: StandAlone 16.3 - "C:\Users\smcro\.vscode\extensions\ms-vscode.csharp-1.21.7\.omnisharp\1.34.7\.msbuild\Current\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        MSBUILD_EXE_PATH environment variable set to 'C:\Users\smcro\.vscode\extensions\ms-vscode.csharp-1.21.7\.omnisharp\1.34.7\.msbuild\Current\Bin\MSBuild.exe'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: StandAlone 16.3 - "C:\Users\smcro\.vscode\extensions\ms-vscode.csharp-1.21.7\.omnisharp\1.34.7\.msbuild\Current\Bin"
            CscToolExe = csc.exe
            CscToolPath = C:\Users\smcro\.vscode\extensions\ms-vscode.csharp-1.21.7\.omnisharp\1.34.7\.msbuild\Current\Bin\Roslyn
            MSBuildExtensionsPath = C:\Users\smcro\.vscode\extensions\ms-vscode.csharp-1.21.7\.omnisharp\1.34.7\.msbuild
            MSBuildToolsPath = C:\Users\smcro\.vscode\extensions\ms-vscode.csharp-1.21.7\.omnisharp\1.34.7\.msbuild\Current\Bin
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in 'd:\Code\Renode\renode\betrusted'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
        No solution files found in 'd:\Code\Renode\renode\betrusted'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in 'd:\Code\Renode\renode\betrusted'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[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.RenameWorkspaceOptionsProvider, Order: 100
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.EditorConfigWorkspaceOptionsProvider, Order: 200
[info]: OmniSharp.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location 'd:\Code\Renode\renode\betrusted' on host 220188.
[info]: OmniSharp.OmniSharpWorkspace
        Miscellaneous file: d:\Code\Renode\renode\betrusted\fb.cs added to workspace
[info]: OmniSharp.OmniSharpWorkspace
        Miscellaneous file: d:\Code\Renode\renode\betrusted\fb.cs added to workspace
[info]: OmniSharp.OmniSharpWorkspace
        Miscellaneous file: d:\Code\Renode\renode\betrusted\fb copy.cs added to workspace
[info]: OmniSharp.OmniSharpWorkspace
        Miscellaneous file: d:\Code\Renode\renode\betrusted\kbd.cs added to workspace
[info]: OmniSharp.OmniSharpWorkspace
        Miscellaneous file: d:\Code\Renode\renode\betrusted\soc_spi.cs added to workspace
[info]: OmniSharp.OmniSharpWorkspace
        Miscellaneous file: d:\Code\Renode\renode\betrusted\spi_soc.cs added to workspace
[info]: OmniSharp.OmniSharpWorkspace
        Miscellaneous file: d:\Code\Renode\renode\betrusted\spi_soc copy.cs added to workspace
[info]: OmniSharp.OmniSharpWorkspace
        Miscellaneous file: d:\Code\Renode\renode\betrusted\spi_ec.cs added to workspace
[info]: OmniSharp.OmniSharpWorkspace
        Miscellaneous file: d:\Code\Renode\renode\betrusted\ticktimer_soc.cs added to workspace
[info]: OmniSharp.OmniSharpWorkspace
        Miscellaneous file: d:\Code\Renode\renode\betrusted\kbd_soc.cs added to workspace

C# log

Environment information

VSCode version: 1.40.1 C# Extension: 1.21.7

Dotnet Information .NET Core SDK (reflecting any global.json): Version: 2.1.505 Commit: b220231234 Runtime Environment: OS Name: Windows OS Version: 10.0.18362 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\2.1.505\ Host (useful for support): Version: 2.1.9 Commit: dcedc87d22 .NET Core SDKs installed: 2.1.201 [C:\Program Files\dotnet\sdk] 2.1.202 [C:\Program Files\dotnet\sdk] 2.1.400 [C:\Program Files\dotnet\sdk] 2.1.402 [C:\Program Files\dotnet\sdk] 2.1.403 [C:\Program Files\dotnet\sdk] 2.1.503 [C:\Program Files\dotnet\sdk] 2.1.505 [C:\Program Files\dotnet\sdk] .NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.9 [C:\Program Files\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| |---|---|---| |asciidoctor-vscode|joaompinto|2.7.6| |cmake-tools|ms-vscode|1.2.2| |code-beautifier|michelemelluso|2.3.3| |code-gnu-global|austin|0.2.2| |cpptools|ms-vscode|0.26.1| |csharp|ms-vscode|1.21.7| |powershell|ms-vscode|2019.11.0| |python|ms-python|2019.11.49689| |remote-wsl|ms-vscode-remote|0.40.3| |rewrap|stkb|1.9.1| |riscv|zhwu95|0.0.6| |rust|rust-lang|0.7.0| |scala-lsp|dragos|0.2.3| |smali|crazywolf|1.0.1| |spellright|ban|3.0.48| |veriloghdl|mshr-h|1.0.4| |vscode-html-css|ecmel|0.2.3| |vscode-markdownlint|DavidAnson|0.32.0|;
OperativeThunny commented 1 year ago

I too have this issue when trying to use vscode in the plugins directory for my Rust (facepunch video game). Would be nice to be able to easily specify DLLs to use as references to these bare .cs files in my game server directory somehow.

xobs commented 1 year ago

I did come up with a solution, which involves creating a fake .csproj file with references to all of the DLLs. I've documented it in my project here: https://github.com/betrusted-io/xous-core/tree/main/emulation#editing-renode-peripherals