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 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.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
sorensor
Posts: 5
Joined: Tue Sep 01, 2015 7:20 pm

Classes in multiple files

Post by sorensor » Mon Jul 01, 2019 9:18 pm

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
Joined: Thu Aug 18, 2011 4:56 am

Re: Classes in multiple files

Post by davidc » Tue Jul 02, 2019 7:32 am

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
Joined: Tue Sep 01, 2015 7:20 pm

Re: Classes in multiple files

Post by sorensor » Tue Jul 02, 2019 11:21 pm

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.