You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Having watched files or paths is causing the workspace/didChangeWatchedFiles handler to try and 1:1 tranlate a glob pattern (valid paths can include .. anywhere) to a regular expression (very different semantics surrounding ..). This is causing a stacktrace dump on every single edit for watched files. Which includes all .cs files by default! The annoying thing is that I can't get this to reproduce upon first opening a project, but the repro steps account for that.
Steps to Reproduce
dotnet new <whatever>
create an empty directory within the project
Open and save the solution
save any CSharp file (no edits required, assuming format on save is enabled)
Reload VSCode
Save file again
close vscode and open it again
Any watched file being saved now results in an error
Expected Behavior
Watched files being processed regardless of file extension.
Actual Behavior
Only the text fragment/document requests succeed for things when explicitly passed to the LSP.
Logs
This one's dumped regardless:
[LanguageServerHost] [09:13:07.531][Start]workspace/didChangeWatchedFiles
[Error - 11:13:07 AM] [LanguageServerHost] System.ArgumentException: ".." can be only added at the beginning of the pattern.
at Microsoft.Extensions.FileSystemGlobbing.Internal.Patterns.PatternBuilder.Build(String pattern)
at Microsoft.Extensions.FileSystemGlobbing.Matcher.AddInclude(String pattern)
at Microsoft.Extensions.FileSystemGlobbing.MatcherExtensions.AddIncludePatterns(Matcher matcher, IEnumerable`1[] includePatternsGroups)
at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.LoadedProject.<>c.b__18_19(FileGlobs glob) in /_/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LoadedProject.cs:line 230
at System.Linq.Enumerable.SelectArrayIterator`2.Fill(ReadOnlySpan`1 source, Span`1 destination, Func`2 func)
at System.Linq.Enumerable.SelectArrayIterator`2.ToArray()
at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
--- End of stack trace from previous location ---
at System.LazyHelper.ThrowException()
at System.Lazy`1.CreateValue()
at System.Lazy`1.get_Value()
at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.LoadedProject.FileChangedContext_FileChanged(Object sender, String filePath) in /_/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LoadedProject.cs:line 76
at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.FileWatching.LspFileChangeWatcher.FileChangeContext.WatchedFilesHandler_OnNotificationRaised(Object sender, DidChangeWatchedFilesParams e) in /_/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/FileWatching/LspFileChangeWatcher.cs:line 103
at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.FileWatching.LspDidChangeWatchedFilesHandler.Microsoft.CommonLanguageServerProtocol.Framework.INotificationHandler.HandleNotificationAsync(DidChangeWatchedFilesParams request, RequestContext requestContext, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/FileWatching/LspDidChangeWatchedFilesHandler.cs:line 28
at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`1.StartRequestAsync[TRequest,TResponse](TRequest request, TRequestContext context, IMethodHandler handler, String language, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 199
[LanguageServerHost] [09:13:07.534][End]workspace/didChangeWatchedFiles
C# LSP Trace Logs
I would've pasted this in as a code block, but instead I learned issues have a hard upper bound character maximum today! csharp-lsp-trace.log.txt
have a free MRE repo. The problem persists after I removed the extra dir as well - but it might be picking up on obj or build. So I didn't run a gitignore, ensuring either one would be present for what should be instant fun?
I suspect we won't be able to use MS.Extensions.FileGlobbing and may need to copy the MSBuild glob evaluator. I recommend if you can to use C# Dev Kit as it should be more robust to these sorts of issues.
Type: Bug
Issue Description
Having watched files or paths is causing the workspace/didChangeWatchedFiles handler to try and 1:1 tranlate a glob pattern (valid paths can include
..
anywhere) to a regular expression (very different semantics surrounding..
). This is causing a stacktrace dump on every single edit for watched files. Which includes all.cs
files by default! The annoying thing is that I can't get this to reproduce upon first opening a project, but the repro steps account for that.Steps to Reproduce
dotnet new <whatever>
Expected Behavior
Watched files being processed regardless of file extension.
Actual Behavior
Only the text fragment/document requests succeed for things when explicitly passed to the LSP.
Logs
This one's dumped regardless:
C# LSP Trace Logs
I would've pasted this in as a code block, but instead I learned issues have a hard upper bound character maximum today!
csharp-lsp-trace.log.txt
C# log
Less big but still big
csharp-lsp.log.txt
Environment information
VSCode version: 1.94.2
C# Extension: 2.50.27
Using OmniSharp: false
Dotnet Information
.NET SDK: Version: 8.0.400 Commit: 36fe6dda56 Workload version: 8.0.400-manifests.6c274a57 MSBuild version: 17.11.3+0c8610977Runtime Environment:
OS Name: Windows
OS Version: 10.0.19045
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.400\
.NET workloads installed:
Configured to use loose manifests when installing new manifests.
There are no installed workloads to display.
Host:
Version: 8.0.8
Architecture: x64
Commit: 08338fcaa5
.NET SDKs installed:
7.0.317 [C:\Program Files\dotnet\sdk]
7.0.408 [C:\Program Files\dotnet\sdk]
7.0.410 [C:\Program Files\dotnet\sdk]
8.0.204 [C:\Program Files\dotnet\sdk]
8.0.206 [C:\Program Files\dotnet\sdk]
8.0.400 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.33 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.35 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.29 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.33 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.35 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.33 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.35 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.18 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
Visual Studio Code Extensions
According to the trace log, none of these register anything with the C# extension
Extension version: 2.50.27
VS Code version: Code 1.94.2 (384ff7382de624fb94dbaf6da11977bba1ecd427, 2024-10-09T16:08:44.566Z)
OS version: Windows_NT x64 10.0.19045
Modes:
System Info
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
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
The text was updated successfully, but these errors were encountered: