Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
dbbe9fa
Port WebApplication WIP
halter73 Apr 14, 2021
2858a94
Remove private copy of Host's ConfigureDefaults
halter73 Apr 15, 2021
def631b
Add sample. "Fix" startup.
halter73 Apr 15, 2021
c9b9432
Add IAsyncDisposable support
halter73 Apr 15, 2021
dbf2382
Add unit tests and make IServer replaceable
halter73 Apr 15, 2021
c53f5a9
Hide WebApplication.Dispose in favor of DisposeAsync
halter73 Apr 15, 2021
3cc8665
seal WebApplication and WebApplicationBuilder
halter73 Apr 15, 2021
cae4c27
Add logging config functional test
halter73 Apr 15, 2021
14d6d72
Update MinimalSample to use WebApplication!!!
halter73 Apr 15, 2021
9cebfd1
Seal Configuration and add WebApplicationBuilder_CanClearDefaultLogge…
halter73 Apr 15, 2021
dcb450d
Explain why it's OK to noop in ConfigurationHostBuilder
halter73 Apr 15, 2021
abc566b
Match the proposed API
halter73 Apr 16, 2021
30d67c9
Make Configure(Web)?HostBuilder public
halter73 Apr 16, 2021
a02158b
missed one
halter73 Apr 16, 2021
5e11585
Fix host builder case sensitivity and add tests.
halter73 Apr 16, 2021
6da3d33
"NotFound" -> string.Empty
halter73 Apr 16, 2021
6af9e02
Address PR feedback
halter73 Apr 17, 2021
ebbda68
Fix handling of ASPNETCORE_ environment variables
halter73 Apr 17, 2021
8aeaa4a
Add WebHostEnvironment.ApplyConfigurationSettings
halter73 Apr 17, 2021
1184f79
cleanup
halter73 Apr 17, 2021
b430995
React to API review feedback
halter73 Apr 19, 2021
ed47002
Addresses IEnumerable<string> -> ICollection<string>
halter73 Apr 19, 2021
c9f8fdc
Addresses -> Urls
halter73 Apr 19, 2021
a1136f7
Make Urls non-nullable
halter73 Apr 19, 2021
bae765b
Add more tests
halter73 Apr 20, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix host builder case sensitivity and add tests.
  • Loading branch information
halter73 committed Apr 19, 2021
commit 5e11585ab1db17ef636535f25b814f456c6dc9e3
10 changes: 5 additions & 5 deletions src/DefaultBuilder/src/ConfigureWebHostBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public sealed class ConfigureWebHostBuilder : IWebHostBuilder

private readonly WebHostEnvironment _environment;
private readonly Configuration _configuration;
private readonly Dictionary<string, string?> _settings = new Dictionary<string, string?>();
private readonly Dictionary<string, string?> _settings = new(StringComparer.OrdinalIgnoreCase);
private readonly IServiceCollection _services;

internal ConfigureWebHostBuilder(Configuration configuration, WebHostEnvironment environment, IServiceCollection services)
Expand Down Expand Up @@ -78,22 +78,22 @@ public IWebHostBuilder UseSetting(string key, string? value)
return this;
}

if (key == WebHostDefaults.ApplicationKey)
if (string.Equals(key, WebHostDefaults.ApplicationKey, StringComparison.OrdinalIgnoreCase))
{
_environment.ApplicationName = value;
}
else if (key == WebHostDefaults.ContentRootKey)
else if (string.Equals(key, WebHostDefaults.ContentRootKey, StringComparison.OrdinalIgnoreCase))
{
_environment.ContentRootPath = value;
_environment.ResolveFileProviders(_configuration);

_configuration.ChangeBasePath(value);
}
else if (key == WebHostDefaults.EnvironmentKey)
else if (string.Equals(key, WebHostDefaults.EnvironmentKey, StringComparison.OrdinalIgnoreCase))
{
_environment.EnvironmentName = value;
}
else if (key == WebHostDefaults.WebRootKey)
else if (string.Equals(key, WebHostDefaults.WebRootKey, StringComparison.OrdinalIgnoreCase))
{
_environment.WebRootPath = value;
_environment.ResolveFileProviders(_configuration);
Expand Down
2 changes: 1 addition & 1 deletion src/DefaultBuilder/src/WebApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Builder
/// <summary>
/// The web application used to configure the http pipeline, and routes.
/// </summary>
public sealed class WebApplication : IHost, IDisposable, IApplicationBuilder, IEndpointRouteBuilder, IAsyncDisposable
public sealed class WebApplication : IHost, IApplicationBuilder, IEndpointRouteBuilder, IAsyncDisposable
{
internal const string EndpointRouteBuilder = "__EndpointRouteBuilder";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics.Tracing;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -65,6 +66,44 @@ public void WebApplicationBuilderWebHost_ThrowsWhenBuiltDirectly()
Assert.Throws<NotSupportedException>(() => ((IWebHostBuilder)WebApplication.CreateBuilder().WebHost).Build());
}

[Fact]
public void WebApplicationBuilderWebHostUseSettings_IsCaseInsensitive()
{
var builder = WebApplication.CreateBuilder();

var contentRoot = Path.GetTempPath().ToString();
var webRoot = Path.GetTempPath().ToString();
var envName = $"{nameof(WebApplicationTests)}_ENV";

builder.WebHost.UseSetting("applicationname", nameof(WebApplicationTests));
builder.WebHost.UseSetting("ENVIRONMENT", envName);
builder.WebHost.UseSetting("CONTENTROOT", contentRoot);
builder.WebHost.UseSetting("WEBROOT", webRoot);

Assert.Equal(nameof(WebApplicationTests), builder.WebHost.GetSetting("APPLICATIONNAME"));
Assert.Equal(envName, builder.WebHost.GetSetting("environment"));
Assert.Equal(contentRoot, builder.WebHost.GetSetting("contentroot"));
Assert.Equal(webRoot, builder.WebHost.GetSetting("webroot"));

var app = builder.Build();

Assert.Equal(nameof(WebApplicationTests), app.Environment.ApplicationName);
Assert.Equal(envName, app.Environment.EnvironmentName);
Assert.Equal(contentRoot, app.Environment.ContentRootPath);
Assert.Equal(webRoot, app.Environment.WebRootPath);
}

[Fact]
public void WebApplicationBuilderHostProperties_IsCaseSensitive()
{
var builder = WebApplication.CreateBuilder();

builder.Host.Properties["lowercase"] = nameof(WebApplicationTests);

Assert.Equal(nameof(WebApplicationTests), builder.Host.Properties["lowercase"]);
Assert.False(builder.Host.Properties.ContainsKey("Lowercase"));
}

[Fact]
public async Task WebApplicationConfiguration_HostFilterOptionsAreReloadable()
{
Expand Down