Skip to content
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

Make NameValueCollection.HasKeys() method virtual and override it in WebHeaderCollection #30788

Closed
madmir opened this issue Sep 6, 2019 · 2 comments
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.Net
Milestone

Comments

@madmir
Copy link
Contributor

madmir commented Sep 6, 2019

This suggestion is order to provide a fix for #27971.

AllKeys and Keys are overridden in WebHeaderCollection, but we are unable to change behavior of related HasKeys() method. This causes inconsistency described in aforementioned bug report.

InternalHasKeys(), as it's currently defined, seems to be redundant as well.

Current

public class NameValueCollection : NameObjectCollectionBase
{
    public bool HasKeys();
    internal virtual bool InternalHasKeys();
}
public class WebHeaderCollection : NameValueCollection, ISerializable
{
}

Proposed

public class NameValueCollection : NameObjectCollectionBase
{
    public virtual bool HasKeys();
}
public class WebHeaderCollection : NameValueCollection, ISerializable
{
    public override bool HasKeys();
}
@davidsh
Copy link
Contributor

davidsh commented Sep 6, 2019

It might be a breaking change to remove a method such as this:

internal virtual bool InternalHasKeys();

from the NameValueCollection type. So, this API proposal would have to be reworked to not be breaking existing usage.

@karelz
Copy link
Member

karelz commented Sep 12, 2019

WebClient is legacy API and as such we are not thrilled to make API changes elsewhere to make it work better.
Let's primarily try to find other ways how to make WebClient work.

@karelz karelz closed this as completed Sep 12, 2019
@msftgits msftgits transferred this issue from dotnet/corefx Feb 1, 2020
@msftgits msftgits added this to the 5.0 milestone Feb 1, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.Net
Projects
None yet
Development

No branches or pull requests

4 participants