NullReferenceException when calling SyntaxFactory.ParseArgumentList
#58,668 创建于 2022年1月6日
仓库指标
- 星标
- (20,414 个星标)
- PR 合并指标
- (平均合并 6天 17小时) (30 天内合并 256 个 PR)
描述
Version Used:
Nuget Microsoft.CodeAnalysis.VisualBasic Versions=4.0.1, 3.11.0
What are we trying to do? Parse an argument list (and recieving an unexpected exception (presumably because the input is invalid).)
- Reference
Microsoft.CodeAnalysis.VisualBasicpackage in a project - Call
SyntaxFactory.ParseArgumentList("42")
Expected Behavior:
Correct parsing of the argument. At least a more understandable exception like ArgumentException or similar, but not a direct bubbling of an internal exception.
Actual Behavior:
NullReferenceExceptionwhen calling a static method.
The current implementation is quite misleading. As soon as one changes the passed string to contain parenthesis (turn "42" into "(42)") the parsing works.
Which could be acceptable behavior. But simply passing on the internal exception is not. It should be something else.