Repository navigation
Multi project support for the C# parser - #847
HorvathDaniel15 wants to merge 6 commits into
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.
| string csharpConnectionString = transformConnectionString(); | ||
|
|
||
| var options = new DbContextOptionsBuilder<CsharpDbContext>() | ||
| .UseNpgsql(csharpConnectionString) | ||
| .Options; | ||
|
|
||
| CsharpDbContext _context = new CsharpDbContext(options); | ||
| _context.Database.Migrate(); |
There was a problem hiding this comment.
The database context is created and migrations are applied before validating that any input paths were provided. This can cause unnecessary (and potentially destructive/slow) DB work even when the CLI invocation is invalid; consider validating args/_rootDir first, then migrating/creating the DbContext only for valid runs (and disposing it via using/await using).
There was a problem hiding this comment.
This thread was resolved, but no fix is present in the codebase.
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.
| private static async Task<Solution> LoadSolutionAsync(string solutionPath) | ||
| { | ||
| Console.WriteLine($"Loading solution: {solutionPath}"); | ||
| using var workspace = CreateMsBuildWorkspace(); | ||
|
|
||
| var solution = await workspace.OpenSolutionAsync(solutionPath); | ||
| Console.WriteLine($"Solution loaded: {solution.FilePath}"); | ||
| Console.WriteLine($"Projects found: {solution.Projects.Count()}"); | ||
| return solution; | ||
| } |
There was a problem hiding this comment.
@HorvathDaniel15 I think this is still an open issue.
| if (IsSolutionInput(primaryInput)) | ||
| { | ||
| await ParseSolutionPathAsync(primaryInput, csharpConnectionString, threadNum); | ||
| return 0; | ||
| } | ||
|
|
||
| if (IsProjectInput(primaryInput)) | ||
| { | ||
| var projectInputs = _rootDir | ||
| .Where(IsProjectInput) | ||
| .Distinct(StringComparer.OrdinalIgnoreCase) | ||
| .ToList(); | ||
|
|
||
| await ParseProjectsByPathAsync(projectInputs, csharpConnectionString, threadNum); | ||
| return 0; | ||
| } | ||
|
|
||
| if (Directory.Exists(primaryInput)) | ||
| { | ||
| await ParseLegacyMode(csharpConnectionString, threadNum); | ||
| return 0; |
There was a problem hiding this comment.
@HorvathDaniel15 Has been this fixed? If no fixing is required, please provide a counter-argument.
Resolves #823