Intellisense for custom objects properties not appearing

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
licensing_SST
Posts: 3
Last visit: Sun Dec 04, 2022 7:16 pm
Has voted: 1 time

Intellisense for custom objects properties not appearing

Post by licensing_SST »

To help you better we need some information from you.

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. *** Product, version and build: Sapien Powershell Studio 2022
Operating system: Windows 11
PowerShell version(s): 5.1.22000.832


*** Please add details and screenshots as needed below. ***

The issue is for this code here in that the $Y object is not autocompleting the property details. It works on Windows Powershell ISE but not for Sapien Powershell studio 2022

$Y = [pscustomobject]@{ 'name' = 'John'; 'town' = 'Playtown' }

"$Y." does not display "name" or "town"

Do i need to configure anything for this to work.
Attachments
1.Sapien Powershell.jpg
1.Sapien Powershell.jpg (74.92 KiB) Viewed 3393 times
2. Windows Powershell ISE.jpg
2. Windows Powershell ISE.jpg (80.21 KiB) Viewed 3393 times
User avatar
Alexander Riedel
Posts: 8180
Last visit: Sun Jan 29, 2023 12:22 pm
Answers: 12
Been upvoted: 30 times

Re: Intellisense for custom objects properties not appearing

Post by Alexander Riedel »

The ISE does not display these custom members until you run the script at least once. That is no doubt convenient for exploration and learning.
But keeping the runspace around is misleading and in some cases even dangerous. It encourages users to run unknown scripts in order to get intellisense. I leave it to your imagination how that can lead to disaster.

Try this:
Create your script in the ISE:

$Y = [pscustomobject]@{ 'name' = 'John'; 'town' = 'Playtown' }

$Y.Town

as Test.ps1

Run it. It will display 'Playtown' as you expect.
Now delete the first line that sets $Y. Save the script. Run it.
It will still display 'Playtown'
Now create a brand new script called "Test2.ps1"
Add
$Y.Town
and run it.
It will still display 'Playtown'

Now load some other, completely unrelated script you have some place else.
Add
$Y.Town
as the first line and run it.
It will still display 'Playtown'

You can see where this can lead you to believe you have variables in your script that you do not have.

So we do not do that. We do not keep the runspace alive like the ISE does.
Alexander Riedel
SAPIEN Technologies, Inc.
licensing_SST
Posts: 3
Last visit: Sun Dec 04, 2022 7:16 pm
Has voted: 1 time

Re: Intellisense for custom objects properties not appearing

Post by licensing_SST »

Hi Alexander,
i understand what you mean but you also nailed in the head around convenient for exploration and learning. Is there anyway else for exploring ?
User avatar
Alexander Riedel
Posts: 8180
Last visit: Sun Jan 29, 2023 12:22 pm
Answers: 12
Been upvoted: 30 times

Re: Intellisense for custom objects properties not appearing

Post by Alexander Riedel »

That is a good question, albeit mostly a philosophical one. Meaning, there is not only one true answer. I will elaborate a bit, also for the sake of other readers, and you can form your own opinion.
I personally highlight code I want to check or explore in a script and run the selected code in the integrated console of PowerShell Studio or PrimalScript. That allows me to then explore the results within the console. You can just as well fire up a regular console and paste the code in question there. I do that regularly if I need to check if there are different behaviors on something between Windows PowerShell and PowerShell 7.x

There is also a notion of exclusivity that has always existed in anything related to software development, regardless of language.
Cue discussions about Vi vs Emacs. Microsoft C vs Borland C. Borland's IDE vs Symantec's vs Microsoft's.
C versus C++ versus C#. PowerShell ISE versus VS Code vs PowerShell Studio vs Notepad++, you name it.
I have found that these arguments are largely not only useless but detrimental to your work. You cannot and should not expect the ISE to do all that PowerShell Studio does and vice versa.
Both where designed for a different task and have for the most part a different type of user in mind. That does not make one better than the other, it just makes them different.
There is nothing in the 'rules' that says you cannot use more than one tool.
You have, I am certain, different types of screwdrivers, hammers, pliers and assorted other tools in your toolbox. Just like you would not use machine screws for a drywall job, you would not open a readme.txt with a SQL IDE. You use the best and most appropriate tool for the job at hand.
In other words, if you find the ISE convenient to explore some code, how it behaves and what it returns and it is easier for you to use than a console, do that. Nobody will force you to remove or abandon the ISE just because you bought another IDE for UI design or a more complex multi-file application.
Build a toolbox with what you need and what suits you, rather than focusing on one single 'hammer' and expect it to do everything you want.

Hope this helps.
Alexander Riedel
SAPIEN Technologies, Inc.
licensing_SST
Posts: 3
Last visit: Sun Dec 04, 2022 7:16 pm
Has voted: 1 time

Re: Intellisense for custom objects properties not appearing

Post by licensing_SST »

Hi Alexander,
Thank you for your explanation and certainly agree to your take on having arguments or comparison between products and tools being detrimental to one's work. I will continue on my scripting journey and build up on my toolset to best suits me.