Search

PS V3: Case sensitivity of a dehydrated hashtable depends on its content (clixml) by Roman Kuzmin

Active

1
0
Sign in
to vote
Type: Bug
ID: 771175
Opened: 11/14/2012 10:59:17 PM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
This script works as expected: a case sensitive hashtable is exported to clixml and then imported as case sensitive:

    # a case sensitive hashtable with keys 'a' and 'A'
    $hash = New-Object System.Collections.Hashtable
    $hash.Add('a', 1)
    $hash.Add('A', 2)
    $hash | Export-Clixml test.clixml

    # the dehydrated is still case sensitive, it contains keys 'a' and 'A'
    $hash2 = Import-Clixml test.clixml
    $hash2

Output:

    Name Value
    ---- -----
    a    1
    A    2

This script does not work as expected: a case sensitive hashtable is exported to clixml and then imported as NOT case sensitive:

    # a case sensitive hashtable with a key 'a'
    $hash = New-Object System.Collections.Hashtable
    $hash.Add('a', 1)
    $hash | Export-Clixml test.clixml

    # the dehydrated is not case sensitive, it fails on adding 'A'
    $hash2 = Import-Clixml test.clixml
    $hash2.Add('A', 2)

Error:

    Exception calling "Add" with "2" argument(s): "Item has already been added. Key in dictionary: 'a' Key being added: 'A'"
    At ...\try2.ps1:9 char:2
    +     $hash2.Add('A', 2)
    +     ~~~~~~~~~~~~~~~~~~
Details (expand)
How often does this happen?
Always Happens

Have you seen this problem before in this product?

No, this is new to the most recent version
Reproduction Steps
 
Expected Results
 
File Attachments
0 attachments
Sign in to post a comment.
Sign in to post a workaround.