Home Dashboard Directory Help
Search

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


Status: 

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)
view
0
User(s) can reproduce this bug

Description

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
Sign in to post a comment.
Sign in to post a workaround.