Description
- Slack Community Chat: https://powershell.slack.com (you can sign-up at http://slack.poshcode.org/ for an invite)
- Also have a look at the
RoleDocumentation
folder for more information on each rule:
https://github.com/PowerShell/PSScriptAnalyzer/tree/development/RuleDocumentation
I found another issue on stackoverflow that was raised a while ago that is the same issue but does not have a solution: https://stackoverflow.com/questions/51918645/how-to-suppress-powershell-unable-to-find-type-typename-message
controller.ps1:
class Controller {
[System.Collections.Hashtable]$_passThru;
Controller(
[System.Collections.Hashtable]$passThru
) {
$this._passThru = $passThru;
}
}
foreachcontroller.ps1
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('TypeNotFound', '')]
class ForeachController : Controller {
ForeachController(
[System.Collections.Hashtable]$passThru
) {
}
}
VScode shows this error:
Ignoring 'TypeNotFound' parse error on type 'Controller'. Check if the specified type is correct. This can also be due the type not being known at parse time due to types imported by 'using' statements.
As you can see, I attempted to suppress th message in foreachcontroller.ps1 (the reference to the Controller class), but this has no effect.
I need to supress the message in 2 contexts. Once when I invoke the script analyzer on the command line, then I also need to suppress the scriptanalyzer built into VSCode to prevent the dreaded red squiggly line from showing up in the text editor.
I can't find relevant documentation for this in the githib repo or elsewhere, so how do I supress this message. When I go to build the module that contains this code, there is no build error, but I need to supress this error to prevent VSC from flagging this none issue. There is no entry for the TypeNotFound rule in the rule documentation.
thanks.