Use a CopyOnWriteDictionary in ApplicationBuilder so branches can set their own properties
Fix #783
This commit is contained in:
parent
73d58b7a13
commit
d89f66f150
|
|
@ -29,7 +29,7 @@ namespace Microsoft.AspNetCore.Builder.Internal
|
|||
|
||||
private ApplicationBuilder(ApplicationBuilder builder)
|
||||
{
|
||||
Properties = builder.Properties;
|
||||
Properties = new CopyOnWriteDictionary<string, object>(builder.Properties, EqualityComparer<string>.Default);
|
||||
}
|
||||
|
||||
public IServiceProvider ApplicationServices
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.CopyOnWriteDictionary.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
|
||||
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.TaskCache.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
|
||||
|
|
|
|||
|
|
@ -19,5 +19,17 @@ namespace Microsoft.AspNetCore.Builder.Internal
|
|||
app.Invoke(httpContext);
|
||||
Assert.Equal(httpContext.Response.StatusCode, 404);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PropertiesDictionaryIsDistinctAfterNew()
|
||||
{
|
||||
var builder1 = new ApplicationBuilder(null);
|
||||
builder1.Properties["test"] = "value1";
|
||||
|
||||
var builder2 = builder1.New();
|
||||
builder2.Properties["test"] = "value2";
|
||||
|
||||
Assert.Equal(builder1.Properties["test"], "value1");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue