-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Search for slnx files when setting solution-relative content root #61305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
9478bcc
to
c4ac2d6
Compare
I think this implementation is both source and binary backwards compatible (except for the semantic change of now looking for slnx files too), but would like someone to verify that. For already compiled assemblies:
For recompiled assemblies:
|
Tests are failing for two reasons:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for searching .slnx files (XML-based solution files) when setting solution-relative content roots in the TestHost library. The functionality extends the existing UseSolutionRelativeContentRoot methods to support both traditional .sln and newer .slnx solution files by default.
Key changes:
- Updated the UseSolutionRelativeContentRoot method to search for both .sln and .slnx files by default
- Refactored the API to accept multiple solution file patterns via ReadOnlySpan
- Added comprehensive test coverage for .slnx file support
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
WebHostBuilderExtensions.cs | Modified UseSolutionRelativeContentRoot methods to support multiple solution file patterns and added .slnx support |
PublicAPI.Shipped.txt | Updated public API surface to reflect the new method signatures |
UseSolutionRelativeContentRootTests.cs | Added comprehensive test coverage for .slnx file detection and multiple solution file scenarios |
WebApplicationFactorySlnxTests.cs | Added integration tests verifying .slnx support works with WebApplicationFactory |
this IWebHostBuilder builder, | ||
string solutionRelativePath, | ||
string applicationBasePath, | ||
ReadOnlySpan<string> solutionNames = default) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this use IReadOnlyCollection<string>
or similar instead? It's not exactly performance sensitive.
var directoryInfo = new DirectoryInfo(applicationBasePath); | ||
do | ||
{ | ||
var solutionPath = Directory.EnumerateFiles(directoryInfo.FullName, solutionName).FirstOrDefault(); | ||
if (solutionPath != null) | ||
foreach (var solutionName in solutionNames) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be a LINQ query instead if you prefer.
@danroth27 not sure if this is on the roadmap for aspnetcore 10, but it would be great to get in and allow easy migration of sln → slnx. Even though this is a feature independent from dotnet and aspnetcore, I predict a lot of folks will adopt this around the .NET 10 time frame, so having the migration work seamlessly will be valuable to many customers. |
@halter73 do you have cycles to review this? slnx support does seem valuable for .NET 10 |
Search for slnx files when setting solution-relative content root
Fixes #61304