Skip to content

SyntaxTrivia doesn't properly validate it's SyntaxTree #40773

@jaredpar

Description

@jaredpar

Consider the following code:

var trivia = SyntaxFactory.SyntaxTrivia(SyntaxKind.WhitespaceTrivia, " ");
var location = trivia.GetLocation();

This code will throw a NullReferenceException because the implementation assumes there is a SyntaxTree available and there is not in this case. The code should be validating this and throwing a better exception type here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions