PowerShell / PowerShell/PSScriptAnalyzer
Object reference not set to an instance of an object.
還沒有人認領這個 Issue。
- 主要語言
- C#
- 星號
- 2.2k
- 分支
- 415
- 平均合併
- 13 小時 1 分鐘
- 30 天內合併 PR
- 2
描述
Good morning,
I have a PowerShell module at work with almost 400 functions. Recently I switched from PSScriptAnalyzer version 1.13.0 to version 1.21.0, fixed a lot of problems, but I have one left. On random functions I get the error:
Exception: Object reference not set to an instance of an object.
If I use the Invoke-ScriptAnalyzer function with the -Verbose switch, the error does not occur. I discovered this by accident while looking for which function is causing the error.
Please advise how to trace the cause.
Somewhere I found information that this can be caused by the Export-ModuleMember function, but I don't want to get rid of it because I would have to fiddle with building the manifest file and that's how Psake does it for me.
For building and checking a powershell module I use
TeamCity and
Psake = '4.9.0'
Pester = '5.3.3'
BuildHelpers = '2.0.16'
PSScriptAnalyzer = '1.21.0'
PSDepend = '0.3.8'

貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
首先使用報告中的 PowerShell 模組和 PSScriptAnalyzer 1.21.0 重現 null 參考錯誤,並比較一般的 Invoke-ScriptAnalyzer 執行與帶有 -Verbose 的執行。使用報告中列出的模組和建置工具版本,將故障範圍縮小到特定函式或分析器操作;完成的標準是找出原因並防止例外發生,且不要求詳細輸出。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- powershell
- 領域
- devtools
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 需要釐清
- 新手友好度
- 25/100