How could I get the type of a Visual Basic expression? #48948
Unanswered
StephenWeatherhead
asked this question in
Q&A
Replies: 1 comment
-
@weatherheadio PM me on Gitter @paul1956, I don't think this is the place to ask this question. You need a SyntaxNode, a SemanticModel to get TypeInfo not a string there are a lot of things C and D could be. This is also complicated that you need to know Options. Option Explicit Off
Option Strict Off
Option Infer Off
'...
Dim i As Integer = "0" + "1" ' i is an Integer whose value is 1
Dim j = "0" + "1" ' J is an Object whose Type is String whose value is "01" |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have the Visual Basic expression as a string and I have the names of the variables it references (and their types), the namespaces and referenced assemblies. From this I would like to get the Type of the expression.
Essentially, I would like to implement the method with the following signature:
Type GetTypeOfExpression(string expressionText, IEnumerable<string> namespaces, IEnumerable<Assembly> referencedAssemblies, IEnumerable<(string, Type)> referencedVariables)
Example expression strings could be "c + d" (this could be a string or a number depending on the types of "c" and "d"), or "myObject.MyMethod()" (would use the referenced assemblies to get the type).
Thank you for your help
Beta Was this translation helpful? Give feedback.
All reactions