Intellisense doesn't work after piping from custom cmdlet (Powershell ISE)

Viewed 141

If I type the following line in the PowerShell ISE editor, I get Intellisense after the dot operator in $_ variable:

Get-ChildItem ATextFile.txt | foreach { $_.FullName }

In this case, $_ is an instance of System.IO.FileSystemInfo. The editor will properly list all accessible members from this object.

Now, if I write:

function GetFile {
  return [System.IO.FileInfo]::new(".\ATextFile.txt")
}

GetFile | foreach { $_.FullName }

The script runs fine, but Intellisense doesn't work after the dot operator in $_.

Am I missing a syntax to make IntelliSense work correctly? Maybe an annotation to "document" the returning value?

1 Answers
Related