Page 1 of 1

Code completion doesn't work as expected

Posted: Wed Jul 29, 2020 3:50 am
by chbwien
If I use the following simple demo code:
  1. [xml]$xml = Get-Content 'inventory.xml'
  3. foreach ($node in $xml.DocumentElement.Childnodes)
  5. {
  7.     $myjuhu = $xml.CreateElement('juhu')
  9.     $myjuhu.innerText = 'juhu'
  11.     [void]$node.appendchild($myjuhu)
  13.     $node.removechild($myjuhu)
  15. }
  17. $xml.Save('inventory_out.xml')
I have no chance to get any help if I type $node.

If I do the same with the standard ISE, after the first run ISE knows the type of $node and it will offer me methods for $node.
2020-07-29 12_43_52-Windows PowerShell ISE.png
2020-07-29 12_43_52-Windows PowerShell ISE.png (65.65 KiB) Viewed 234 times
So what do I have to do, to get at least the same help from Powershell Studio?

Re: Code completion doesn't work as expected

Posted: Wed Aug 05, 2020 7:27 am
by brittneyr
This is because it does not know what the type of $node is, therefore the editor does not know what information to provide via intellisense. As you casted the the result of Get-Content to xml, it was then recognized as xml and intellisense information was able to be provided. PowerShell Studio doesn't store information about the script after its run.

You may find the following helpful: