Repository navigation
Description
Description
Etymology App failed to launch with error that Header's referrer is missing when run against .NET 7.0.
Reproduction Steps
Repro steps for the Problematic App:
This is 5.0 app, issue occurs when we run against .NET 7.0
1.Launch Etymology.Web.exe from Etymology.
2.Open Edge https://localhost:5001.
Minimal Repro steps:
1.Create a new web project.
2.Create a settings.json.
{
"IndexPagePaths": [ "/", "/index.htm" ]
}
3.Create Settings.cs.
public class Settings
{
public List<string> IndexPagePaths { get; } = new();
}4.Input the following code in startup.cs.
public Startup()
{
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
configurationBuilder.AddJsonFile(Path.Combine("settings.json"), optional: false, reloadOnChange: true);
this.configuration = configurationBuilder.Build();
}
public static IServiceCollection AddSettings<TSettings>(this IServiceCollection services, IConfiguration configuration, out TSettings settings)
where TSettings : class
{
settings = configuration.Get<TSettings>();
return services.AddSingleton(settings);
}
public void ConfigureServices(IServiceCollection services)
{
services.AddSettings(this.configuration, out Settings settings);
if (settings.IndexPagePaths.Count == 0)
{
Console.WriteLine("Can't get IndexPagePaths!");
};
services.AddRazorPages();
}5.When use default sdk 5.0, settings.IndexPagePaths.Count == 2.
When use sdk 7.0, settings.IndexPagePaths.Count == 0.
Expected behavior
Web page should load successfully.
Actual behavior
It shows an error: Header's referrer is missing.
Regression?
Yes
Verify Scenarios:
1). Windows rs5 x64 + dotnet-sdk-7.0.100-alpha.1.21568.2: Fail
2). Windows rs5 x64 + dotnet-sdk-5.0.404-win-x64:Pass
3). Windows rs5 x64 + dotnet-sdk-6.0.101:Pass
Known Workarounds
It will work after changing
public List<string> IndexPagePaths { get; } = new(); to
public List<string> IndexPagePaths { get; set;} = new();Configuration
Application Name: Etymology
OS: Windows 10 RS5
CPU: X64
.NET Build Number: dotnet-sdk-7.0.100-alpha.1.21568.2
App Github Repo link: https://github.com/Dixin/Etymology
App, App Source and Minimal Repro Code checking at: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1458234
Other information
@dotnet-actwx-bot @dotnet/compat
Activity
mkArtakMSFT commentedon Jan 6, 2022
@adityamandaleeka not sure why this was transferred to us as it feels to be configuration options related, but moving over to your area path as you have more expertise in this area.
ericstj commentedon Jan 6, 2022
Agree with @mkArtakMSFT that this looks like the configuration binder. It looks like this was regressed by 97ef512
ericstj commentedon Jan 6, 2022
I was able to repro this with a simple console app. The first 7.0 build that repros is 7.0.0-alpha.1.21514.8 which corresponds to #60415 cc @safern @danielmpetrov
That change broke the scenario where an object has a read-only property with a mutable collection.
Here's a simple repro:
config.zip
safern commentedon Jan 7, 2022
Interesting that we didn't have test coverage for that scenario. We should definitely fix this, I'm not longer on this area ownership, but shouldn't be a hard fix.
ericstj commentedon Jan 10, 2022
Reverting the regression for now. I'll add the detail to the other issue to address this scenario in the fix.
Junjun-zhao commentedon Jan 18, 2022
Verified and pass with dotnet-sdk-7.0.100-alpha.1.22065.3.