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

NullReferenceException analyzing xWebAdministration DSC resource #982

Closed
edyoung opened this issue May 3, 2018 · 1 comment · Fixed by #1046
Closed

NullReferenceException analyzing xWebAdministration DSC resource #982

edyoung opened this issue May 3, 2018 · 1 comment · Fixed by #1046

Comments

@edyoung
Copy link
Contributor

edyoung commented May 3, 2018

Steps to reproduce

save-module -Name xWebAdministration -Version 1.20.0.0 -Path .
Invoke-ScriptAnalyzer .

Expected behavior

some warnings if warranted

Actual behavior

Numerous errors, including the NullReferenceException below:
writeErrorStream      : True
PSMessageDetails      :
Exception             : System.NullReferenceException: Object reference not set to an instance of an object.
                           at Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.UseIdenticalMandatoryPa
                        rametersDSC.GetKeys(String fileName)
                           at Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.UseIdenticalMandatoryPa
                        rametersDSC.<AnalyzeDSCResource>d__7.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.AnalyzeSyntaxTree(Scr
                        iptBlockAst scriptAst, Token[] scriptTokens, String filePath)
TargetObject          : C:\temp\testpackages\xWebAdministration\1.20.0.0\DSCResources\MSFT_xWebsite\MSFT_xWebs
                        ite.psm1
CategoryInfo          : InvalidOperation: (C:\temp\testpac...T_xWebsite.psm1:String) [Invoke-ScriptAnalyzer],
                        NullReferenceException
FullyQualifiedErrorId : RULE_ERROR,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCo
                        mmand
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.UseIdenticalMandatoryPa
                        rametersDSC.GetKeys(String fileName)
                           at Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.UseIdenticalMandatoryPa
                        rametersDSC.<AnalyzeDSCResource>d__7.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.AnalyzeSyntaxTree(Scr
                        iptBlockAst scriptAst, Token[] scriptTokens, String filePath)
TargetObject          : C:\temp\testpackages\xWebAdministration\1.20.0.0\DSCResources\MSFT_xWebApplication\MSF
                        T_xWebApplication.psm1
CategoryInfo          : InvalidOperation: (C:\temp\testpac...pplication.psm1:String) [Invoke-ScriptAnalyzer],
                        NullReferenceException
FullyQualifiedErrorId : RULE_ERROR,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCo
                        mmand
ErrorDetails          :
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {0, 1}

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.16299.251
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.16299.251
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.16.1
@bergmeister
Copy link
Collaborator

bergmeister commented May 5, 2018

I can confirm this still happens on the latest version of development. The more minimal repro is:

save-module -Name xWebAdministration -RequiredVersion 1.20.0.0 -Path .
$results = Invoke-ScriptAnalyzer -Path .\xWebAdministration\1.20.0.0\DSCResources\MSFT_xWebApplication

Here is the snapshot inside the debugger:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants