Several problems about PrimalSense

Use this forum to ask questions after your subscription maintenance expires or before you buy. Need information on licensing or pricing? Questions about a trial version? This is the right place for you. No scripting questions, please.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE 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.
This topic is 1 year and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
davider360
Posts: 18
Last visit: Wed Nov 23, 2022 2:35 am

Several problems about PrimalSense

Post by davider360 »

Hello everyone

I encountered the following problems in the process of using Powershell Studio 2022 . But working normally in PowerShell ISE. If someone knows the problem, please tell me, thank you in advance

My system ver: windows 7 sp1 X64
powershell studio ver: 5.8.212

problem1
All built -in classes cannot display the NEW structure method. In addition, there are the same problem using a third -party library. Work normally under the ISE, See the demo and code
1.gif
1.gif (162.65 KiB) Viewed 7198 times

Code: Select all

using namespace System.Collections.Generic;

$S = [string]::new("hello")
$L1 = [List[int]]::new()
$L2 = [System.Collections.Generic.List[int]]::new()
$L3 = [System.Collections.ArrayList]
$D = [system.collections.generic.dictionary[string, int]]::new()
problem2
There is no $Matches automatic variable in the automatic completion list, which exists in ISE, See the demo
2.gif
2.gif (73.89 KiB) Viewed 7198 times
problem3
All methods of the system built -in shell cannot be displayed in the list. In addition, the use of third -party COM components also has the same problem, working normally in PowerShell ISE, See the demo and code

Code: Select all

$shell = New-Object -com 'Shell.Application'
$shell
3.gif
3.gif (137.17 KiB) Viewed 7198 times
problem4
It cannot be displayed by members of the PSOBJECT object and its internal methods,In addition, the PSCUSTOMOBJECT object also has this problem, See the demo and code (In the second post below)

$obj.psobject.properties.remove('Name')

Code: Select all

$obj = New-Object -TypeName PSObject -Property @{
	Name	 = 'Kevin'
	Language = 'PowerShell'
	State    = 'Texas'
}
$obj.psobject.properties.remove('Name')
$obj
problem5
Can't automatically display the members and methods of adding C#class, and Unable to display the output results, working normally in PowerShell ISE, See the demo and code (In the second post below)

Code: Select all

$cs = @'
namespace Ns1
{
	public class Cl1
	{
		public static void Hi()
		{
			System.Console.WriteLine("hello!");
		}
	}
}
'@
Add-Type -TypeDefinition $cs

[Ns1.Cl1]::Hi()
Last edited by davider360 on Sat Oct 29, 2022 3:53 pm, edited 5 times in total.
davider360
Posts: 18
Last visit: Wed Nov 23, 2022 2:35 am

Re: Several problems about PrimalSense

Post by davider360 »

problem4 demo
4.gif
4.gif (170.99 KiB) Viewed 7101 times

problem5 demo
5.gif
5.gif (267.55 KiB) Viewed 7101 times

I have checked the options in the figure below, but it has no effect
5.png
5.png (28.8 KiB) Viewed 7101 times
User avatar
brittneyr
Site Admin
Posts: 1649
Last visit: Mon Mar 18, 2024 1:47 pm
Answers: 38
Been upvoted: 30 times

Re: Several problems about PrimalSense

Post by brittneyr »

ISE and PowerShell Studio run differently, and you should not expect them to behave the same. PowerShell Studio does not keep live runspaces like ISE does as to avoid runspace contamination. For more information on runspace contamination, you may find the follow articles helpful:
https://www.sapien.com/blog/2022/04/25/ ... -avoid-it/
https://www.sapien.com/blog/2014/05/05/ ... do-i-need/

As for your issues reported, it is generally a good idea to only post one issue per topic for future posts.

I'm currently investigating the behaviors reported and will update you when I have more information.

It's also worth mentioning that Windows 7 is not supported. This means that while we do not prevent the installation, we do not test our products with Windows 7.
Brittney
SAPIEN Technologies, Inc.
davider360
Posts: 18
Last visit: Wed Nov 23, 2022 2:35 am

Re: Several problems about PrimalSense

Post by davider360 »

brittneyr wrote: Mon Oct 31, 2022 9:09 am ISE and PowerShell Studio run differently, and you should not expect them to behave the same. PowerShell Studio does not keep live runspaces like ISE does as to avoid runspace contamination. For more information on runspace contamination, you may find the follow articles helpful:
https://www.sapien.com/blog/2022/04/25/ ... -avoid-it/
https://www.sapien.com/blog/2014/05/05/ ... do-i-need/

As for your issues reported, it is generally a good idea to only post one issue per topic for future posts.

I'm currently investigating the behaviors reported and will update you when I have more information.

It's also worth mentioning that Windows 7 is not supported. This means that while we do not prevent the installation, we do not test our products with Windows 7.
Thank you for your reply,

It would be more convenient if an option could be added to support these features

I just found another problem,
Get-Item command, there is no GetValueNames method, see the demo below
Is there a way to add these methods manually? I find a lot of this situation !
7.gif
7.gif (61.9 KiB) Viewed 6843 times
User avatar
Alexander Riedel
Posts: 8472
Last visit: Mon Mar 18, 2024 2:59 pm
Answers: 19
Been upvoted: 37 times

Re: Several problems about PrimalSense

Post by Alexander Riedel »

As Brittney pointed out, the ISE is not the same as PowerShell Studio. The ISE requires you to run code at least once to obtain the information and types needed.
While that my seem convenient at times, it has a number of disadvantages, not to speak of severe security implications. You should *never* be required to run code, specially if it comes from some place else, to obtain intellisense.
Please see here for a recent discussion on the issue: viewtopic.php?t=16067

In order for PowerShell Studio to give you correct information, you need to specify the type of a variable. PowerShell functions can return ANY type at runtime, which means
anything returned from Get-Item for example can really be anything. The exact type is only determined at runtime. That is great for a script with only a few lines. For anything more complex, that can get out of hand quickly.

We highly recommend to specify a type for a variable if you need intellisense specific to that.
2022-10-31_16-31-42.png
2022-10-31_16-31-42.png (50.05 KiB) Viewed 6706 times
This not only gives you intellisense without having to run code, it also makes your code more readable for your future self and others.
If, for example, you are debugging and a variable set to a specific type suddenly changes type you can see from the code what it should be.
Alexander Riedel
SAPIEN Technologies, Inc.
davider360
Posts: 18
Last visit: Wed Nov 23, 2022 2:35 am

Re: Several problems about PrimalSense

Post by davider360 »

Thanks for your guidance

Adding types before variables is too complicated for beginners :)

PowerShell is a very automated language, sometimes too restrictive, and can feel uninteresting because it's too complex.
If in powershell, all variable names are preceded by types, then I might as well learn C #

Of course this is a joke :D

Add the previous option, I can turn on the IntelliSense like ISE , which will be beginner-friendly,
davider360
Posts: 18
Last visit: Wed Nov 23, 2022 2:35 am

Re: Several problems about PrimalSense

Post by davider360 »

The ISE requires you to run code at least once to obtain the information and types needed.


After testing, in ISE, registry data types do not need to be run once, they can be recognized directly

Alexander Riedel wrote: Mon Oct 31, 2022 4:41 pm As Brittney pointed out, the ISE is not the same as PowerShell Studio. The ISE requires you to run code at least once to obtain the information and types needed.
While that my seem convenient at times, it has a number of disadvantages, not to speak of severe security implications. You should *never* be required to run code, specially if it comes from some place else, to obtain intellisense.
Please see here for a recent discussion on the issue: viewtopic.php?t=16067

In order for PowerShell Studio to give you correct information, you need to specify the type of a variable. PowerShell functions can return ANY type at runtime, which means
anything returned from Get-Item for example can really be anything. The exact type is only determined at runtime. That is great for a script with only a few lines. For anything more complex, that can get out of hand quickly.

We highly recommend to specify a type for a variable if you need intellisense specific to that.

2022-10-31_16-31-42.png

This not only gives you intellisense without having to run code, it also makes your code more readable for your future self and others.
If, for example, you are debugging and a variable set to a specific type suddenly changes type you can see from the code what it should be.
User avatar
Alexander Riedel
Posts: 8472
Last visit: Mon Mar 18, 2024 2:59 pm
Answers: 19
Been upvoted: 37 times

Re: Several problems about PrimalSense

Post by Alexander Riedel »

Does not.jpg
Does not.jpg (54.44 KiB) Viewed 6406 times
Not from where I am sitting. Make sure you restart the ISE before testing that, otherwise you fall prey to runspace contamination.
Alexander Riedel
SAPIEN Technologies, Inc.
davider360
Posts: 18
Last visit: Wed Nov 23, 2022 2:35 am

Re: Several problems about PrimalSense

Post by davider360 »

Alexander Riedel wrote: Tue Nov 01, 2022 5:48 pm Does not.jpg

Not from where I am sitting. Make sure you restart the ISE before testing that, otherwise you fall prey to runspace contamination.
Strange, I did restart ISE
c.png
c.png (52.61 KiB) Viewed 6443 times
User avatar
Alexander Riedel
Posts: 8472
Last visit: Mon Mar 18, 2024 2:59 pm
Answers: 19
Been upvoted: 37 times

Re: Several problems about PrimalSense

Post by Alexander Riedel »

Apples and oranges. You changed the code to use Get-Item with HKLM: rather than a registry path.
This uses the registry provider, which has been coded into the ISE to be supported this way.
https://devblogs.microsoft.com/scriptin ... ry-access/
That is great if that helps you.
Alexander Riedel
SAPIEN Technologies, Inc.
This topic is 1 year and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.