Multi project support for the C# parser#847
Multi project support for the C# parser#847HorvathDaniel15 wants to merge 1 commit intoEricsson:feature/csharp_pluginfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the C# parser to accept richer inputs (solutions/projects) and to better handle multiple inputs, enabling “multi-project” parsing via Roslyn/MSBuild rather than only directory-based discovery.
Changes:
- Add input validation and safer log parsing in the C++ wrapper (avoid empty-input and empty-line crashes; log non file-status output).
- Update the C# parser to support
.sln/.slnxand.csprojinputs usingMSBuildWorkspace, with a fallback path that extracts project paths from solution files. - Add Roslyn MSBuild workspace dependency and ignore
.DS_Store.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
plugins/csharp/parser/src/csharpparser.cpp |
Validates inputs and hardens parsing of the C# parser output stream. |
plugins/csharp/parser/src_csharp/Program.cs |
Implements solution/project loading via MSBuildWorkspace and multi-project processing with parallel document parsing. |
plugins/csharp/parser/src_csharp/CSharpParser.csproj |
Adds Microsoft.CodeAnalysis.Workspaces.MSBuild to support solution/project loading. |
.gitignore |
Ignores macOS .DS_Store. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Console.WriteLine($"Loading solution: {solutionPath}"); | ||
| var workspace = CreateMsBuildWorkspace(); | ||
|
|
||
| var solution = await workspace.OpenSolutionAsync(solutionPath); |
There was a problem hiding this comment.
The MSBuildWorkspace created here is not disposed. Since loading a solution can allocate significant resources, this can cause avoidable memory/file-handle usage. Wrap the workspace in a using/await using (or otherwise ensure Dispose() is called) once loading is complete.
There was a problem hiding this comment.
Valid memory optimization concern.
| if (projectPaths.Count == 0) | ||
| { | ||
| Console.Error.WriteLine($"No C# projects found in solution: {solutionPath}"); | ||
| return; |
There was a problem hiding this comment.
When no C# projects are found in the solution, this method logs an error and returns, but Main will still exit with code 0. That makes the wrapper/parser treat the run as successful even though nothing was parsed. Consider propagating failure (e.g., return a bool/int result or throw) so Main can exit non-zero in this case.
| return; | |
| throw new InvalidOperationException( | |
| $"No C# projects found in solution: {solutionPath}"); |
There was a problem hiding this comment.
Valid concern, since in case of other input errors, the program return with a non-zero exit code.
Resolves #823