-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
ListDictionary TKey and TValue same type #1261
Comments
Could you provide more detail? I have no idea what you are talking about or what you are trying to do. |
This is about the Prism.Common.Listdictionary class in Prism.Wpf. When TKey and TValue is the same type, the methods Remove(TKey key) and Remove(TValue value) in ListDictionary<TKey, TValue> become ambiguous. |
This is not a collection meant to be used generically. These methods also work as intended for its uses within Prism. |
Also, I think you misunderstand what those methods are doing. When you use the (key, value) method, you are removing values from the list with the given key, not actually removing the list. This is described in the method comments:
What you did was create an Extension method that actually removed the list from the collection, which is not the intended function of the method you are using. |
Then we should make it internal. |
Once you make something public for nearly 10 years, you can't just make it internal. Also, the collection is working exactly as it should. The OP did not understand what those methods actually did. |
The API of Listdictionary class is poorly designed. Listdictionary<string, string> works in Prism.Modularity.ModuleDependencySolver only because it never attempts to remove neither key nor value. |
Possibly, but this really is a non-issue. |
Sure, not a big deal. But the library provides public general-purpose collection class, it does not behave well, and the users complain. This can be fixed without breaking backward compatibility by adding RemoveKey(TKey) and RemoveValue(TValue) methods which will do exactly what Remove(TKey) and Remove(TValue) do. |
The methods in the current API work as expected. The remove Key/Value will first get the collection based on key, the loop through that collection and remove the value from that collection. I am confused on what needs to change. |
After the line https://github.com/PrismLibrary/Prism/blob/master/Source/Wpf/Prism.Wpf/Modularity/ModuleDependencySolver.cs#L59 add the line
and try compile. |
So your main complaint is that the method Remove(value) doesn't accurately represent what the method does. Instead RemoveValueFromLists(value) would make more sense? |
Did you tried to compile? |
No, I am working on other, more important, things :) |
The problem is not the meaningful name. It does not compile. Does not work at all. |
Ahh, now I see what you mean. It is because of the method name :) Should be named RemoveValue instead. Actually looks like the easy fix is for both of the methods to be called RemoveValue. |
No, method names should be different. The problem is that there exist two methods with the same name (Remove) which differ only in argument type (TKey/TValue). This becomes ambiguous when TKey and TValue are the same type. |
Yeah that's what I meant.
That would fix the issue. |
But this will be a breaking change. Easy to fix though. |
The good news is I don't think many people are using this anyways. In 10 years this is the first I have heard of anyone using it. It will be noted as a break, and it will result in a build error so anyone using it will know where the break is. If it was a behavior break, those are nearly impossible to find and I try to avoid those at all costs. |
Fixed |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Package info
Repro steps
with the same "key" and "value" type you cannot use the Remove( TKey ) or Remove( TValue ) method
The text was updated successfully, but these errors were encountered: