PrimalSense not showing methods

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.
This topic is 3 years and 8 months 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.
gallery
Posts: 12
Last visit: Wed Apr 10, 2024 6:06 am

PrimalSense not showing methods

Post by gallery »

Product: PowerShell Studio 2020 (64 Bit)
Build: v5.7.179
OS: Windows Server 2019 Datacenter (64 Bit)
Build: v10.0.17763.0

Hi all,

I found a similar post subject but it's not the same issue.

I'm testing classes in modules so I started a new module project and added a few classes in.
The main class has properties and methods.

Not sure why but PrimalSense is only showing me the properties and not the methods, during or after debugging with breakpoints.

I've done the following to troubleshoot:
* If I call Get-Member on my variable it shows all the properties and methods.
* If I type the method by hand and run it, it works fine.
* Tried using a basic methods [int]testFunction{return 1} and [void]testFunction2{"aaa"}
* Tested 2 different constructors invocations with [var]::new() and new-object var
* I tried 3 methods to export the class in this page but same result: arcanecode<dot>com/2016/04/05/accessing-a-powershell-class-defined-in-a-module-from-outside-a-module/
* I tried to rebuild local cache and clear the session variables and restart PSStudio.
* I tested the module on ISE and it shows everything fine.
* Tested other classes in my module
* Same happens on the debug console

I could swear it was showing before but can't be positive.

Running out of ideas. Can someone help?

Cheers
gallery
Posts: 12
Last visit: Wed Apr 10, 2024 6:06 am

Re: PrimalSense not showing methods

Post by gallery »

Just an update,

I run a few more tests and found the problem, although I don't understand how this happens!
I closed the project and start a new script and it works.
because it was a new project I used the full path to the module, instead of the automatically added Import-Module 'MyModule'

So the fix is to use the full path to the module file!
User avatar
brittneyr
Site Admin
Posts: 1671
Last visit: Tue Apr 16, 2024 11:13 am
Answers: 39
Been upvoted: 31 times

Re: PrimalSense not showing methods

Post by brittneyr »

Classes are not loaded by default when you use the command Import-Module. Import-Module and the #requires statement only import the module functions, aliases, and variables, as defined by the module. Classes are not imported. The using module statement imports the classes defined in the module. If the module isn't loaded in the current session, the using statement fails. While importing via the path may be a workaround for this, I cannot say for sure as I have not tried.
You may find the following helpful:
https://docs.microsoft.com/en-us/powers ... wershell-7
https://stephanevg.github.io/powershell ... h-classes/

If after changing to a using statement and the intellsense is still not provided, then let me know. :)
Brittney
SAPIEN Technologies, Inc.
gallery
Posts: 12
Last visit: Wed Apr 10, 2024 6:06 am

Re: PrimalSense not showing methods

Post by gallery »

Thanks Brittney,

I did my due research before posting and I used used and all the possible combinations I could think of.
the problem is not the using module or import-module. they both only show the properties and not the methods.

the Test-Module.ps1 was automatically generated by PSStudio when I created the new module project and automatically added the import-module 'mymodule.psm1' so I assumed it was correct.
to be clear, I don't think this is a PowerShell issue, I think it's a PSStudio issue because somehow it can resolve the module (because I don't get an error) and it automatically added the code for me, and it knows the properties (confirming it resolves the file) but not the methods.

As I mentioned, I found a fix and hopefully this may help other people until the problem is fixed.

thanks.
User avatar
brittneyr
Site Admin
Posts: 1671
Last visit: Tue Apr 16, 2024 11:13 am
Answers: 39
Been upvoted: 31 times

Re: PrimalSense not showing methods

Post by brittneyr »

I'll investigate this behavior more and let you know when I have more information.
Brittney
SAPIEN Technologies, Inc.
This topic is 3 years and 8 months 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.