Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PesterDocumentSymbolProvider sometimes crashes when opening a file #859

Closed
daviwil opened this issue Jun 11, 2017 · 0 comments
Closed

PesterDocumentSymbolProvider sometimes crashes when opening a file #859

daviwil opened this issue Jun 11, 2017 · 0 comments
Labels
Area-Pester Issue-Bug A bug to squash.
Milestone

Comments

@daviwil
Copy link
Contributor

daviwil commented Jun 11, 2017

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)
@daviwil daviwil added Area-Pester Issue-Bug A bug to squash. labels Jun 11, 2017
@daviwil daviwil added this to the 1.3.2 milestone Jun 11, 2017
daviwil added a commit to daviwil/PowerShellEditorServices that referenced this issue Jun 12, 2017
This change fixes an issue in the PesterDocumentSymbolProvider where
CommandAsts for dot-sourced scripts were being evaluated by the symbol
provider and causing a crash when GetCommandName() returned null.  This
change causes dot-sourced commands to now be skipped and also skips any
CommandAst which returns null for GetCommandName().

Resolves PowerShell/vscode-powershell#859
daviwil added a commit to daviwil/PowerShellEditorServices that referenced this issue Jun 12, 2017
This change fixes an issue in the PesterDocumentSymbolProvider where
CommandAsts for dot-sourced scripts were being evaluated by the symbol
provider and causing a crash when GetCommandName() returned null.  This
change causes dot-sourced commands to now be skipped and also skips any
CommandAst which returns null for GetCommandName().

Resolves PowerShell/vscode-powershell#859
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Pester Issue-Bug A bug to squash.
Projects
None yet
Development

No branches or pull requests

1 participant