-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Open
Labels
api-ready-for-reviewAPI is ready for formal API review - https://github.com/dotnet/apireviewsAPI is ready for formal API review - https://github.com/dotnet/apireviewsarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsfeature-mvc-testingMVC testing packageMVC testing package
Milestone
Description
Background and Motivation
WebApplicationFactory tries setting the content root based on a number of sources (a builder setting, MvcTestingAppManifest.json, and the assembly metadata) before falling back to setting a solution-relative content root. This looks specifically for a .sln file, which means any test that relies on it breaks when migrating to the new SLNX solution format.
A proposed implementation can be found here: #61305
Proposed API
namespace Microsoft.AspNetCore.TestHost;
public static class WebHostBuilderExtensions
{
- public static Microsoft.AspNetCore.Hosting.IWebHostBuilder UseSolutionRelativeContentRoot(this Microsoft.AspNetCore.Hosting.IWebHostBuilder builder, string solutionRelativePath, string solutionName = "*.sln");
- public static Microsoft.AspNetCore.Hosting.IWebHostBuilder UseSolutionRelativeContentRoot(this Microsoft.AspNetCore.Hosting.IWebHostBuilder builder, string solutionRelativePath, string applicationBasePath, string solutionName = "*.sln");
+ public static Microsoft.AspNetCore.Hosting.IWebHostBuilder UseSolutionRelativeContentRoot(this Microsoft.AspNetCore.Hosting.IWebHostBuilder builder, string solutionRelativePath);
+ public static Microsoft.AspNetCore.Hosting.IWebHostBuilder UseSolutionRelativeContentRoot(this Microsoft.AspNetCore.Hosting.IWebHostBuilder builder, string solutionRelativePath, string solutionName);
+ public static Microsoft.AspNetCore.Hosting.IWebHostBuilder UseSolutionRelativeContentRoot(this Microsoft.AspNetCore.Hosting.IWebHostBuilder builder, string solutionRelativePath, string applicationBasePath, string solutionName);
+ public static Microsoft.AspNetCore.Hosting.IWebHostBuilder UseSolutionRelativeContentRoot(this Microsoft.AspNetCore.Hosting.IWebHostBuilder builder, string solutionRelativePath, string applicationBasePath, System.ReadOnlySpan<string> solutionNames = default(System.ReadOnlySpan<string>));
}
Usage Examples
before:
.UseSolutionRelativeContentRoot(Path.Combine("test", "WebSites", applicationName), "*.slnx")
after:
.UseSolutionRelativeContentRoot(Path.Combine("test", "WebSites", applicationName))
Alternative Designs
The solutionNames
overload may be more appropriately take a IReadOnlyCollection<string>
given that this api is called on a builder that is typical a one-time setup, so performance isn't particularly critical.
namespace Microsoft.AspNetCore.TestHost;
public static class WebHostBuilderExtensions
{
+ public static Microsoft.AspNetCore.Hosting.IWebHostBuilder UseSolutionRelativeContentRoot(this Microsoft.AspNetCore.Hosting.IWebHostBuilder builder, string solutionRelativePath, string applicationBasePath, System.Collections.Generic.IReadOnlyCollection<string> solutionNames = default(System.Collections.Generic.IReadOnlyCollection<string>));
}
Risks
While these changes should be binary and source compatible, we should double-check this.
Metadata
Metadata
Assignees
Labels
api-ready-for-reviewAPI is ready for formal API review - https://github.com/dotnet/apireviewsAPI is ready for formal API review - https://github.com/dotnet/apireviewsarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsfeature-mvc-testingMVC testing packageMVC testing package