-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Mark StringDictionary as obsolete #889
Comments
Hm. We've traditionally been against marking things Anecdotally, part of a class I took in college was writing your own specialized versions of collections. So basically this code. |
This (and probably many other specialised collections) are from pre-.NET Framework 2.0 when there was no generics. I guess this reduced the needs for having to write strongly-typed wrappers over HashTable/ArrayList/Etc. I think nobody just bothered to work on it because generic collections are superior over these specialised ones due to generic ones being multi-purpose compared to this. I bet there's surprising amount of apps which use this and many other non-generic collections like ArrayList and HashTable (because "they just work"). Adding ObsoleteAttribute might cause some trouble for those. |
@terrajobst what's our stance w.r.t. obsoleting non-generic collections? |
I am generally sceptical about obsoleting non-generic collections, but I have to say that the fact that I don't know what the documentatation is built from, but the code already suggests this class should be considered obsolete, and the constructor notes it shouldn't be used for files etc. The I cannot say the same about |
That's the point. If the docs say it should be considered as obsolete, it should have an obsolete attribute. Obsolete don't break code, it only throws a warning and this warning is not an issue because the docs give this warning as well. If there are apps which relies on it they either find an alternative or stick to an obsolete class. I've seen many stuff marked as obsolete: This includes the BinaryFormatter and Assembly.CodeBase which are both heavily used things and for the binaryformatter there is no 1:1 replacement. I fully understand that making things as obsolete should be done carefully.. but hence if even the documentation says its obsolete, then I dont understand why the class itself does not have this attribute on it. |
Just to clarify we are in agreement that
It's not as simple as that. Some codebases treat warnings as errors, and there is an understandable expectation that obsolete stuff will be removed in the future. The fact that we cannot distinguish between "we messed up and this will be going away ASAP" and "you might want to consider this other thing if possible because we like the new design better" is rather unfortunate. |
This is used in PowerShell Core in public API ( |
@iSazonov you are aware that several of these classes, especially this one, are heavily used by the ASP.NET team, correct? |
@Kaelum I only pointed that we should think about a replacement early because it affects other public APIs. |
I recently discovered StringDictionary. To me it is not clear what's the benefit of using it instead of Dictionary<string,string>. Also benchmarks reveal that it is slower comparing to Dictionary<string,string>. When I searched the internet for its purpose people said its coming from old times https://stackoverflow.com/questions/627716/stringdictionary-vs-dictionarystring-string. So I am suggestion to mark StringDictionary as obsolete and remove it in the future, telling people to use Dictionary<string,string> instead. And maybe doing the same with StringCollection? Please correct me if I am wrong and there is an important reason to use StringDictionary over Dictionary<string,string>.
Add
Add Benchmark
Contains
Contains Benchmark
The text was updated successfully, but these errors were encountered: