Created
March 10, 2015 20:59
-
-
Save Jaykul/db1a254bdcbd4a14878b to your computer and use it in GitHub Desktop.
Playing with classes in PowerShell 5 (February Preview)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In the real world, I'm trying to use Nancy.NancyModule, but for demo's sake, it can be this simple: | |
add-type @' | |
namespace Nancy | |
{ | |
public abstract class NancyModule | |
{ | |
protected NancyModule() { } | |
} | |
} | |
'@ | |
# Use a ScriptBlock to keep the type definition and use in the same scope | |
&{ | |
class SampleModule : Nancy.NancyModule { | |
SampleModule() { | |
} | |
} | |
[SampleModule]::new() | |
} | |
# Get this error | |
# an object comes out too ... but the WriteLine doesn't get written, of course, | |
# so I have no idea how the object was constructed ... | |
Cannot find an overload for "new" and the argument count: "0". | |
At line:3 char:24 | |
+ SampleModule() { | |
+ ~ | |
+ CategoryInfo : NotSpecified: (:) [], MethodException | |
+ FullyQualifiedErrorId : MethodCountCouldNotFindBest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment