Title: UseCorrectCasing gets NullReferenceException from CommandInfo.get_Parameters · Issue #1708 · PowerShell/PSScriptAnalyzer · GitHub
Open Graph Title: UseCorrectCasing gets NullReferenceException from CommandInfo.get_Parameters · Issue #1708 · PowerShell/PSScriptAnalyzer
X Title: UseCorrectCasing gets NullReferenceException from CommandInfo.get_Parameters · Issue #1708 · PowerShell/PSScriptAnalyzer
Description: Steps to reproduce This reproduces about 25% of the time on my laptop. I think we may be exposing a gap in the fix for #1516, perhaps because we have about 250 .ps1 files in the repo. Clone https://github.com/microsoft/CSS-Exchange Chang...
Open Graph Description: Steps to reproduce This reproduces about 25% of the time on my laptop. I think we may be exposing a gap in the fix for #1516, perhaps because we have about 250 .ps1 files in the repo. Clone https:/...
X Description: Steps to reproduce This reproduces about 25% of the time on my laptop. I think we may be exposing a gap in the fix for #1516, perhaps because we have about 250 .ps1 files in the repo. Clone https:/...
Opengraph URL: https://github.com/PowerShell/PSScriptAnalyzer/issues/1708
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"UseCorrectCasing gets NullReferenceException from CommandInfo.get_Parameters","articleBody":"Steps to reproduce\r\n------------------\r\nThis reproduces about 25% of the time on my laptop. I think we may be exposing a gap in the fix for #1516, perhaps because we have about 250 .ps1 files in the repo.\r\n\r\n* Clone https://github.com/microsoft/CSS-Exchange\r\n* Change into that folder and run:\r\n\r\n```PowerShell\r\nGet-ChildItem *.ps1 -Recurse | % { Invoke-ScriptAnalyzer -Path $_ -Settings .\\PSScriptAnalyzerSettings.psd1 }\r\n```\r\n\r\n* If it doesn't reproduce on the first try, launch a new PowerShell window, cd into the folder, and try again.\r\n\r\nExpected behavior\r\n-----------------\r\nNo error.\r\n\r\nActual behavior\r\n---------------\r\n\r\n```none\r\nInvoke-ScriptAnalyzer: Object reference not set to an instance of an object.\r\n```\r\n\r\nIf an unexpected error was thrown then please report the full error details using e.g. `$error[0] | Select-Object *`\r\n\r\n```\r\nPSMessageDetails :\r\nException : System.NullReferenceException: Object reference not set to an instance of an object.\r\n at System.Management.Automation.CommandInfo.get_Parameters()\r\n at Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.UseCorrectCasing.AnalyzeScript(Ast ast, String fileName)+MoveNext()\r\n at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)\r\n at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)\r\n at Microsoft.Windows.PowerShell.ScriptAnalyzer.ScriptAnalyzer.\u003c>c__DisplayClass82_1.\u003cAnalyzeSyntaxTree>b__2()\r\nTargetObject : D:\\code\\CSS-Exchange\\Diagnostics\\ExchangeLogCollector\\RemoteScriptBlock\\IO\\Copy-BulkItems.ps1\r\nCategoryInfo : InvalidOperation: (D:\\code\\CSS-Exchang…\\Copy-BulkItems.ps1:String) [Invoke-ScriptAnalyzer], NullReferenceException\r\nFullyQualifiedErrorId : RULE_ERROR,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand\r\nErrorDetails :\r\nInvocationInfo : System.Management.Automation.InvocationInfo\r\nScriptStackTrace : at \u003cScriptBlock>, \u003cNo file>: line 1\r\n at \u003cScriptBlock>, \u003cNo file>: line 1\r\nPipelineIterationInfo : {0, 1}\r\n```\r\n\r\n```\r\n❯ Get-Error $Error[0]\r\n\r\nException :\r\n Type : System.NullReferenceException\r\n TargetSite :\r\n Name : get_Parameters\r\n DeclaringType : System.Management.Automation.CommandInfo\r\n MemberType : Method\r\n Module : System.Management.Automation.dll\r\n StackTrace :\r\n at System.Management.Automation.CommandInfo.get_Parameters()\r\n at Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.UseCorrectCasing.AnalyzeScript(Ast ast, String fileName)+MoveNext()\r\n at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)\r\n at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)\r\n at Microsoft.Windows.PowerShell.ScriptAnalyzer.ScriptAnalyzer.\u003c>c__DisplayClass82_1.\u003cAnalyzeSyntaxTree>b__2()\r\n Message : Object reference not set to an instance of an object.\r\n Source : System.Management.Automation\r\n HResult : -2147467261\r\nTargetObject : D:\\code\\CSS-Exchange\\Diagnostics\\ExchangeLogCollector\\RemoteScriptBlock\\IO\\Copy-BulkItems.ps1\r\nCategoryInfo : InvalidOperation: (D:\\code\\CSS-Exchang…\\Copy-BulkItems.ps1:String) [Invoke-ScriptAnalyzer], NullReferenceException\r\nFullyQualifiedErrorId : RULE_ERROR,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand\r\nInvocationInfo :\r\n MyCommand : Invoke-ScriptAnalyzer\r\n ScriptLineNumber : 1\r\n OffsetInLine : 36\r\n HistoryId : 2\r\n Line : Get-ChildItem *.ps1 -Recurse | % { Invoke-ScriptAnalyzer -Path $_ -Settings .\\PSScriptAnalyzerSettings.psd1 }\r\n PositionMessage : At line:1 char:36\r\n + … curse | % { Invoke-ScriptAnalyzer -Path $_ -Settings .\\PSScriptAnalyz …\r\n + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n InvocationName : Invoke-ScriptAnalyzer\r\n CommandOrigin : Internal\r\nScriptStackTrace : at \u003cScriptBlock>, \u003cNo file>: line 1\r\n at \u003cScriptBlock>, \u003cNo file>: line 1\r\nPipelineIterationInfo :\r\n```\r\n\r\nEnvironment data\r\n----------------\r\n\r\n\u003c!-- Provide the output of the following 2 commands -->\r\n\r\n```PowerShell\r\n> $PSVersionTable\r\n\r\nName Value\r\n---- -----\r\nPSVersion 7.1.3\r\nPSEdition Core\r\nGitCommitId 7.1.3\r\nOS Microsoft Windows 10.0.19043\r\nPlatform Win32NT\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}\r\nPSRemotingProtocolVersion 2.3\r\nSerializationVersion 1.1.0.1\r\nWSManStackVersion 3.0\r\n\r\n> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }\r\n\r\n1.19.1\r\n```\r\n","author":{"url":"https://github.com/bill-long","@type":"Person","name":"bill-long"},"datePublished":"2021-08-23T14:33:04Z","url":"https://github.com/PowerShell/PSScriptAnalyzer/issues/1708"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:cc764a98-287c-cdb3-6a6f-643f8c4569e4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D8A8:266BB:14809C0:1CE66A7:6AFCE45C |
| html-safe-nonce | 43180180bc8ad0fcf4d64eeb18eafded49497405e47af35350e1be421c3bd64b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOEE4OjI2NkJCOjE0ODA5QzA6MUNFNjZBNzo2QUZDRTQ1QyIsInZpc2l0b3JfaWQiOiI1NjQ2Njc4MzUyOTI1MDkwOTA4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | a4a15246f6c70ab0095ed1ae93698ae8df7122e599782ede2ee2f68ea1ec4cc0 |
| hovercard-subject-tag | issue:977102680 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PSScriptAnalyzer/1708/issue_layout |
| twitter:image | https://opengraph.githubassets.com/62da103967aacd06deaaed0c391879000e5b7c6f75238b9a77d351c0761f15aa/PowerShell/PSScriptAnalyzer/issues/1708 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/62da103967aacd06deaaed0c391879000e5b7c6f75238b9a77d351c0761f15aa/PowerShell/PSScriptAnalyzer/issues/1708 |
| og:image:alt | Steps to reproduce This reproduces about 25% of the time on my laptop. I think we may be exposing a gap in the fix for #1516, perhaps because we have about 250 .ps1 files in the repo. Clone https:/... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bill-long |
| hostname | github.com |
| expected-hostname | github.com |
| None | 99aede4c5f55ec5cf06666a8c9e03ebf9f85f7231223e7f1c38c16e5504835b3 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PSScriptAnalyzer git https://github.com/PowerShell/PSScriptAnalyzer.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 33149177 |
| octolytics-dimension-repository_nwo | PowerShell/PSScriptAnalyzer |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 33149177 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PSScriptAnalyzer |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ecfd63ca125ec74b42f74eeb158b3fa081c8c497 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width