PowerShell module?

Feb 12, 2013 at 9:04 PM
I think this project is great, however I'd love to see this framework exported as a PowerShell module to use it with PSGet
Nov 24, 2013 at 11:13 AM
Edited Nov 24, 2013 at 4:18 PM
I have tried to transform the script into module. Unfortunately the trial has not been successful.
The beauty of the original PSClass.ps1 construction is that it gives us possibility to use very communicative/self-descriptive scriptblock in New-PSClass invocation.
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:
if (Get-Module PSClass) { return }

Push-Location $psScriptRoot
. .\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?
Nov 24, 2013 at 5:28 PM
Edited Nov 24, 2013 at 5:30 PM
Thanks for your feedback. I took a quick attempt at it a couple of years ago. The thing that stopped me at the time was it seemed to obscure debugging. The current version lets you set breakpoints in your Class Methods. For some reason it seemed to be blocked by the it 'going through' the Module code. For me that was a non-starter.

I probably will make a go at it again with some prototyping to see if this is still a problem. The nice thing about this project is it let's you make elegant OO like code. My implementation is not so elegant. This really was one of my first PowerShell implementations when I was still reading books trying to figure out what PowerShell is all about. I think I could do better within the PowerShell mindset now. For the next month or so I will be working on my new PowerShell Database Deployment project. I've got 'real work and real money' waiting on it.

Nov 25, 2013 at 11:37 AM
Edited Nov 25, 2013 at 5:08 PM
Thank you for the reply and declaration.
I would like to ask you for one more thing.
It could be great, if PSClass didn't require Set-StrictMode -Off to work. The greatest think would be Set-StrictMode -Version Latest.

There is some interesting snippet in "Windows Powershell Cookbook" written by Jeremy D. Pavleck named New-CommandWrapper.ps1. Unfortunately, I am not proficient in PowerShell enough to use all mechanisms like Steppable Pipelines, Argument Splatting and Proxy Command APIs in PSClass context, but I feel that this is right direction.