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

Fix NullRefEx bug when accessing scriptFile.ReferencedFiles #838

Merged
merged 2 commits into from
Jan 8, 2019

Conversation

rkeithhill
Copy link
Contributor

This happens because the ScriptFile ctor does not initialize all its
public props. I added initialization for the other public props
except for the ScriptAst prop. I don't see an empty Ast. Perhaps null
is OK for this prop?

This address vscode-powershell bug PowerShell/vscode-powershell#1675

No real need for ScriptTokens to have a backing field. Make it auto like the other props.

Also, for the 2.0.0 branch, we should see if we can use Array.Empty<>()
for initialization. It isn't availble to net45x. :-(

…ns because the ScriptFile ctor does not initialize all itspublic props. I added initialization for the other public propsexcept for the ScriptAst prop. I don't see an empty Ast. Perhaps nullis OK for this prop?This address vscode-powershell bug https://github.com/PowerShell/vscode-powershell/issues/1675Also, for the 2.0.0 branch, we should see if we can use Array.Empty<>()for initialization.  It isn't availble to net45x.  :-(
@rkeithhill rkeithhill force-pushed the rkeithhill/fix-refdfiles-nre branch from 3fdb5e1 to bd01d79 Compare December 28, 2018 21:18
@TylerLeonhardt
Copy link
Member

@rkeithhill could we possibly add a test for this?

https://github.com/PowerShell/PowerShellEditorServices/blob/master/test/PowerShellEditorServices.Test/Session/ScriptFileTests.cs

That maybe just creates a simple ScriptFile and checks its props?

Or something a little further up the stack that creates a new ScriptFile

@rkeithhill
Copy link
Contributor Author

Working on it. Man it sure would be nice if the xUnit / VS Test Explorer integration weren't so crappy. Can't seem to step into tests and test output won't show me line numbers. Sigh...

Copy link
Member

@TylerLeonhardt TylerLeonhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thanks @rkeithhill !

@TylerLeonhardt TylerLeonhardt merged commit 73044d1 into master Jan 8, 2019
@TylerLeonhardt TylerLeonhardt deleted the rkeithhill/fix-refdfiles-nre branch January 8, 2019 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants