Page 1 of 1

Classes in multiple files

Posted: Mon Jul 01, 2019 9:18 pm
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.

Re: Classes in multiple files

Posted: Tue Jul 02, 2019 7:32 am
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.

Re: Classes in multiple files

Posted: Tue Jul 02, 2019 11:21 pm
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.