Open raafamaia opened 3 years ago
this is fixed in https://github.com/OmniSharp/omnisharp-vscode/pull/4178
I am having this issue as well.
Are you sure @filipw ? I am using 1.23.6 and I still need to manually restart Omnisharp after creating a file. No completion in the file, nor can I use the new class elsewhere otherwise.
I think you are right, this still has a problem.
@JoeRobich should this be fixed now? I can see that after a new file is created, and after the save it is reported to the server but then the completion request throws. I haven't debugged further but looks like the server sees the file as empty (?).
[dbug]: OmniSharp.Stdio.Host
************ Request ************
{
"Type": "request",
"Seq": 663,
"Command": "/completion",
"Arguments": {
"FileName": "/Users/filipw/Documents/dev/personal/repro/net50withnet48/app/Foo.cs",
"Line": 8,
"Column": 15,
"CompletionTrigger": 2,
"TriggerCharacter": "."
}
}
[fail]: OmniSharp.Stdio.Host
************ Response ************
{
"Request_seq": 663,
"Command": "/completion",
"Running": true,
"Success": false,
"Message": "\"System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.\\nParameter name: index\\n at Microsoft.CodeAnalysis.Text.SourceText+LineInfo.get_Item (System.Int32 index) [0x0000f] in <74e762f007514b0991a005183ec8dcb2>:0 \\n at Microsoft.CodeAnalysis.Text.TextLineCollection.GetPosition (Microsoft.CodeAnalysis.Text.LinePosition position) [0x00008] in <74e762f007514b0991a005183ec8dcb2>:0 \\n at OmniSharp.Extensions.SourceTextExtensions.GetTextPosition (Microsoft.CodeAnalysis.Text.SourceText sourceText, OmniSharp.Models.Request request) [0x00017] in <be259f9fdaf7461fb1b75b43208e4134>:0 \\n at OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService.Handle (OmniSharp.Models.v1.Completion.CompletionRequest request) [0x0016c] in <845c3087cc7d4530b36a8584d73f1c1d>:0 \\n at OmniSharp.Endpoint.EndpointHandler`2[TRequest,TResponse].GetFirstNotEmptyResponseFromHandlers (OmniSharp.Endpoint.Exports.ExportHandler`2[TRequest,TResponse][] handlers, TRequest request) [0x00099] in <0b3dc7d6f0c8428682a86ac3f9663775>:0 \\n at OmniSharp.Endpoint.EndpointHandler`2[TRequest,TResponse].HandleRequestForLanguage (System.String language, TRequest request, OmniSharp.Protocol.RequestPacket packet) [0x00163] in <0b3dc7d6f0c8428682a86ac3f9663775>:0 \\n at OmniSharp.Endpoint.EndpointHandler`2[TRequest,TResponse].Process (OmniSharp.Protocol.RequestPacket packet, OmniSharp.Endpoint.LanguageModel model, Newtonsoft.Json.Linq.JToken requestObject) [0x0024b] in <0b3dc7d6f0c8428682a86ac3f9663775>:0 \\n at OmniSharp.Stdio.Host.HandleRequest (System.String json, Microsoft.Extensions.Logging.ILogger logger) [0x000e7] in <0ff274924a1842faabf855aebc686508>:0 \"",
"Body": null,
"Seq": 880,
"Type": "response"
}
interesting is that I was partly correct 🙂 looks like it works on Windows, but not on MacOS
hum, it might be a distinct issue but here is an easy reproduction path on Windows:
dotnet new console
public Model MyProperty { get; set; }
Show Fixes (ctrl+;)
to create Model Generate type 'Model' -> Generate class 'Model' in a new file
now Model.cs is created but Program doesn't see the class, and you can't see the 'x references' hints in the new file.
Thanks, we had a look at that yesterday with @333fred and indeed it is a bug that crept in due to improvements in handling file changes and due to certain indeterminism in how VS Code sends file events to the server.
It is addressed in https://github.com/OmniSharp/omnisharp-roslyn/pull/2019
Nice, thanks!
When is this going to get released the the VS Code Marketplace?
@TCROC if you set omnisharp.path
to latest
in your settings, you should see it now.
@333fred Awesome thanks! I just created a new test script from Unity and it appears to be working :)
1. make a new folder, cd into it 2. `dotnet new console` 3. go edit Program class, add property : `public Model MyProperty { get; set; }` 4. use `Show Fixes (ctrl+;)` to create Model `Generate type 'Model' -> Generate class 'Model' in a new file`
now Model.cs is created but Program doesn't see the class, and you can't see the 'x references' hints in the new file.
This minimal example works for me having set omnisharp.path
to latest
, however within a Unity project adding a new C# script isn't recognised and I get the "Could not find document for file" warning, no autocompletions or reference counter
I'm using VSCodium 1.52.0, C# extension 1.23.7. I'm not massively familiar with C# development so please let me know what other debug info you need if you do
1. make a new folder, cd into it 2. `dotnet new console` 3. go edit Program class, add property : `public Model MyProperty { get; set; }` 4. use `Show Fixes (ctrl+;)` to create Model `Generate type 'Model' -> Generate class 'Model' in a new file`
now Model.cs is created but Program doesn't see the class, and you can't see the 'x references' hints in the new file.
This minimal example works for me having set
omnisharp.path
tolatest
, however within a Unity project adding a new C# script isn't recognised and I get the "Could not find document for file" warning, no autocompletions or reference counterI'm using VSCodium 1.52.0, C# extension 1.23.7. I'm not massively familiar with C# development so please let me know what other debug info you need if you do
I had the same problem. It is broken in 1.23.7. Do this to use the beta where it is fixed: https://github.com/OmniSharp/omnisharp-vscode/issues/4181#issuecomment-742668376
That's what I am doing - sorry if I wasn't clear. I set omnisharp.path
to latest
and the extension still isn't picking up new scripts in a Unity project I'm working on
The minimal example works though
@alpha-tango-kilo Sorry you are running into issues. Are you adding the script file outside of Unity?
I ask because Unity generates old style project files where each source file to be included is individually listed. This is different from SDK style projects created with dotnet new
which automatically include source files without needing them listed.
I am not sure that OmniSharp would add new files to the workspace without Unity rebuilding the project file to specifically include the source file.
I ask because Unity generates old style project files where each source file to be included is individually listed
I'm not surprised somehow
So I tested this and now I can't even replicate my own issue now 3 days later...
I tried (with Unity open in all cases):
Everything worked!🤯 Shall report back if I have any further issues down the line.
Also given Unity itself seems also to be a factor here, I'll note that the version I'm using is 2019.4.16f1
I did notice having this issue once when using the "latest" release. It was right after I created a new .asmdef file. I will see if I can recreate it later today.
Sorry it took me a minute to get around to testing this. I got caught up in some other projects. Anyway, I can confirm that adding an asmdef file breaks things. Steps to reproduce:
@TCROC I would check that Unity is updating the project file after adding the second asmdef and script. You should see a new <Compile Include="..Path to new script.." />
in the csproj.
@JoeRobich I can confirm that behavior is working as expected. When a new asmdef file is created, a new csproj is correctly created and that <Compile Include="..Path to new script.." />
is there. Omnisharp just isn't picking up on it and I have to restart Omnisharp.
@TCROC Does VS Code stay open with your unity project folder from step 4 thru step 8? or is it closed while adding the new asmdef and script?
@JoeRobich Unity and VS Code are both open the entire time
I misspoke, Unity is open the entire time and VS Code is open in steps 4 - 8
@TCROC Does VS Code stay open with your unity project folder from step 4 thru step 8? or is it closed while adding the new asmdef and script?
To further clarify, VS Code is open in steps 4 - 8.
Just checking in to see what the status is on this bug
I'm also seeing this issue in VSCode using extension version 1.23.8 and OmniSharp 1.37.6-beta.16. I'm not seeing any exceptions, just the Could not find document for file
message. I'm using a normal SDK-style csproj targeting net5.0.
I'm also seeing this issue in VSCode using extension version 1.23.8 and OmniSharp 1.37.6-beta.16. I'm not seeing any exceptions, just the
Could not find document for file
message. I'm using a normal SDK-style csproj targeting net5.0.
Me too, it's not working for me either and just giving that message.
I noticed that in the changelog of the C# extension it said:
For Mono-based development (e.g. Unity) that requires full .NET framework, you need to set "omnisharp.useGlobalMono": "always". The current value of "auto" will remain "never" until Mono upgrades their bundled MSBuild version.
I tried setting it to always, but it still won't work
For those of you who are still seeing this and aren't adding non csharp files (like tcroc is) please file a new issue with specific repro steps. I use the extension every day and have yet to reproduce the issue with csharp files, so more info is needed.
https://github.com/OmniSharp/omnisharp-vscode/issues/4181#issuecomment-742795336
This issue is occurring again for me. I've tested it in both Unity projects and Mono projects. Running on Ubuntu 20.04.
Edit: False alarm. See below comment.
This issue is occurring again for me. I've tested it in both Unity projects and Mono projects. Running on Ubuntu 20.04.
Never mind. False alarm. I just had to increase the file watcher limit on my system.
However, I would like to confirm that even with the file watchers limit increased, it still doesn't work when creating a new asmdef file in Unity (which is the equivalent of adding a new .csproj).
Issue Description
Hello!
I'm having some trouble using VSCode and the C# extension. Everytime I create a new file, the Intellisense doens't work, not showing any errors (red underline) on the file. The OmniSharp Log output shows the following message:
I reinstalled VSCode and deleted all my extensions folder rm -rf ~/.vscode*, just installed the C# extension and the error persists.
I'm using VSCode version 1.50.1 on a macOS Cataline 10.15.7, dotnet sdk 3.1.403
Steps to Reproduce
Clean Install of VSCode Install C# extension Create a dotnet webapi project
dotnet new webapi -n Test
Create a new file Write something ex: aaaaaaExpected Behavior
The expect behavior would be the line written with a red underscore, indicating an error.
Actual Behavior
Nothing happens, and you can check errors popping on the OmniSharp Log
Logs
OmniSharp log
C# log
Nothing on C# Log.
Environment information
VSCode version: 1.50.1 C# Extension: 1.23.5
Mono Information
OmniSharp using built-in monoDotnet Information
.NET Core SDK (reflecting any global.json): Version: 3.1.403 Commit: 9e895200cd Runtime Environment: OS Name: Mac OS X OS Version: 10.15 OS Platform: Darwin RID: osx.10.15-x64 Base Path: /usr/local/share/dotnet/sdk/3.1.403/ Host (useful for support): Version: 3.1.9 Commit: 774fc3d6a9 .NET Core SDKs installed: 2.0.3 [/usr/local/share/dotnet/sdk] 2.1.3 [/usr/local/share/dotnet/sdk] 3.1.403 [/usr/local/share/dotnet/sdk] .NET Core runtimes installed: Microsoft.AspNetCore.App 3.1.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.23 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-downloadVisual Studio Code Extensions
|Extension|Author|Version| |---|---|---| |csharp|ms-dotnettools|1.23.5|;