Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds .slnx support to the #r solution/project reference resolver, along with documentation and test coverage to prevent regressions.
Changes:
- Extend solution reference resolution to accept
.slnxin addition to.sln. - Add a regression test and a demo
.slnxfile under test data. - Update README and in-app help text to mention
.slnxreferences.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents that #r supports .slnx solution references. |
| CSharpRepl/ReadEvalPrintLoop.cs | Updates help text to include .slnx examples for #r. |
| CSharpRepl.Tests/EvaluationTests.cs | Adds a regression test that references a .slnx solution. |
| CSharpRepl.Tests/Data/DemoSolution/DemoSolution.slnx | Adds a demo .slnx file used by the new test. |
| CSharpRepl.Services/Roslyn/MetadataResolvers/SolutionFileMetadataResolver.cs | Extends resolver to recognize and open .slnx solutions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
28
to
34
| public override bool CanResolve(string reference) => | ||
| reference.EndsWith(".sln", StringComparison.OrdinalIgnoreCase) || | ||
| reference.EndsWith(".sln\"", StringComparison.OrdinalIgnoreCase) || | ||
| reference.EndsWith(".slnx", StringComparison.OrdinalIgnoreCase) || | ||
| reference.EndsWith(".slnx\"", StringComparison.OrdinalIgnoreCase) || | ||
| reference.EndsWith(".csproj", StringComparison.OrdinalIgnoreCase) || | ||
| reference.EndsWith(".csproj\"", StringComparison.OrdinalIgnoreCase); |
Comment on lines
59
to
64
| var projects = Path.GetExtension(solutionOrProject) switch | ||
| { | ||
| ".csproj" => [await workspace.OpenProjectAsync(solutionOrProject, cancellationToken: cancellationToken)], | ||
| ".sln" => (await workspace.OpenSolutionAsync(solutionOrProject, cancellationToken: cancellationToken)).Projects, | ||
| ".sln" or ".slnx" => (await workspace.OpenSolutionAsync(solutionOrProject, cancellationToken: cancellationToken)).Projects, | ||
| _ => throw new ArgumentException("Unexpected filetype for file " + solutionOrProject) | ||
| }; |
Comment on lines
+159
to
+169
| [Fact] | ||
| public async Task Evaluate_SolutionReference_ReferencesAllProjects_FromSlnx() | ||
| { | ||
| var referenceResult = await services.EvaluateAsync(@"#r ""./Data/DemoSolution/DemoSolution.slnx"""); | ||
| var importProject1Result = await services.EvaluateAsync(@"using DemoSolution.DemoProject1;"); | ||
| var importProject2Result = await services.EvaluateAsync(@"using DemoSolution.DemoProject2;"); | ||
|
|
||
| Assert.IsType<EvaluationResult.Success>(referenceResult); | ||
| Assert.IsType<EvaluationResult.Success>(importProject1Result); | ||
| Assert.IsType<EvaluationResult.Success>(importProject2Result); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.slnxsupport to the solution reference resolver used by#r.slnxfile in test data.slnxsolution referencesValidation
dotnet build CSharpRepl/CSharpRepl.csproj -c Debug#r ".../DemoSolution.slnx"now builds the solution and adds references when running the local binary