Home Dashboard Directory Help
Search

OrderedDictionary becomes Hashtable when exported to and imported from clixml by Roman Kuzmin


Status: 

Active


3
0
Sign in
to vote
Type: Bug
ID: 771721
Opened: 11/20/2012 5:07:07 AM
Access Restriction: Public
0
Workaround(s)
view
2
User(s) can reproduce this bug

Description

The following script shows the problem:

    # new OrderedDictionary
    $t1 = [ordered] @{p1=11; p2=22; p3=33}

    # it is OrderedDictionary
    $t1.GetType().Name

    # export
    $t1 | Export-Clixml z1.clixml

    # import
    $t2 = Import-Clixml z1.clixml

    # it is not OrderedDictionary, it is Hashtable
    $t2.GetType().Name

Actual output:

    OrderedDictionary
    Hashtable

Expected output:

    OrderedDictionary
    OrderedDictionary
Details
Sign in to post a comment.
Posted by Roman Kuzmin on 5/9/2014 at 9:19 AM
v4.0 has the same issue.
Posted by Ronald Rink on 1/26/2013 at 7:49 AM
It actually seems that the type information gets lost when importing via Import-CliXml as the exported xml file still contains the following type information: "<T>System.Collections.Specialized.OrderedDictionary</T>".
Sign in to post a workaround.