-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,10 +123,10 @@ | |
/// <param name="solutionName">The name of the solution file to make the content root relative to.</param> | ||
/// <returns>The <see cref="IWebHostBuilder"/>.</returns> | ||
[SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Required to maintain compatibility")] | ||
public static IWebHostBuilder UseSolutionRelativeContentRoot( | ||
Check failure on line 126 in src/Hosting/TestHost/src/WebHostBuilderExtensions.cs
|
||
this IWebHostBuilder builder, | ||
string solutionRelativePath, | ||
string solutionName = "*.sln") | ||
string solutionName = "*.sln?") | ||
{ | ||
return builder.UseSolutionRelativeContentRoot(solutionRelativePath, AppContext.BaseDirectory, solutionName); | ||
} | ||
|
@@ -140,11 +140,11 @@ | |
/// <param name="solutionName">The name of the solution file to make the content root relative to.</param> | ||
/// <returns>The <see cref="IWebHostBuilder"/>.</returns> | ||
[SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Required to maintain compatibility")] | ||
public static IWebHostBuilder UseSolutionRelativeContentRoot( | ||
Check failure on line 143 in src/Hosting/TestHost/src/WebHostBuilderExtensions.cs
|
||
this IWebHostBuilder builder, | ||
string solutionRelativePath, | ||
string applicationBasePath, | ||
string solutionName = "*.sln") | ||
string solutionName = "*.sln?") | ||
{ | ||
ArgumentNullException.ThrowIfNull(solutionRelativePath); | ||
ArgumentNullException.ThrowIfNull(applicationBasePath); | ||
|
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 probably isn't a good idea, since it also matches solution filter files (
.slnf
).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.
I can think of a few options:
UseSolutionRelativeContentRoot
method that takes in a list ofsolutionNames
and default to["*.sln", "*.slnx"]
. Then we make different calls toDirectory.EnumerateFiles
and stop on the first return.solutionName
param is*.sln
and theEnumerateFiles
call does not return, do an extra lookup for*.slnx
.*.slnx
.*.sln?
and filter solution filter files (.slnf
) or any other than.sln, .slnx
, ifsolutionName
has the default value.I think I like option 3 the most.
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.
The problem with 1 is that, since the parameters are both optional, there will be a conflict between the overloads. That could maybe be solved with OverloadResolutionPriorityAttribute, but that only works from .NET 9.
2 and 3 are a little weird, since the parameter that you pass in doesn't match the behavior.
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.
2 and 3 are a bit weird, but even if it's not explicit, sln and slnx are analogous. Maybe do 2 and 3?