-
Notifications
You must be signed in to change notification settings - Fork 234
Variables display isn't showing contents for generic-based dictionaries #75
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
Comments
That is... weird. There seems to be some implicit coercion going on when using the foreach approach. I'm fine with doing it this way though! I'd leave a comment above the loop explaining why it needs to remain a loop so that nobody changes it :) |
OK I “think” I know the “why” now after spending some time in dotPeek. Here are the two ways to get an enumerator from a Dictionary<TKey,TValue) based object, that the IDictionaryEnumerator IDictionary.GetEnumerator()
{
return new Enumerator(this, Enumerator.DictEntry);
}
IEnumerator IEnumerable.GetEnumerator()
{
return new Enumerator(this, Enumerator.KeyValuePair);
} I believe the This gives me confidence that any type that derives from |
Sounds good to me, thanks for looking into this! |
…ing for generic dictionaries like PSBoundParametersDictionary. Also enhanced the determination of what is expandable. We were not allowing structs like DateTime, TimeSpan and DictionaryEntry to expand. Changed test from !IsValueType to !IsPrimitive. Also enhanced the display of property values where we encounter an exception when trying to retrieve the property. Following VS debugger's lead on this on. You can see the display by looking at $Host.Runspace. And we also weren't displaying .NET properties for colletions and dictionaries. We now do that - in addition to the elements in the collection or dictionary. Also, don't try to add properties that are indexers.
…-bug For for issue #75, variables display isn't displaying anything for ge…
Specifically the
$PSBoundParameters
variable inLocal
scope of a function that specifies parameters. I've modified the code inVariableDetails.GetChildren
like so:The commented out code at the bottom is the original code. The LINQ operator OfType returns nothing for
PSBoundParametersDictionary
because it derives from the generic typeDictionary<string, object>
. I can see in res1 that the type of object enumerated using theOfType<>
method isKeyValuePair<string,object>
. However, if I just do the enumeration via a foreach loop, the item type works out toDictionaryEntry
even for PSBoundParametersDictionary.It is late and I'm not quite grokking how this is working and what the best way is to handle both
IDictionary
andIDictionary<TKey,TValue>
. If anybody has any suggestions, let me know. At the very least, the code above (sans the res1/res2 experiment) is better than what we have right now.The text was updated successfully, but these errors were encountered: