-
Notifications
You must be signed in to change notification settings - Fork 398
Closed
Description
Thanks to @lipkau for the initial bug report in Slack.
Steps to reproduce
Invoke-ScriptAnalyzer -ScriptDefinition '[foo]::bar = [baz]::qux'
Expected behavior
Normal behaviour, no warnings.
Actual behavior
Invoke-ScriptAnalyzer : Object reference not set to an instance of an object.
At line:1 char:2
+ Invoke-ScriptAnalyzer -ScriptDefinition '[foo]::SecurityProtocol = [ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Invoke-ScriptAnalyzer], NullReferenceException
+ FullyQualifiedErrorId : RULE_ERROR,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand
If an unexpected error was thrown then please report the full error details using e.g. $error[0] | Select-Object *
writeErrorStream : True
PSMessageDetails :
Exception : System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.AvoidAssignmentToAutomaticVariable.<AnalyzeScript>d__2.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Microsoft.Windows.PowerShell.ScriptAnalyzer.ScriptAnalyzer.<>c__DisplayClass82_1.<AnalyzeSyntaxTree>b__2()
TargetObject :
CategoryInfo : InvalidOperation: (:) [Invoke-ScriptAnalyzer], NullReferenceException
FullyQualifiedErrorId : RULE_ERROR,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {0, 1}
writeErrorStream : True
PSMessageDetails :
Exception : System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.AvoidAssignmentToAutomaticVariable.<AnalyzeScript>d__2.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Microsoft.Windows.PowerShell.ScriptAnalyzer.ScriptAnalyzer.<>c__DisplayClass82_1.<AnalyzeSyntaxTree>b__2()
TargetObject :
CategoryInfo : InvalidOperation: (:) [Invoke-ScriptAnalyzer], NullReferenceException
FullyQualifiedErrorId : RULE_ERROR,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {0, 1}
Environment data
This bug was introduced in 1.17.0 in the new PSAvoidAssignmentToAutomaticVariable
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.17134.81
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17134.81
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.17.0