How to transform PSClass into module?
I consider PSClass - Object Oriented Scripting in Powershell as a very promising way to use simple OOP notations in my PowerShell productions.
The beauty of the original PSClass.ps1 construction is that it gives possibility to use very communicative/self-descriptive scriptblock in New-PSClass invocation.
It is constructed as a script that you have to run before any OOP syntax can be used in you own code.
My ambition is to convert it into standard PoweShell module (ie. PSClass.psm1) that could be imported by Import-Module cmdlet. Unfortunately, when content of the PSClass.ps1 is directly embedded into PSClass.psm1 subroutines note, constructor, property, method are not visible for Export-ModuleMember. Even if I use simple PSClass.psm1 definition like:
. .\PSClass.ps1 Export-ModuleMember -Function @('New-PSClass')
still subroutines note, constructor, property, method cannot be exported by Export-ModuleMember.
Has anybody any hint, how to make PSClass.ps1 script fully functional module with preserved self-descriptive scriptblock in New-PSClass invocation?
Personally I would rename PSClass.ps1 to PSClass.psm1 and the put the Export-ModuleMember command inside the PSClass.psm1 file. I don't see any value in dot sourcing PSClass.ps1 inside PSClass.psm1. Now you have two classes to pass redist rather than just one.
After looking at this script, I would add this to the end of the PSClass.psm1 file:
Export-ModuleMember -Function New-PSClass, constructor, note, property, method