diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e142989..d641a01f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -89,6 +89,11 @@ Status of the `main` branch. Changes prior to the next official version change w thread (#2038) * Language Servers: + - Fix: The C# language server opened every `.csproj` found anywhere under the repository root, + without consulting the project's ignore settings. On repositories that vendor third-party or + sample C# projects, this loads projects the server cannot restore on every start, and their + restore failures bury the diagnostics of the projects the user actually works on. Project + discovery now skips `.csproj` files matched by the project's ignore patterns - Kotlin: update the managed Kotlin LSP from `262.9593.0` to `263.4702.0`; the `262.9593.0` build has expired and fails on startup with "This build of intellij-server has expired" (#2008) - Fix: Godot's GDScript parser can report a symbol's end column one column past the diff --git a/src/solidlsp/language_servers/csharp_language_server.py b/src/solidlsp/language_servers/csharp_language_server.py index ce34f2e6..a411cc78 100644 --- a/src/solidlsp/language_servers/csharp_language_server.py +++ b/src/solidlsp/language_servers/csharp_language_server.py @@ -748,11 +748,24 @@ class CSharpLanguageServer(SolidLanguageServer): self.server.notify.send_notification("solution/open", {"solution": solution_uri}) log.debug(f"Opened solution file: {solution_file}") - # Find and open project files + # Find and open project files, skipping any that the project's ignore settings exclude. + # Vendored, third-party and sample trees routinely contain .csproj files that the language + # server cannot restore or build. Each one costs a project load on every server start, and + # the resulting restore failures bury the diagnostics of the projects the user cares about. project_files = [] + skipped = 0 for filename in breadth_first_file_scan(self.repository_root_path): - if filename.endswith(".csproj"): - project_files.append(filename) + if not filename.endswith(".csproj"): + continue + relative_path = os.path.relpath(filename, self.repository_root_path) + # ignore_unsupported_files=False, because a .csproj is not itself a C# source file and + # would otherwise be excluded on file type rather than by the ignore patterns. + if self.is_ignored_path(relative_path, ignore_unsupported_files=False): + skipped += 1 + continue + project_files.append(filename) + if skipped: + log.debug(f"Skipped {skipped} .csproj file(s) matched by the project's ignore settings") # Send project/open notifications for each project file if project_files: