Repository: dotnet/aspnetcore
File: src/Hosting/TestHost/src/WebHostBuilderExtensions.cs (C#)

Code before:
    /// </summary>
    /// <param name="builder">The <see cref="IWebHostBuilder"/>.</param>
    /// <param name="solutionRelativePath">The directory of the solution file.</param>
    /// <param name="solutionName">The name of the solution file to make the content root relative to.</param>
    /// <returns>The <see cref="IWebHostBuilder"/>.</returns>
    public static IWebHostBuilder UseSolutionRelativeContentRoot(
        this IWebHostBuilder builder,
        string solutionRelativePath,
        string solutionName)
    {
        return builder.UseSolutionRelativeContentRoot(solutionRelativePath, AppContext.BaseDirectory, [solutionName]);
    }

    /// <summary>
    /// Sets the content root of relative to the <paramref name="solutionRelativePath" />.
    /// </summary>
    /// <param name="builder">The <see cref="IWebHostBuilder"/>.</param>
    /// <param name="solutionRelativePath">The directory of the solution file.</param>
    /// <param name="applicationBasePath">The root of the app's directory.</param>
    /// <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(
        this IWebHostBuilder builder,
        string solutionRelativePath,
        string applicationBasePath,
        string solutionName)
    {
        return builder.UseSolutionRelativeContentRoot(solutionRelativePath, applicationBasePath, [solutionName]);
    }

    /// <summary>
    /// Sets the content root of relative to the <paramref name="solutionRelativePath" />.
    /// </summary>
    /// <param name="builder">The <see cref="IWebHostBuilder"/>.</param>
    /// <param name="solutionRelativePath">The directory of the solution file.</param>
    /// <param name="applicationBasePath">The root of the app's directory.</param>
    /// <param name="solutionNames">The names of the solution files to make the content root relative to. If empty, defaults to *.sln and *.slnx.</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(
        this IWebHostBuilder builder,
        string solutionRelativePath,
        string applicationBasePath,
        ReadOnlySpan<string> solutionNames = default)
    {
        ArgumentNullException.ThrowIfNull(solutionRelativePath);
        ArgumentNullException.ThrowIfNull(applicationBasePath);

        if (solutionNames.IsEmpty)
        {

Review comment (suggestion):
Nit: I think we can remove the `[SuppressMessage(...` from this overload now too.

It's really unfortunate that we have all these overloads of just `string` parameters and we decided to add `applicationBasePath` to the middle of the parameter list instead of the end. That's what RS0026 was warning about. It makes it very difficult to make backwards compatible changes, but I think this change is safe. I'm glad the new overload at least takes a type other than `string`.

Code after:
    /// </summary>
    /// <param name="builder">The <see cref="IWebHostBuilder"/>.</param>
    /// <param name="solutionRelativePath">The directory of the solution file.</param>
    /// <param name="solutionName">The name of the solution file to make the content root relative to.</param>
    /// <returns>The <see cref="IWebHostBuilder"/>.</returns>
    public static IWebHostBuilder UseSolutionRelativeContentRoot(
        this IWebHostBuilder builder,
        string solutionRelativePath,
        string solutionName)
    {
        return builder.UseSolutionRelativeContentRoot(solutionRelativePath, AppContext.BaseDirectory, [solutionName]);
    }

    /// <summary>
    /// Sets the content root of relative to the <paramref name="solutionRelativePath" />.
    /// </summary>
    /// <param name="builder">The <see cref="IWebHostBuilder"/>.</param>
    /// <param name="solutionRelativePath">The directory of the solution file.</param>
    /// <param name="applicationBasePath">The root of the app's directory.</param>
    /// <param name="solutionName">The name of the solution file to make the content root relative to.</param>
    /// <returns>The <see cref="IWebHostBuilder"/>.</returns>
    public static IWebHostBuilder UseSolutionRelativeContentRoot(
        this IWebHostBuilder builder,
        string solutionRelativePath,
        string applicationBasePath,
        string solutionName)
    {
        return builder.UseSolutionRelativeContentRoot(solutionRelativePath, applicationBasePath, [solutionName]);
    }

    /// <summary>
    /// Sets the content root of relative to the <paramref name="solutionRelativePath" />.
    /// </summary>
    /// <param name="builder">The <see cref="IWebHostBuilder"/>.</param>
    /// <param name="solutionRelativePath">The directory of the solution file.</param>
    /// <param name="applicationBasePath">The root of the app's directory.</param>
    /// <param name="solutionNames">The names of the solution files to make the content root relative to. If empty, defaults to *.sln and *.slnx.</param>
    /// <returns>The <see cref="IWebHostBuilder"/>.</returns>
    [SuppressMessage("ApiDesign", "RS0027:Public API with optional parameter(s) should have the most parameters amongst its public overloads", Justification = "Required to maintain compatibility")]
    public static IWebHostBuilder UseSolutionRelativeContentRoot(
        this IWebHostBuilder builder,
        string solutionRelativePath,
        string applicationBasePath,
        ReadOnlySpan<string> solutionNames = default)
    {
        ArgumentNullException.ThrowIfNull(solutionRelativePath);
        ArgumentNullException.ThrowIfNull(applicationBasePath);

        if (solutionNames.IsEmpty)
        {
            solutionNames = _defaultSolutionNames;