Skip to content

[automated] Merge branch 'release/3.0-preview3' => 'master' #7918

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@using System.Net.Http
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Layouts
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.JSInterop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ app {
background-color: rgba(255, 255, 255, 0.1);
}

.valid.modified:not([type=checkbox]) {
outline: 1px solid #26b050;
}

.invalid {
outline: 1px solid red;
}

.validation-message {
color: red;
}

@media (max-width: 767.98px) {
.main .top-row {
display: none;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@using System.Net.Http
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Layouts
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.JSInterop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ app {
background-color: rgba(255, 255, 255, 0.1);
}

.valid.modified:not([type=checkbox]) {
outline: 1px solid #26b050;
}

.invalid {
outline: 1px solid red;
}

.validation-message {
color: red;
}

@media (max-width: 767.98px) {
.main .top-row {
display: none;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ app {
background-color: rgba(255, 255, 255, 0.1);
}

.valid.modified:not([type=checkbox]) {
outline: 1px solid #26b050;
}

.invalid {
outline: 1px solid red;
}

.validation-message {
color: red;
}

@media (max-width: 767.98px) {
.main .top-row {
display: none;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public abstract class InputBase<T> : ComponentBase
/// <summary>
/// Gets or sets a callback that updates the bound value.
/// </summary>
[Parameter] Action<T> ValueChanged { get; set; }
[Parameter] EventCallback<T> ValueChanged { get; set; }

/// <summary>
/// Gets or sets an expression that identifies the bound value.
Expand Down Expand Up @@ -71,7 +71,7 @@ protected T CurrentValue
if (hasChanged)
{
Value = value;
ValueChanged?.Invoke(value);
_ = ValueChanged.InvokeAsync(value);
EditContext.NotifyFieldChanged(FieldIdentifier);
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Components/Components/test/Forms/InputBaseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,8 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
{
childBuilder.OpenComponent<TComponent>(0);
childBuilder.AddAttribute(0, "Value", Value);
childBuilder.AddAttribute(1, "ValueChanged", ValueChanged);
childBuilder.AddAttribute(1, "ValueChanged",
EventCallback.Factory.Create(this, ValueChanged));
childBuilder.AddAttribute(2, "ValueExpression", ValueExpression);
childBuilder.AddAttribute(3, nameof(Id), Id);
childBuilder.AddAttribute(4, nameof(Class), Class);
Expand Down
21 changes: 21 additions & 0 deletions src/Components/test/E2ETest/Tests/FormsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,27 @@ public void ValidationMessageDisplaysMessagesForField()
WaitAssert.Empty(emailMessagesAccessor);
}

[Fact]
public void InputComponentsCauseContainerToRerenderOnChange()
{
var appElement = MountTestComponent<TypicalValidationComponent>();
var ticketClassInput = new SelectElement(appElement.FindElement(By.ClassName("ticket-class")).FindElement(By.TagName("select")));
var selectedTicketClassDisplay = appElement.FindElement(By.Id("selected-ticket-class"));
var messagesAccessor = CreateValidationMessagesAccessor(appElement);

// Shows initial state
WaitAssert.Equal("Economy", () => selectedTicketClassDisplay.Text);

// Refreshes on edit
ticketClassInput.SelectByValue("Premium");
WaitAssert.Equal("Premium", () => selectedTicketClassDisplay.Text);

// Leaves previous value unchanged if new entry is unparseable
ticketClassInput.SelectByText("(select)");
WaitAssert.Equal(new[] { "The TicketClass field is not valid." }, messagesAccessor);
WaitAssert.Equal("Premium", () => selectedTicketClassDisplay.Text);
}

private Func<string[]> CreateValidationMessagesAccessor(IWebElement appElement)
{
return () => appElement.FindElements(By.ClassName("validation-message"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<option value="@TicketClass.Premium">Premium class</option>
<option value="@TicketClass.First">First class</option>
</InputSelect>
<span id="selected-ticket-class">@person.TicketClass</span>
</p>
<p class="accepts-terms">
Accepts terms: <InputCheckbox bind-Value="@person.AcceptsTerms" />
Expand Down
6 changes: 3 additions & 3 deletions src/Components/test/testassets/BasicTestApp/wwwroot/style.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.modified.valid {
box-shadow: 0px 0px 0px 2px rgb(78, 203, 37);
.valid.modified:not([type=checkbox]) {
outline: 1px solid #26b050;
}

.invalid {
box-shadow: 0px 0px 0px 2px rgb(255, 0, 0);
outline: 1px solid red;
}

.validation-message {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ app {
background-color: rgba(255, 255, 255, 0.1);
}

.valid.modified:not([type=checkbox]) {
outline: 1px solid #26b050;
}

.invalid {
outline: 1px solid red;
}

.validation-message {
color: red;
}

@media (max-width: 767.98px) {
.main .top-row {
display: none;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace Microsoft.AspNetCore.Hosting
{
[System.ObsoleteAttribute("This type is obsolete and will be removed in a future version. The recommended alternative is Microsoft.Extensions.Hosting.Environments.", false)]
public static partial class EnvironmentName
{
public static readonly string Development;
Expand Down
3 changes: 2 additions & 1 deletion src/Hosting/Abstractions/src/EnvironmentName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ namespace Microsoft.AspNetCore.Hosting
/// <summary>
/// Commonly used environment names.
/// </summary>
[System.Obsolete("This type is obsolete and will be removed in a future version. The recommended alternative is Microsoft.Extensions.Hosting.Environments.", error: false)]
public static class EnvironmentName
{
public static readonly string Development = "Development";
public static readonly string Staging = "Staging";
public static readonly string Production = "Production";
}
}
}
2 changes: 1 addition & 1 deletion src/Hosting/Hosting/src/Internal/HostingEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal
public class HostingEnvironment : IHostingEnvironment, Extensions.Hosting.IHostingEnvironment, IWebHostEnvironment
#pragma warning restore CS0618 // Type or member is obsolete
{
public string EnvironmentName { get; set; } = Hosting.EnvironmentName.Production;
public string EnvironmentName { get; set; } = Extensions.Hosting.Environments.Production;

public string ApplicationName { get; set; }

Expand Down
21 changes: 11 additions & 10 deletions src/Hosting/Hosting/test/StartupManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Microsoft.AspNetCore.Hosting.Tests.Internal;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using Xunit;

Expand Down Expand Up @@ -510,7 +511,7 @@ public void CustomProviderFactoryCallsConfigureContainer()
serviceCollection.AddSingleton<IServiceProviderFactory<MyContainer>, MyContainerFactory>();
var services = serviceCollection.BuildServiceProvider();

var startup = StartupLoader.LoadMethods(services, typeof(MyContainerStartup), EnvironmentName.Development);
var startup = StartupLoader.LoadMethods(services, typeof(MyContainerStartup), Environments.Development);

var app = new ApplicationBuilder(services);
app.ApplicationServices = startup.ConfigureServicesDelegate(serviceCollection);
Expand All @@ -526,7 +527,7 @@ public void CustomServiceProviderFactoryStartupBaseClassCallsConfigureContainer(
serviceCollection.AddSingleton<IServiceProviderFactory<MyContainer>, MyContainerFactory>();
var services = serviceCollection.BuildServiceProvider();

var startup = StartupLoader.LoadMethods(services, typeof(MyContainerStartupBaseClass), EnvironmentName.Development);
var startup = StartupLoader.LoadMethods(services, typeof(MyContainerStartupBaseClass), Environments.Development);

var app = new ApplicationBuilder(services);
app.ApplicationServices = startup.ConfigureServicesDelegate(serviceCollection);
Expand All @@ -542,13 +543,13 @@ public void CustomServiceProviderFactoryEnvironmentBasedConfigureContainer()
serviceCollection.AddSingleton<IServiceProviderFactory<MyContainer>, MyContainerFactory>();
var services = serviceCollection.BuildServiceProvider();

var startup = StartupLoader.LoadMethods(services, typeof(MyContainerStartupEnvironmentBased), EnvironmentName.Production);
var startup = StartupLoader.LoadMethods(services, typeof(MyContainerStartupEnvironmentBased), Environments.Production);

var app = new ApplicationBuilder(services);
app.ApplicationServices = startup.ConfigureServicesDelegate(serviceCollection);

Assert.IsType<MyContainer>(app.ApplicationServices);
Assert.Equal(((MyContainer)app.ApplicationServices).Environment, EnvironmentName.Production);
Assert.Equal(((MyContainer)app.ApplicationServices).Environment, Environments.Production);
}

[Fact]
Expand All @@ -557,7 +558,7 @@ public void CustomServiceProviderFactoryThrowsIfNotRegisteredWithConfigureContai
var serviceCollection = new ServiceCollection();
var services = serviceCollection.BuildServiceProvider();

var startup = StartupLoader.LoadMethods(services, typeof(MyContainerStartup), EnvironmentName.Development);
var startup = StartupLoader.LoadMethods(services, typeof(MyContainerStartup), Environments.Development);

Assert.Throws<InvalidOperationException>(() => startup.ConfigureServicesDelegate(serviceCollection));
}
Expand All @@ -568,7 +569,7 @@ public void CustomServiceProviderFactoryThrowsIfNotRegisteredWithConfigureContai
var serviceCollection = new ServiceCollection();
var services = serviceCollection.BuildServiceProvider();

Assert.Throws<InvalidOperationException>(() => StartupLoader.LoadMethods(services, typeof(MyContainerStartupBaseClass), EnvironmentName.Development));
Assert.Throws<InvalidOperationException>(() => StartupLoader.LoadMethods(services, typeof(MyContainerStartupBaseClass), Environments.Development));
}

[Fact]
Expand All @@ -578,7 +579,7 @@ public void CustomServiceProviderFactoryFailsWithOverloadsInStartup()
serviceCollection.AddSingleton<IServiceProviderFactory<MyContainer>, MyContainerFactory>();
var services = serviceCollection.BuildServiceProvider();

Assert.Throws<InvalidOperationException>(() => StartupLoader.LoadMethods(services, typeof(MyContainerStartupWithOverloads), EnvironmentName.Development));
Assert.Throws<InvalidOperationException>(() => StartupLoader.LoadMethods(services, typeof(MyContainerStartupWithOverloads), Environments.Development));
}

[Fact]
Expand All @@ -588,7 +589,7 @@ public void BadServiceProviderFactoryFailsThatReturnsNullServiceProviderOverridd
serviceCollection.AddSingleton<IServiceProviderFactory<MyContainer>, MyBadContainerFactory>();
var services = serviceCollection.BuildServiceProvider();

var startup = StartupLoader.LoadMethods(services, typeof(MyContainerStartup), EnvironmentName.Development);
var startup = StartupLoader.LoadMethods(services, typeof(MyContainerStartup), Environments.Development);

var app = new ApplicationBuilder(services);
app.ApplicationServices = startup.ConfigureServicesDelegate(serviceCollection);
Expand Down Expand Up @@ -629,12 +630,12 @@ public void ConfigureServices(IServiceCollection services)

public void ConfigureDevelopmentContainer(MyContainer container)
{
container.Environment = EnvironmentName.Development;
container.Environment = Environments.Development;
}

public void ConfigureProductionContainer(MyContainer container)
{
container.Environment = EnvironmentName.Production;
container.Environment = Environments.Production;
}

public void Configure(IApplicationBuilder app)
Expand Down
9 changes: 5 additions & 4 deletions src/Hosting/Hosting/test/WebHostConfigurationsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.Generic;
using Microsoft.AspNetCore.Hosting.Internal;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Xunit;

namespace Microsoft.AspNetCore.Hosting.Tests
Expand All @@ -18,7 +19,7 @@ public void ReadsParametersCorrectly()
{ WebHostDefaults.WebRootKey, "wwwroot"},
{ WebHostDefaults.ApplicationKey, "MyProjectReference"},
{ WebHostDefaults.StartupAssemblyKey, "MyProjectReference" },
{ WebHostDefaults.EnvironmentKey, EnvironmentName.Development},
{ WebHostDefaults.EnvironmentKey, Environments.Development},
{ WebHostDefaults.DetailedErrorsKey, "true"},
{ WebHostDefaults.CaptureStartupErrorsKey, "true" },
{ WebHostDefaults.SuppressStatusMessagesKey, "true" }
Expand All @@ -29,7 +30,7 @@ public void ReadsParametersCorrectly()
Assert.Equal("wwwroot", config.WebRoot);
Assert.Equal("MyProjectReference", config.ApplicationName);
Assert.Equal("MyProjectReference", config.StartupAssembly);
Assert.Equal(EnvironmentName.Development, config.Environment);
Assert.Equal(Environments.Development, config.Environment);
Assert.True(config.CaptureStartupErrors);
Assert.True(config.DetailedErrors);
Assert.True(config.SuppressStatusMessages);
Expand All @@ -38,10 +39,10 @@ public void ReadsParametersCorrectly()
[Fact]
public void ReadsOldEnvKey()
{
var parameters = new Dictionary<string, string>() { { "ENVIRONMENT", EnvironmentName.Development } };
var parameters = new Dictionary<string, string>() { { "ENVIRONMENT", Environments.Development } };
var config = new WebHostOptions(new ConfigurationBuilder().AddInMemoryCollection(parameters).Build());

Assert.Equal(EnvironmentName.Development, config.Environment);
Assert.Equal(Environments.Development, config.Environment);
}

[Theory]
Expand Down
12 changes: 6 additions & 6 deletions src/Hosting/Hosting/test/WebHostTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -812,8 +812,8 @@ public void EnvDefaultsToProductionIfNoConfig()
#pragma warning disable CS0618 // Type or member is obsolete
var env2 = host.Services.GetService<AspNetCore.Hosting.IHostingEnvironment>();
#pragma warning restore CS0618 // Type or member is obsolete
Assert.Equal(EnvironmentName.Production, env.EnvironmentName);
Assert.Equal(EnvironmentName.Production, env2.EnvironmentName);
Assert.Equal(Environments.Production, env.EnvironmentName);
Assert.Equal(Environments.Production, env2.EnvironmentName);
}
}

Expand All @@ -822,7 +822,7 @@ public void EnvDefaultsToConfigValueIfSpecified()
{
var vals = new Dictionary<string, string>
{
{ "Environment", EnvironmentName.Staging }
{ "Environment", Environments.Staging }
};

var builder = new ConfigurationBuilder()
Expand All @@ -835,8 +835,8 @@ public void EnvDefaultsToConfigValueIfSpecified()
#pragma warning disable CS0618 // Type or member is obsolete
var env2 = host.Services.GetService<AspNetCore.Hosting.IHostingEnvironment>();
#pragma warning restore CS0618 // Type or member is obsolete
Assert.Equal(EnvironmentName.Staging, env.EnvironmentName);
Assert.Equal(EnvironmentName.Staging, env.EnvironmentName);
Assert.Equal(Environments.Staging, env.EnvironmentName);
Assert.Equal(Environments.Staging, env.EnvironmentName);
}
}

Expand Down Expand Up @@ -873,7 +873,7 @@ public async Task IsEnvironment_Extension_Is_Case_Insensitive()
{
await host.StartAsync();
var env = host.Services.GetRequiredService<IHostEnvironment>();
Assert.True(env.IsEnvironment(EnvironmentName.Production));
Assert.True(env.IsEnvironment(Environments.Production));
Assert.True(env.IsEnvironment("producTion"));
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Hosting/samples/SampleStartups/StartupFullControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

// Note that this sample will not run. It is only here to illustrate usage patterns.
Expand All @@ -25,7 +26,7 @@ public static void Main(string[] args)
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory()) // Override the content root with the current directory
.UseUrls("http://*:1000", "https://*:902")
.UseEnvironment(EnvironmentName.Development)
.UseEnvironment(Environments.Development)
.UseWebRoot("public")
.ConfigureServices(services =>
{
Expand Down
Loading