Skip to content

PesterDocumentSymbolProvider sometimes crashes when opening a file #859

Closed
@daviwil

Description

Looks like the new PesterSymbolReference.GetCommandType isn't catching null cases.

Logs provided by @muzzar78:

    System.AggregateException: One or more errors occurred. ---> System.NullReferenceException: Object reference not set to an instance of an object.
       at Microsoft.PowerShell.EditorServices.Symbols.PesterSymbolReference.GetCommandType(String commandName)
       at Microsoft.PowerShell.EditorServices.Symbols.PesterDocumentSymbolProvider.<>c.<Microsoft.PowerShell.EditorServices.Symbols.IDocumentSymbolProvider.ProvideDocumentSymbols>b__0_0(Ast ast)
       at System.Management.Automation.Language.AstSearcher.Check(Ast ast)
       at System.Management.Automation.Language.CommandAst.InternalVisit(AstVisitor visitor)
       at System.Management.Automation.Language.PipelineAst.InternalVisit(AstVisitor visitor)
       at System.Management.Automation.Language.StatementBlockAst.InternalVisit(AstVisitor visitor, ReadOnlyCollection`1 traps, ReadOnlyCollection`1 statements, AstVisitAction action)
       at System.Management.Automation.Language.NamedBlockAst.InternalVisit(AstVisitor visitor)
       at System.Management.Automation.Language.ScriptBlockAst.InternalVisit(AstVisitor visitor)
       at System.Management.Automation.Language.Ast.FindAll(Func`2 predicate, Boolean searchNestedScriptBlocks)
       at Microsoft.PowerShell.EditorServices.Symbols.PesterDocumentSymbolProvider.Microsoft.PowerShell.EditorServices.Symbols.IDocumentSymbolProvider.ProvideDocumentSymbols(ScriptFile scriptFile)
       at Microsoft.PowerShell.EditorServices.CodeLenses.PesterCodeLensProvider.ProvideCodeLenses(ScriptFile scriptFile)

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions