File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ Imports NuGet.Packaging.Core
1212Imports NuGet.ProjectManagement
1313Imports NuGet.Protocol.Core.Types
1414Imports NuGet.Resolver
15- 'TODO: Multiple statements
15+ 'TODO: Child variables only
16+ 'TODO: Non method things
1617Public Class REPL
1718 Private _imports As New List( Of ImportsStatementSyntax)
1819 Private _state As New Dictionary( Of String , Object )
@@ -85,7 +86,26 @@ Public Class REPL
8586
8687 Private Function GetTypeName( key As String ) As String
8788 Dim obj As Object = _state( key )
88- Return If (obj Is Nothing , "Object" , obj.GetType.FullName)
89+ If obj Is Nothing Then
90+ Return "Object"
91+ Else
92+ Dim type As Type = obj.GetType
93+ Return GetTypeName(type)
94+ End If
95+ End Function
96+
97+ Public Function GetTypeName(type As Type) As String
98+ If type.IsGenericType Then
99+ Return SyntaxFactory.GenericName(GetGenericNameActual(type), SyntaxFactory.TypeArgumentList( New SeparatedSyntaxList( Of TypeSyntax)().AddRange(type.GenericTypeArguments.Select( Function (x) SyntaxFactory.ParseTypeName(GetTypeName(x)))))).NormalizeWhitespace.ToFullString
100+ ElseIf type.IsArray Then
101+ Return SyntaxFactory.ArrayType(SyntaxFactory.ParseTypeName(GetTypeName(type.GetElementType))).NormalizeWhitespace.ToFullString
102+ Else
103+ Return type.FullName
104+ End If
105+ End Function
106+
107+ Private Function GetGenericNameActual(type As Type) As String
108+ Return $"{type.Namespace}.{type.Name.Remove(type.Name.IndexOf(" `"))}"
89109 End Function
90110
91111 Public Sub Reset()
You can’t perform that action at this time.
0 commit comments