Closed
Description
Background and Motivation
Some background can be found here, dictionary resizes were fairly visible in traces #31240
Proposed API
namespace Microsoft.AspNetCore.Http.Features
{
public class FeatureCollection
{
+ public FeatureCollection(int initialCapacity);
}
}
Usage Examples
Initial place this will be used is
public DefaultHttpContext()
: this(new FeatureCollection(10)) // right here
{
Features.Set<IHttpRequestFeature>(new HttpRequestFeature());
Features.Set<IHttpResponseFeature>(new HttpResponseFeature());
Features.Set<IHttpResponseBodyFeature>(new StreamResponseBodyFeature(Stream.Null));
// At least some slots left before resize for storing RequestAborted feature, Services and other such things.
}
The initial capacity of 10 is just an example, say 5 or 7 would also be fine for me.
Alternative Designs
This could also be handled through an internal constructor.
Risks
It can be viewed as api bloat if it provides minimal overall value.
Metadata
Metadata
Assignees
Labels
API was approved in API review, it can be implementedIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsThis issue represents an ask for new feature or an enhancement to an existing oneGood for newcomers.Up for grabs. We would accept a PR to help resolve this issue