Anonymous Types conversion

2 posts, 0 answers
  1. Brian Mains
    Brian Mains avatar
    485 posts
    Member since:
    Oct 2008

    Posted 23 Dec 2009 Link to this post

    Hello,

    The code converter does not convert anonymous types well from  C# to VB.  Consider this:

    var types = new[]
    {
        new A { Key= 1, Name = 2 },
        new A { Key= 1, Name = 2 },
        new A { Key= 1, Name = 2 }
    }

    Does VB have an anonymous collection feature?  I don't think it does, so I always convert to:

    Dim types As New List<A>()
    types.Add(New A With { .Key = 1, .Name = 2});
    .
    .

    But your code converter just does:

    new A()
    new A()

    Something like that... I was hoping it would at least convert \

    new A { Key= 1, Name = 2 },

    to

    New A With { .Key = 1, .Name = 2}

    I understand if it doesn't create a list, but if it could convert the anonymous types correctly, that would help a lot.

    Thanks.
  2. Todd
    Admin
    Todd avatar
    66 posts

    Posted 04 Jan 2010 Link to this post

    Hello Brian,

    Thanks for the feedback. It does seem that NRefactory should support this, so we'll try to update our engine soon. In the mean time, you can try your conversion here to see what NRefactory produces:

    http://codeconverter.sharpdevelop.net

    Hope that helps.

    -Todd
Back to Top