dotnet/roslyn

NullReferenceException when calling SyntaxFactory.ParseArgumentList

Offen

#58.668 geöffnet am 06.01.2022

 (0 Kommentare) (1 Reaktion) (1 zugewiesene Person)C# (4.257 Forks)batch import
Area-CompilersBugLanguage-VBhelp wanted

Repository-Metriken

Stars
 (20.414 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (256 gemergte PRs in 30 T)

Beschreibung

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).)

  1. Reference Microsoft.CodeAnalysis.VisualBasic package in a project
  2. 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.

Contributor Guide