Deprecating Resolve(Type, IDictionary) in favor of IReadOnlyDictionary<string, object>
See original GitHub issueRight now it’s a bit of a pain to use the Resolve method because what I’ll have in hand is an IReadOnlyDictionary<string, object>
, usually from a method parameter.
Please consider adding this method and removing the nongeneric overload.
The nongeneric one would be a problem. So long as it’s there and you pass it a type like Dictionary<string, object>
which implements both interfaces, which all of the BCL dictionaries do, you’ll have to disambiguate the overload by explicitly casting to one or the other interface type.
This would be a breaking change for people still using non-generic dictionaries like Hashtable
, and there may be a few, so what if you removed it in v5?
Issue Analytics
- State:
- Created 6 years ago
- Comments:28 (16 by maintainers)
Top Results From Across the Web
c# - Extension methods for both IDictionary and ...
So if the OP wants to use the same extension method on both types of objects, he needs to write the method using...
Read more >Why does IDictionary not implement IReadOnlyDictionary
2 Answers. Preface: this answer is predicated on a misunderstanding that IReadOnlyDictionary means "A dictionary that is read-only". It ...
Read more >IReadOnlyDictionary<TKey,TValue> Interface
The IReadOnlyDictionary<TKey,TValue> interface allows the contained keys and values to be enumerated, but it does not imply any particular sort order. The ...
Read more >Class SerializedDictionary<K, V> | Core RP Library | 15.0.6
Unity can't serialize Dictionary so here's a custom wrapper that does. ... before it can be serialized as Unity won't serialized generic-based types...
Read more >Implementing a custom Trigger for an Isolated .Net Azure ...
For this post I wanted to research how to implement a custom trigger for Azure Functions running in the isolated process model.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@jnm2
The extension Arguments.FromReadOnlyDictionary now calls a shallow copy constructor here.
I think this coupled with making Arguments readonly for any side effects when it comes to calling Add, Clear or Remove by setting isReadOnly here gets you what you need.
It is also a tidy way of getting rid of bad methods as it turns out 😃
@fir3pho3nixx thanks for looking into this more, I had just thought we’d do as @jnm2 suggested and implement it at the API surface level but this is something we’ll definitely need to look at more.
If Windsor does mutate the user’s dictionary then we could probably implement copy-on-write using the cheshire cat pattern or something similar so the Windsor internals are none the wiser that they were even passed a readonly dictionary.
However, we’ve already got copy-on-write with the overload that takes an anonymous type which Windsor obviously can’t modify, Windsor uses the
ReflectionBasedDictionaryAdapter
to read the contents and methods likeAdd
throw aNotImplementedException
, maybe some consolidation of code paths: