Classes in multiple files

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 4 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.
User avatar
sorensor
Posts: 5
Last visit: Tue Jul 02, 2019 11:21 pm

Classes in multiple files

Post by sorensor »

Product: PowerShell Studio 2019 (64 Bit)
Build: v5.6.158
OS: Windows 10 Enterprise (64 Bit)
Build: v10.0.16299.0

I'm attempting to make a powershell project with multiple classes, and I'd like to keep each class in its own separate folder. However as these classes need to reference each other I'm having trouble as the classes don't seem to know about each other.

Startup.pss is able to get type information and auto complete for classes in other files, but none of the class files themselves auto complete for other classes and Powershell Studio reports unknown types. Building the project works fine and inserting 'using module .\class.ps1' sometimes fixes the issue but it seems buggy.

To recreate, create a project add two separate class files, and add one as a member of the other.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Classes in multiple files

Post by davidc »

When PowerShell Studio runs a syntax check, it only does it for the open file. That is why PowerShell reports that it can't resolve the type.

Maybe we could filter out these false errors in a future build.
David
SAPIEN Technologies, Inc.
User avatar
sorensor
Posts: 5
Last visit: Tue Jul 02, 2019 11:21 pm

Re: Classes in multiple files

Post by sorensor »

That would be greatly appreciated. startup.pss manages to get class info from the other files fine.

In the meantime I guess I'll just have to cram all my classes into one file.
This topic is 4 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.