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

[O# Parity] Support dotnet script (.csx) files

Open awa5114 opened this issue 2 years ago • 7 comments

Type: Bug

Issue Description

Steps to Reproduce

  1. Create folder md scripting
  2. Navigate to the folder cd scripting
  3. Create a scripting project dotnet script init
  4. Add a file bye.csx
  5. Add some code into this file, e.g. Console.WriteLine("test");

Expected Behavior

The syntax highlighting works for file bye.csv

Actual Behavior

  • There is no syntax highlighting.
  • The error Request textDocument/signatureHelp failed appears image
  • The output log shows another error:
Using dotnet configured on PATH
Dotnet path: C:\Program Files\dotnet\dotnet.exe
Activating C# + C# Dev Kit + C# IntelliCode...
[Info  - 4:07:33 PM] [Program]Language server initialized
[Error - 4:07:50 PM] [LanguageServerHost]System.InvalidOperationException: Unexpected false - line 68
   at Roslyn.Utilities.Contract.Fail(String message, Int32 lineNumber) in /_/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/Contract.cs:line 154
   at Microsoft.CodeAnalysis.CSharp.SignatureHelp.InvocationExpressionSignatureHelpProviderBase.GetAccessibleMethods(InvocationExpressionSyntax invocationExpression, SemanticModel semanticModel, ISymbol within, IEnumerable`1 methodGroup, CancellationToken cancellationToken) in /_/src/Features/CSharp/Portable/SignatureHelp/InvocationExpressionSignatureHelpProviderBase_MethodGroup.cs:line 68
   at Microsoft.CodeAnalysis.CSharp.SignatureHelp.InvocationExpressionSignatureHelpProviderBase.GetItemsWorkerAsync(Document document, Int32 position, SignatureHelpTriggerInfo triggerInfo, SignatureHelpOptions options, CancellationToken cancellationToken) in /_/src/Features/CSharp/Portable/SignatureHelp/InvocationExpressionSignatureHelpProvider.cs:line 98
   at Microsoft.CodeAnalysis.SignatureHelp.AbstractSignatureHelpProvider.GetItemsAsync(Document document, Int32 position, SignatureHelpTriggerInfo triggerInfo, SignatureHelpOptions options, CancellationToken cancellationToken) in /_/src/Features/Core/Portable/SignatureHelp/AbstractSignatureHelpProvider.cs:line 245
   at Microsoft.CodeAnalysis.LanguageServer.Handler.SignatureHelpHandler.HandleRequestAsync(TextDocumentPositionParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/SignatureHelp/SignatureHelpHandler.cs:line 58
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, CancellationToken cancellationToken)
[Error - 4:07:50 PM] Request textDocument/signatureHelp failed.
  Message: Unexpected false - line 68
  Code: -32000 
[object Object]
Using dotnet configured on PATH

Logs

C# log

Post the output from Output-->C# here

C# LSP Trace Logs

Post the output from Output-->C# LSP Trace Logs here. Requires `dotnet.server.trace` to be set to `Trace`

Environment information

VSCode version: 1.82.2 C# Extension: 2.1.2 Using OmniSharp: false

Dotnet Information Error running dotnet --info: Error: Command failed: C:\Program Files\dotnet\dotnet.exe --info 'C:\Program' is not recognized as an internal or external command, operable program or batch file.

'C:\Program' is not recognized as an internal or external command, operable program or batch file.

Visual Studio Code Extensions
Extension Author Version Folder Name
csdevkit ms-dotnettools 0.4.10 ms-dotnettools.csdevkit-0.4.10-win32-x64
csharp ms-dotnettools 2.1.2 ms-dotnettools.csharp-2.1.2-win32-x64
dotnet-interactive-vscode ms-dotnettools 1.0.4461040 ms-dotnettools.dotnet-interactive-vscode-1.0.4461040
jupyter ms-toolsai 2023.8.1002501831 ms-toolsai.jupyter-2023.8.1002501831-win32-x64
jupyter-keymap ms-toolsai 1.1.2 ms-toolsai.jupyter-keymap-1.1.2
jupyter-renderers ms-toolsai 1.0.17 ms-toolsai.jupyter-renderers-1.0.17
LiveServer ritwickdey 5.7.9 ritwickdey.liveserver-5.7.9
msbuild-project-tools tintoy 0.4.9 tintoy.msbuild-project-tools-0.4.9
pdf tomoki1207 1.2.2 tomoki1207.pdf-1.2.2
powershell ms-vscode 2023.6.0 ms-vscode.powershell-2023.6.0
python ms-python 2023.16.0 ms-python.python-2023.16.0
run-on-save pucelle 1.6.0 pucelle.run-on-save-1.6.0
vscode-dotnet-pack ms-dotnettools 1.0.12 ms-dotnettools.vscode-dotnet-pack-1.0.12
vscode-dotnet-runtime ms-dotnettools 1.7.3 ms-dotnettools.vscode-dotnet-runtime-1.7.3
vscode-jupyter-cell-tags ms-toolsai 0.1.8 ms-toolsai.vscode-jupyter-cell-tags-0.1.8
vscode-jupyter-slideshow ms-toolsai 0.1.5 ms-toolsai.vscode-jupyter-slideshow-0.1.5
vscode-pylance ms-python 2023.9.20 ms-python.vscode-pylance-2023.9.20
vscodeintellicode-csharp ms-dotnettools 0.1.26 ms-dotnettools.vscodeintellicode-csharp-0.1.26-win32-x64

Extension version: 2.1.2 VS Code version: Code 1.82.2 (abd2f3db4bdb28f9e95536dfa84d8479f1eb312d, 2023-09-14T05:55:25.390Z) OS version: Windows_NT x64 10.0.19044 Modes:

System Info
Item Value
CPUs 11th Gen Intel(R) Core(TM) i9-11950H @ 2.60GHz (16 x 2611)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 63.67GB (48.67GB free)
Process Argv . --crash-reporter-id 9b73ea97-bda1-4db3-9fce-24ce43b1d8af
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscorecescf:30445987
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
pythonvs932:30410667
py29gd2263cf:30792227
vscaat:30438848
vsclangdc:30486549
c4g48928:30535728
dsvsc012cf:30540253
pynewext54:30695312
azure-dev_surveyone:30548225
2e4cg342:30602488
89544117:30613380
a9j8j154:30646983
showlangstatbar:30737416
03d35959:30757346
pythonfmttext:30731395
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
pythonnosmt12:30797651
pythonidxpt:30805730
pythonnoceb:30805159
copilotsettingc:30839828
dsvsc013:30795093
dsvsc014:30804076
diffeditorv2:30821572
dsvsc015:30829745

awa5114 avatar Sep 21 '23 14:09 awa5114

Ran into this issue tonight.

I had to add the following change to vscode settings

{
    "dotnet.server.useOmnisharp": true
}

Then I disabled the Dev Kit extension for a specific workspace where I'm writing dotnet script files. Doing this only affects that workspace and leaves the DevKit extension enabled globally for other workspaces where I'm writing typical libs or apps.

Once I disable the extension and reloaded vscode, it downloaded omnisharp. Then I had to reload vscode and restart the omnisharp server to get intellisense working.

Ideally it shouldn't require any configuration on the user's part to use dotnet script, but the above seems to work for now.

bowtiedgnome avatar Oct 11 '23 04:10 bowtiedgnome

CSX support is still missing from the new server, for now the workaround is to set dotnet.server.useOmnisharp to true as mentioned above.

dibarbet avatar Nov 09 '23 19:11 dibarbet

I'm having a similar issue as well, and the above workaround does work. However, the resulting inconsistencies in the configuration behavior of the global project are unacceptable, and it is hoped that the configuration behavior of the script mode and the development mode can be unified.

1m188 avatar Jan 17 '24 07:01 1m188