dotnet/roslyn

Cannot get type of implicitly typed array in VB.NET

Open

#11.933 aberto em 11 de jun. de 2016

Ver no GitHub
 (5 comments) (0 reactions) (0 assignees)C# (4.257 forks)batch import
Area-CompilersBugConcept-APILanguage-VBhelp wanted

Métricas do repositório

Stars
 (20.414 stars)
Métricas de merge de PR
 (Mesclagem média 6d 17h) (256 fundiu PRs em 30d)

Description

Version Used: 1.2.2

Steps to Reproduce:

  1. Have the following piece of code in your sample VB.NET solution (lets call {1, 2} initExpr):

    Dim a = {1, 2}
    
  2. setup roslyn code analysis solution and try to get type of initExpr syntax node using:

    var type = model.GetTypeInfo(initExpr).Type
    

    where model is SemanticModel of document where initExpr resides,

  3. observe type is null

Expected Behavior: Type of initExpr should be Integer()

Actual Behavior: Type of initExpr is null

Why?

  • above approach to get type info works just fine in C# for implicitly typed arrays such as new[] {1, 2},
  • putting cursor over a variable a in Visual Studio correctly shows it is of type Integer() so the type is obviously known and should be returned when trying to access it via GetSymbolInfo method.

Issue initially described at StackOverflow.

Guia do colaborador