Skip to content

Commit 40b2a94

Browse files
authored
Merge pull request #7918 from dotnet-maestro-bot/merge/release/3.0-preview3-to-master
[automated] Merge branch 'release/3.0-preview3' => 'master'
2 parents 423de42 + 87ae40f commit 40b2a94

File tree

21 files changed

+122
-32
lines changed

21 files changed

+122
-32
lines changed

src/Components/Blazor/Templates/src/content/BlazorHosted-CSharp/BlazorHosted-CSharp.Client/_ViewImports.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@using System.Net.Http
2+
@using Microsoft.AspNetCore.Components.Forms
23
@using Microsoft.AspNetCore.Components.Layouts
34
@using Microsoft.AspNetCore.Components.Routing
45
@using Microsoft.JSInterop

src/Components/Blazor/Templates/src/content/BlazorHosted-CSharp/BlazorHosted-CSharp.Client/wwwroot/css/site.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,18 @@ app {
8484
background-color: rgba(255, 255, 255, 0.1);
8585
}
8686

87+
.valid.modified:not([type=checkbox]) {
88+
outline: 1px solid #26b050;
89+
}
90+
91+
.invalid {
92+
outline: 1px solid red;
93+
}
94+
95+
.validation-message {
96+
color: red;
97+
}
98+
8799
@media (max-width: 767.98px) {
88100
.main .top-row {
89101
display: none;

src/Components/Blazor/Templates/src/content/BlazorStandalone-CSharp/_ViewImports.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@using System.Net.Http
2+
@using Microsoft.AspNetCore.Components.Forms
23
@using Microsoft.AspNetCore.Components.Layouts
34
@using Microsoft.AspNetCore.Components.Routing
45
@using Microsoft.JSInterop

src/Components/Blazor/Templates/src/content/BlazorStandalone-CSharp/wwwroot/css/site.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,18 @@ app {
8484
background-color: rgba(255, 255, 255, 0.1);
8585
}
8686

87+
.valid.modified:not([type=checkbox]) {
88+
outline: 1px solid #26b050;
89+
}
90+
91+
.invalid {
92+
outline: 1px solid red;
93+
}
94+
95+
.validation-message {
96+
color: red;
97+
}
98+
8799
@media (max-width: 767.98px) {
88100
.main .top-row {
89101
display: none;

src/Components/Blazor/testassets/StandaloneApp/wwwroot/css/site.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,18 @@ app {
8484
background-color: rgba(255, 255, 255, 0.1);
8585
}
8686

87+
.valid.modified:not([type=checkbox]) {
88+
outline: 1px solid #26b050;
89+
}
90+
91+
.invalid {
92+
outline: 1px solid red;
93+
}
94+
95+
.validation-message {
96+
color: red;
97+
}
98+
8799
@media (max-width: 767.98px) {
88100
.main .top-row {
89101
display: none;

src/Components/Components/src/Forms/InputComponents/InputBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public abstract class InputBase<T> : ComponentBase
4242
/// <summary>
4343
/// Gets or sets a callback that updates the bound value.
4444
/// </summary>
45-
[Parameter] Action<T> ValueChanged { get; set; }
45+
[Parameter] EventCallback<T> ValueChanged { get; set; }
4646

4747
/// <summary>
4848
/// Gets or sets an expression that identifies the bound value.
@@ -71,7 +71,7 @@ protected T CurrentValue
7171
if (hasChanged)
7272
{
7373
Value = value;
74-
ValueChanged?.Invoke(value);
74+
_ = ValueChanged.InvokeAsync(value);
7575
EditContext.NotifyFieldChanged(FieldIdentifier);
7676
}
7777
}

src/Components/Components/test/Forms/InputBaseTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,8 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
459459
{
460460
childBuilder.OpenComponent<TComponent>(0);
461461
childBuilder.AddAttribute(0, "Value", Value);
462-
childBuilder.AddAttribute(1, "ValueChanged", ValueChanged);
462+
childBuilder.AddAttribute(1, "ValueChanged",
463+
EventCallback.Factory.Create(this, ValueChanged));
463464
childBuilder.AddAttribute(2, "ValueExpression", ValueExpression);
464465
childBuilder.AddAttribute(3, nameof(Id), Id);
465466
childBuilder.AddAttribute(4, nameof(Class), Class);

src/Components/test/E2ETest/Tests/FormsTest.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,27 @@ public void ValidationMessageDisplaysMessagesForField()
316316
WaitAssert.Empty(emailMessagesAccessor);
317317
}
318318

319+
[Fact]
320+
public void InputComponentsCauseContainerToRerenderOnChange()
321+
{
322+
var appElement = MountTestComponent<TypicalValidationComponent>();
323+
var ticketClassInput = new SelectElement(appElement.FindElement(By.ClassName("ticket-class")).FindElement(By.TagName("select")));
324+
var selectedTicketClassDisplay = appElement.FindElement(By.Id("selected-ticket-class"));
325+
var messagesAccessor = CreateValidationMessagesAccessor(appElement);
326+
327+
// Shows initial state
328+
WaitAssert.Equal("Economy", () => selectedTicketClassDisplay.Text);
329+
330+
// Refreshes on edit
331+
ticketClassInput.SelectByValue("Premium");
332+
WaitAssert.Equal("Premium", () => selectedTicketClassDisplay.Text);
333+
334+
// Leaves previous value unchanged if new entry is unparseable
335+
ticketClassInput.SelectByText("(select)");
336+
WaitAssert.Equal(new[] { "The TicketClass field is not valid." }, messagesAccessor);
337+
WaitAssert.Equal("Premium", () => selectedTicketClassDisplay.Text);
338+
}
339+
319340
private Func<string[]> CreateValidationMessagesAccessor(IWebElement appElement)
320341
{
321342
return () => appElement.FindElements(By.ClassName("validation-message"))

src/Components/test/testassets/BasicTestApp/FormsTest/TypicalValidationComponent.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<option value="@TicketClass.Premium">Premium class</option>
3535
<option value="@TicketClass.First">First class</option>
3636
</InputSelect>
37+
<span id="selected-ticket-class">@person.TicketClass</span>
3738
</p>
3839
<p class="accepts-terms">
3940
Accepts terms: <InputCheckbox bind-Value="@person.AcceptsTerms" />

src/Components/test/testassets/BasicTestApp/wwwroot/style.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
.modified.valid {
2-
box-shadow: 0px 0px 0px 2px rgb(78, 203, 37);
1+
.valid.modified:not([type=checkbox]) {
2+
outline: 1px solid #26b050;
33
}
44

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

99
.validation-message {

src/Components/test/testassets/ComponentsApp.Server/wwwroot/css/site.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,18 @@ app {
8484
background-color: rgba(255, 255, 255, 0.1);
8585
}
8686

87+
.valid.modified:not([type=checkbox]) {
88+
outline: 1px solid #26b050;
89+
}
90+
91+
.invalid {
92+
outline: 1px solid red;
93+
}
94+
95+
.validation-message {
96+
color: red;
97+
}
98+
8799
@media (max-width: 767.98px) {
88100
.main .top-row {
89101
display: none;

src/Hosting/Abstractions/ref/Microsoft.AspNetCore.Hosting.Abstractions.netcoreapp3.0.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace Microsoft.AspNetCore.Hosting
55
{
6+
[System.ObsoleteAttribute("This type is obsolete and will be removed in a future version. The recommended alternative is Microsoft.Extensions.Hosting.Environments.", false)]
67
public static partial class EnvironmentName
78
{
89
public static readonly string Development;

src/Hosting/Abstractions/src/EnvironmentName.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ namespace Microsoft.AspNetCore.Hosting
66
/// <summary>
77
/// Commonly used environment names.
88
/// </summary>
9+
[System.Obsolete("This type is obsolete and will be removed in a future version. The recommended alternative is Microsoft.Extensions.Hosting.Environments.", error: false)]
910
public static class EnvironmentName
1011
{
1112
public static readonly string Development = "Development";
1213
public static readonly string Staging = "Staging";
1314
public static readonly string Production = "Production";
1415
}
15-
}
16+
}

src/Hosting/Hosting/src/Internal/HostingEnvironment.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal
99
public class HostingEnvironment : IHostingEnvironment, Extensions.Hosting.IHostingEnvironment, IWebHostEnvironment
1010
#pragma warning restore CS0618 // Type or member is obsolete
1111
{
12-
public string EnvironmentName { get; set; } = Hosting.EnvironmentName.Production;
12+
public string EnvironmentName { get; set; } = Extensions.Hosting.Environments.Production;
1313

1414
public string ApplicationName { get; set; }
1515

src/Hosting/Hosting/test/StartupManagerTests.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Microsoft.AspNetCore.Hosting.Tests.Internal;
1212
using Microsoft.Extensions.DependencyInjection;
1313
using Microsoft.Extensions.DependencyInjection.Extensions;
14+
using Microsoft.Extensions.Hosting;
1415
using Microsoft.Extensions.Options;
1516
using Xunit;
1617

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

513-
var startup = StartupLoader.LoadMethods(services, typeof(MyContainerStartup), EnvironmentName.Development);
514+
var startup = StartupLoader.LoadMethods(services, typeof(MyContainerStartup), Environments.Development);
514515

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

529-
var startup = StartupLoader.LoadMethods(services, typeof(MyContainerStartupBaseClass), EnvironmentName.Development);
530+
var startup = StartupLoader.LoadMethods(services, typeof(MyContainerStartupBaseClass), Environments.Development);
530531

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

545-
var startup = StartupLoader.LoadMethods(services, typeof(MyContainerStartupEnvironmentBased), EnvironmentName.Production);
546+
var startup = StartupLoader.LoadMethods(services, typeof(MyContainerStartupEnvironmentBased), Environments.Production);
546547

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

550551
Assert.IsType<MyContainer>(app.ApplicationServices);
551-
Assert.Equal(((MyContainer)app.ApplicationServices).Environment, EnvironmentName.Production);
552+
Assert.Equal(((MyContainer)app.ApplicationServices).Environment, Environments.Production);
552553
}
553554

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

560-
var startup = StartupLoader.LoadMethods(services, typeof(MyContainerStartup), EnvironmentName.Development);
561+
var startup = StartupLoader.LoadMethods(services, typeof(MyContainerStartup), Environments.Development);
561562

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

571-
Assert.Throws<InvalidOperationException>(() => StartupLoader.LoadMethods(services, typeof(MyContainerStartupBaseClass), EnvironmentName.Development));
572+
Assert.Throws<InvalidOperationException>(() => StartupLoader.LoadMethods(services, typeof(MyContainerStartupBaseClass), Environments.Development));
572573
}
573574

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

581-
Assert.Throws<InvalidOperationException>(() => StartupLoader.LoadMethods(services, typeof(MyContainerStartupWithOverloads), EnvironmentName.Development));
582+
Assert.Throws<InvalidOperationException>(() => StartupLoader.LoadMethods(services, typeof(MyContainerStartupWithOverloads), Environments.Development));
582583
}
583584

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

591-
var startup = StartupLoader.LoadMethods(services, typeof(MyContainerStartup), EnvironmentName.Development);
592+
var startup = StartupLoader.LoadMethods(services, typeof(MyContainerStartup), Environments.Development);
592593

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

630631
public void ConfigureDevelopmentContainer(MyContainer container)
631632
{
632-
container.Environment = EnvironmentName.Development;
633+
container.Environment = Environments.Development;
633634
}
634635

635636
public void ConfigureProductionContainer(MyContainer container)
636637
{
637-
container.Environment = EnvironmentName.Production;
638+
container.Environment = Environments.Production;
638639
}
639640

640641
public void Configure(IApplicationBuilder app)

src/Hosting/Hosting/test/WebHostConfigurationsTests.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Collections.Generic;
55
using Microsoft.AspNetCore.Hosting.Internal;
66
using Microsoft.Extensions.Configuration;
7+
using Microsoft.Extensions.Hosting;
78
using Xunit;
89

910
namespace Microsoft.AspNetCore.Hosting.Tests
@@ -18,7 +19,7 @@ public void ReadsParametersCorrectly()
1819
{ WebHostDefaults.WebRootKey, "wwwroot"},
1920
{ WebHostDefaults.ApplicationKey, "MyProjectReference"},
2021
{ WebHostDefaults.StartupAssemblyKey, "MyProjectReference" },
21-
{ WebHostDefaults.EnvironmentKey, EnvironmentName.Development},
22+
{ WebHostDefaults.EnvironmentKey, Environments.Development},
2223
{ WebHostDefaults.DetailedErrorsKey, "true"},
2324
{ WebHostDefaults.CaptureStartupErrorsKey, "true" },
2425
{ WebHostDefaults.SuppressStatusMessagesKey, "true" }
@@ -29,7 +30,7 @@ public void ReadsParametersCorrectly()
2930
Assert.Equal("wwwroot", config.WebRoot);
3031
Assert.Equal("MyProjectReference", config.ApplicationName);
3132
Assert.Equal("MyProjectReference", config.StartupAssembly);
32-
Assert.Equal(EnvironmentName.Development, config.Environment);
33+
Assert.Equal(Environments.Development, config.Environment);
3334
Assert.True(config.CaptureStartupErrors);
3435
Assert.True(config.DetailedErrors);
3536
Assert.True(config.SuppressStatusMessages);
@@ -38,10 +39,10 @@ public void ReadsParametersCorrectly()
3839
[Fact]
3940
public void ReadsOldEnvKey()
4041
{
41-
var parameters = new Dictionary<string, string>() { { "ENVIRONMENT", EnvironmentName.Development } };
42+
var parameters = new Dictionary<string, string>() { { "ENVIRONMENT", Environments.Development } };
4243
var config = new WebHostOptions(new ConfigurationBuilder().AddInMemoryCollection(parameters).Build());
4344

44-
Assert.Equal(EnvironmentName.Development, config.Environment);
45+
Assert.Equal(Environments.Development, config.Environment);
4546
}
4647

4748
[Theory]

src/Hosting/Hosting/test/WebHostTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -812,8 +812,8 @@ public void EnvDefaultsToProductionIfNoConfig()
812812
#pragma warning disable CS0618 // Type or member is obsolete
813813
var env2 = host.Services.GetService<AspNetCore.Hosting.IHostingEnvironment>();
814814
#pragma warning restore CS0618 // Type or member is obsolete
815-
Assert.Equal(EnvironmentName.Production, env.EnvironmentName);
816-
Assert.Equal(EnvironmentName.Production, env2.EnvironmentName);
815+
Assert.Equal(Environments.Production, env.EnvironmentName);
816+
Assert.Equal(Environments.Production, env2.EnvironmentName);
817817
}
818818
}
819819

@@ -822,7 +822,7 @@ public void EnvDefaultsToConfigValueIfSpecified()
822822
{
823823
var vals = new Dictionary<string, string>
824824
{
825-
{ "Environment", EnvironmentName.Staging }
825+
{ "Environment", Environments.Staging }
826826
};
827827

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

@@ -873,7 +873,7 @@ public async Task IsEnvironment_Extension_Is_Case_Insensitive()
873873
{
874874
await host.StartAsync();
875875
var env = host.Services.GetRequiredService<IHostEnvironment>();
876-
Assert.True(env.IsEnvironment(EnvironmentName.Production));
876+
Assert.True(env.IsEnvironment(Environments.Production));
877877
Assert.True(env.IsEnvironment("producTion"));
878878
}
879879
}

src/Hosting/samples/SampleStartups/StartupFullControl.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Microsoft.AspNetCore.Hosting;
55
using Microsoft.Extensions.Configuration;
66
using Microsoft.Extensions.DependencyInjection;
7+
using Microsoft.Extensions.Hosting;
78
using Microsoft.Extensions.Logging;
89

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

0 commit comments

Comments
 (0)